Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(ci): add publish-npm steps to publish-release workflow
  • Loading branch information
legobeat committed May 16, 2024
commit e571b294d61f9faae70b170702b1fa5e6b6b874d
4 changes: 4 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Create Release Pull Request

permissions:
contents: write
pull-requests: write

on:
workflow_dispatch:
inputs:
Expand Down
65 changes: 60 additions & 5 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Publish Release

on:
pull_request:
types: [closed]
workflow_call:
secrets:
NPM_TOKEN:
required: true

jobs:
publish-release:
Expand All @@ -15,13 +17,66 @@ 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:
node-version-file: '.nvmrc'
- 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