|
1 | 1 | name: Publish Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - types: [closed] |
6 | | - |
| 4 | + workflow_call: |
| 5 | + secrets: |
| 6 | + NPM_TOKEN: |
| 7 | + required: true |
| 8 | + SLACK_WEBHOOK_URL: |
| 9 | + required: true |
| 10 | + PUBLISH_DOCS_TOKEN: |
| 11 | + required: true |
7 | 12 | jobs: |
8 | 13 | publish-release: |
9 | 14 | permissions: |
10 | 15 | contents: write |
11 | | - if: | |
12 | | - github.event.pull_request.merged == true && |
13 | | - startsWith(github.event.pull_request.head.ref, 'release/') |
14 | 16 | runs-on: ubuntu-latest |
15 | 17 | steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - with: |
18 | | - # We check out the release pull request's base branch, which will be |
19 | | - # used as the base branch for all git operations. |
20 | | - ref: ${{ github.event.pull_request.base.ref }} |
21 | | - - uses: actions/setup-node@v4 |
| 18 | + - name: Checkout and setup environment |
| 19 | + uses: MetaMask/action-checkout-and-setup@v1 |
22 | 20 | with: |
23 | | - node-version-file: .nvmrc |
24 | | - - uses: MetaMask/action-publish-release@v1 |
| 21 | + is-high-risk-environment: true |
| 22 | + ref: ${{ github.sha }} |
| 23 | + - uses: MetaMask/action-publish-release@v3 |
25 | 24 | env: |
26 | 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + - run: yarn build |
| 27 | + - name: Upload build artifacts |
| 28 | + uses: actions/upload-artifact@v4 |
| 29 | + with: |
| 30 | + name: publish-release-artifacts-${{ github.sha }} |
| 31 | + retention-days: 4 |
| 32 | + include-hidden-files: true |
| 33 | + path: | |
| 34 | + ./dist |
| 35 | + ./node_modules/.yarn-state.yml |
| 36 | +
|
| 37 | + publish-npm-dry-run: |
| 38 | + needs: publish-release |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - name: Checkout and setup environment |
| 42 | + uses: MetaMask/action-checkout-and-setup@v1 |
| 43 | + with: |
| 44 | + is-high-risk-environment: true |
| 45 | + ref: ${{ github.sha }} |
| 46 | + - name: Restore build artifacts |
| 47 | + uses: actions/download-artifact@v4 |
| 48 | + with: |
| 49 | + name: publish-release-artifacts-${{ github.sha }} |
| 50 | + - name: Dry Run Publish |
| 51 | + # omit npm-token token to perform dry run publish |
| 52 | + uses: MetaMask/action-npm-publish@v5 |
| 53 | + with: |
| 54 | + slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 55 | + subteam: S042S7RE4AE # @metamask-npm-publishers |
| 56 | + env: |
| 57 | + SKIP_PREPACK: true |
| 58 | + |
| 59 | + publish-npm: |
| 60 | + needs: publish-npm-dry-run |
| 61 | + runs-on: ubuntu-latest |
| 62 | + environment: npm-publish |
| 63 | + steps: |
| 64 | + - name: Checkout and setup environment |
| 65 | + uses: MetaMask/action-checkout-and-setup@v1 |
| 66 | + with: |
| 67 | + is-high-risk-environment: true |
| 68 | + ref: ${{ github.sha }} |
| 69 | + - name: Restore build artifacts |
| 70 | + uses: actions/download-artifact@v4 |
| 71 | + with: |
| 72 | + name: publish-release-artifacts-${{ github.sha }} |
| 73 | + - name: Publish |
| 74 | + uses: MetaMask/action-npm-publish@v5 |
| 75 | + with: |
| 76 | + # This `NPM_TOKEN` needs to be manually set per-repository. |
| 77 | + # Look in the repository settings under "Environments", and set this token in the `npm-publish` environment. |
| 78 | + npm-token: ${{ secrets.NPM_TOKEN }} |
| 79 | + env: |
| 80 | + SKIP_PREPACK: true |
0 commit comments