From 4d98ead3f20fc9e41db1c1440f7e46dd89365f05 Mon Sep 17 00:00:00 2001 From: Yixuan Xu Date: Fri, 27 Jan 2023 15:24:39 +0800 Subject: [PATCH 1/4] ci: only run release when tags pushed --- .github/workflows/install/action.yml | 9 ++++----- .github/workflows/release.yml | 9 ++++----- .github/workflows/test.yml | 3 +-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/install/action.yml b/.github/workflows/install/action.yml index b08bee4e6..e0262e120 100644 --- a/.github/workflows/install/action.yml +++ b/.github/workflows/install/action.yml @@ -3,10 +3,12 @@ description: 'Set up and install dependencies' inputs: fetch-depth: + description: 'Number of commits to fetch' default: '1' required: false persist-credentials: - default: true + description: 'Whether to persist credentials' + default: "true" required: false @@ -17,7 +19,7 @@ runs: uses: actions/checkout@v3 - name: Setup pnpm - uses: pnpm/action-setup@v2.2.2 + uses: pnpm/action-setup@v2.2.4 - name: Use Node.js 16 uses: actions/setup-node@v3 @@ -27,9 +29,6 @@ runs: - name: Install Dependencies shell: bash - run: | corepack enable pnpm install - env: - CI: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db8a611ed..6f16e6c69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ on: jobs: release: + if: ${{ contains('refs/tags', github.ref) == 'true' }} runs-on: ubuntu-latest steps: - name: Check out @@ -19,9 +20,7 @@ jobs: - name: Install uses: ./.github/workflows/install - - name: Publish - run: | - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - npm publish --access public + - name: Release + run: pnpm publish --access public --no-git-checks env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 350c74961..dbc437bb4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: - main pull_request: + jobs: test: @@ -22,5 +23,3 @@ jobs: pnpm clean pnpm build pnpm test-packaging - env: - CI: true From 3d06cac8c3eefa6b62dca1597e0f891a69091bfa Mon Sep 17 00:00:00 2001 From: Yixuan Xu Date: Fri, 27 Jan 2023 15:50:04 +0800 Subject: [PATCH 2/4] chore: merge release and test --- .github/workflows/release.yml | 26 -------------------------- .github/workflows/test.yml | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 6f16e6c69..000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: [Lint and Test] - types: - - completed - push: - tags: - - v* - -jobs: - release: - if: ${{ contains('refs/tags', github.ref) == 'true' }} - runs-on: ubuntu-latest - steps: - - name: Check out - uses: actions/checkout@v3 - - - name: Install - uses: ./.github/workflows/install - - - name: Release - run: pnpm publish --access public --no-git-checks - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dbc437bb4..2b6da3b5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,9 @@ on: push: branches: - main + tags: + - v* pull_request: - jobs: test: @@ -23,3 +24,17 @@ jobs: pnpm clean pnpm build pnpm test-packaging + release: + runs-on: ubuntu-latest + if: ${{ contains('refs/tags', github.ref) == 'true' && jobs.test.result == 'success' }} + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Install + uses: ./.github/workflows/install + + - name: Release + run: pnpm publish --access public --no-git-checks + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} From 9fd7bddaa3e47d5883bc15f9641507d445eb4389 Mon Sep 17 00:00:00 2001 From: Yixuan Xu Date: Fri, 27 Jan 2023 15:53:55 +0800 Subject: [PATCH 3/4] fix syntax and sequence --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2b6da3b5a..5d0286a90 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,8 @@ jobs: pnpm test-packaging release: runs-on: ubuntu-latest - if: ${{ contains('refs/tags', github.ref) == 'true' && jobs.test.result == 'success' }} + needs: test + if: ${{ contains('refs/tags', github.ref) == 'true' }} steps: - name: Check out uses: actions/checkout@v3 From 52fbed93c239ecc4a2e5eef44bd91885799c6ab4 Mon Sep 17 00:00:00 2001 From: Yixuan Xu Date: Fri, 27 Jan 2023 18:30:03 +0800 Subject: [PATCH 4/4] chore: rename action --- .github/workflows/{test.yml => test-release.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{test.yml => test-release.yml} (97%) diff --git a/.github/workflows/test.yml b/.github/workflows/test-release.yml similarity index 97% rename from .github/workflows/test.yml rename to .github/workflows/test-release.yml index 5d0286a90..873cd27ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test-release.yml @@ -1,4 +1,4 @@ -name: Lint and Test +name: Test and Release on: push: