From 44935a000fb3f1f4a76de4de49edd3c66655f03f Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 9 May 2024 08:32:25 +0000 Subject: [PATCH 1/6] ci: update actions/checkout from v2 to v3 --- .github/workflows/create-release-pr.yml | 2 +- .github/workflows/publish-release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index e843833d..80c6f90b 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -21,7 +21,7 @@ jobs: contents: write pull-requests: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: # This is to guarantee that the most recent tag is fetched. # This can be configured to a more reasonable value by consumers. diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 31484ac4..db566334 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -13,7 +13,7 @@ jobs: startsWith(github.event.pull_request.head.ref, 'release/') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: # We check out the release pull request's base branch, which will be # used as the base branch for all git operations. From d90f402ee88f18e2a5060f38398b9f0db6ce8d51 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 9 May 2024 08:40:04 +0000 Subject: [PATCH 2/6] ci: update actions/setup-node from v2 to v3 --- .github/workflows/build-test.yml | 2 +- .github/workflows/create-release-pr.yml | 8 +++----- .github/workflows/publish-release.yml | 8 +++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 9c7c9ba5..f4d55dde 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Get Yarn cache directory diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 80c6f90b..2e05ca81 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -29,12 +29,10 @@ jobs: # We check out the specified branch, which will be used as the base # branch for all git operations and the release PR. ref: ${{ github.event.inputs.base-branch }} - - name: Get Node.js version - id: nvm - run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) - - uses: actions/setup-node@v2 + - name: Setup Node.js + uses: actions/setup-node@v3 with: - node-version: ${{ steps.nvm.outputs.NODE_VERSION }} + node-version-file: '.nvmrc' - uses: MetaMask/action-create-release-pr@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index db566334..30655e85 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -18,12 +18,10 @@ jobs: # We check out the release pull request's base branch, which will be # used as the base branch for all git operations. ref: ${{ github.event.pull_request.base.ref }} - - name: Get Node.js version - id: nvm - run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) - - uses: actions/setup-node@v2 + - name: Setup Node.js + uses: actions/setup-node@v3 with: - node-version: ${{ steps.nvm.outputs.NODE_VERSION }} + node-version-file: '.nvmrc' - uses: MetaMask/action-publish-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From e571b294d61f9faae70b170702b1fa5e6b6b874d Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 9 May 2024 09:07:23 +0000 Subject: [PATCH 3/6] chore(ci): add publish-npm steps to publish-release workflow --- .github/workflows/create-release-pr.yml | 4 ++ .github/workflows/publish-release.yml | 65 +++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index 2e05ca81..fe78e867 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -1,5 +1,9 @@ name: Create Release Pull Request +permissions: + contents: write + pull-requests: write + on: workflow_dispatch: inputs: diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 30655e85..b9e90c32 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -1,8 +1,10 @@ name: Publish Release on: - pull_request: - types: [closed] + workflow_call: + secrets: + NPM_TOKEN: + required: true jobs: publish-release: @@ -15,9 +17,7 @@ jobs: steps: - uses: actions/checkout@v3 with: - # We check out the release pull request's base branch, which will be - # used as the base branch for all git operations. - ref: ${{ github.event.pull_request.base.ref }} + ref: ${{ github.sha }} - name: Setup Node.js uses: actions/setup-node@v3 with: @@ -25,3 +25,58 @@ jobs: - uses: MetaMask/action-publish-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install + run: | + yarn install + yarn build + - uses: actions/cache@v3 + id: restore-build + with: + path: | + ./dist + ./node_modules/.yarn-state.yml + key: ${{ github.sha }} + + publish-npm-dry-run: + runs-on: ubuntu-latest + needs: publish-release + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - uses: actions/cache@v3 + id: restore-build + with: + path: | + ./dist + ./node_modules/.yarn-state.yml + key: ${{ github.sha }} + - name: Dry Run Publish + # omit npm-token token to perform dry run publish + uses: MetaMask/action-npm-publish@v2 + env: + SKIP_PREPACK: true + + publish-npm: + environment: npm-publish + runs-on: ubuntu-latest + needs: publish-npm-dry-run + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.sha }} + - uses: actions/cache@v3 + id: restore-build + with: + path: | + ./dist + ./node_modules/.yarn-state.yml + key: ${{ github.sha }} + - name: Publish + uses: MetaMask/action-npm-publish@v2 + with: + # This `NPM_TOKEN` needs to be manually set per-repository. + # Look in the repository settings under "Environments", and set this token in the `npm-publish` environment. + npm-token: ${{ secrets.NPM_TOKEN }} + env: + SKIP_PREPACK: true From f03cba61fd75ae55be14222c86feff3553ac8ab4 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 9 May 2024 09:11:21 +0000 Subject: [PATCH 4/6] ci: refactor to main.yml entrypoint --- .github/workflows/build-test.yml | 11 +----- .github/workflows/main.yml | 61 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f4d55dde..bda779e6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,9 +1,7 @@ name: Build, Lint, and Test on: - push: - branches: [main] - pull_request: + workflow_call: jobs: build-lint-test: @@ -40,10 +38,3 @@ jobs: - name: Validate changelog if: ${{ !startsWith(github.head_ref, 'release/') }} run: yarn auto-changelog validate - all-jobs-pass: - name: All jobs pass - runs-on: ubuntu-20.04 - needs: - - build-lint-test - steps: - - run: echo "Great success!" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..9ab3c8bc --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,61 @@ +name: Main + +on: + push: + branches: [main] + pull_request: + +jobs: + build-lint-test: + name: Test + uses: ./.github/workflows/build-test.yml + + all-jobs-completed: + name: All jobs completed + runs-on: ubuntu-latest + needs: + - build-lint-test + outputs: + PASSED: ${{ steps.set-output.outputs.PASSED }} + steps: + - name: Set PASSED output + id: set-output + run: echo "PASSED=true" >> "$GITHUB_OUTPUT" + + all-jobs-pass: + name: All jobs pass + if: ${{ always() }} + runs-on: ubuntu-latest + needs: all-jobs-completed + steps: + - name: Check that all jobs have passed + run: | + passed="${{ needs.all-jobs-completed.outputs.PASSED }}" + if [[ $passed != "true" ]]; then + exit 1 + fi + + is-release: + # Filtering by `push` events ensures that we only release from the `main` branch, which is a + # requirement for our npm publishing environment. + # The commit author should always be 'github-actions' for releases created by the + # 'create-release-pr' workflow, so we filter by that as well to prevent accidentally + # triggering a release. + if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions') + needs: all-jobs-pass + outputs: + IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }} + runs-on: ubuntu-latest + steps: + - uses: MetaMask/action-is-release@v1 + id: is-release + + publish-release: + needs: is-release + if: needs.is-release.outputs.IS_RELEASE == 'true' + name: Publish release + permissions: + contents: write + uses: ./.github/workflows/publish-release.yml + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From b5fdfba68d784121c749acd459daa347be9e6c72 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 9 May 2024 09:22:03 +0000 Subject: [PATCH 5/6] ci: upgrade MetaMask/action-publish-release from v1 to v2 --- .github/workflows/publish-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index b9e90c32..a08fa299 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -22,7 +22,7 @@ jobs: uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' - - uses: MetaMask/action-publish-release@v1 + - uses: MetaMask/action-publish-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install From 39c0c94d9fd69f72df8a47b590ec95fcfbffcd6a Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 9 May 2024 09:23:36 +0000 Subject: [PATCH 6/6] chore: rename build-test.yml to build-lint-test.yml --- .github/workflows/{build-test.yml => build-lint-test.yml} | 0 .github/workflows/main.yml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{build-test.yml => build-lint-test.yml} (100%) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-lint-test.yml similarity index 100% rename from .github/workflows/build-test.yml rename to .github/workflows/build-lint-test.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ab3c8bc..2af11a0a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ on: jobs: build-lint-test: name: Test - uses: ./.github/workflows/build-test.yml + uses: ./.github/workflows/build-lint-test.yml all-jobs-completed: name: All jobs completed