generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GitHub actions to match module template (#125)
The GitHub actions have been updated to match the latest used in the module template, with some exceptions. The require-additional-reviewer action was omitted because it's broken for forks, and the documentation-related steps have been omitted because this repository does not yet have API documentation. The build has also been included in the lint step, because the changelog linting relies upon the built `auto-changelog` tool. See: https://github.com/MetaMask/metamask-module-template/tree/a3b2e531a7961ccc32577ac3c49aa651a14623cd/.github/workflows
- Loading branch information
Showing
5 changed files
with
196 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,87 @@ | ||
name: Publish Release | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
is-release: | ||
# release merge commits come from github-actions | ||
if: startsWith(github.event.commits[0].author.name, 'github-actions') | ||
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: | ||
permissions: | ||
contents: write | ||
if: | | ||
github.event.pull_request.merged == true && | ||
startsWith(github.event.pull_request.head.ref, 'release/') | ||
if: needs.is-release.outputs.IS_RELEASE == 'true' | ||
runs-on: ubuntu-latest | ||
needs: is-release | ||
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 }} | ||
- name: Get Node.js version | ||
id: nvm | ||
run: echo "NODE_VERSION=$(cat .nvmrc)" >> "$GITHUB_OUTPUT" | ||
- uses: actions/setup-node@v3 | ||
ref: ${{ github.sha }} | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ steps.nvm.outputs.NODE_VERSION }} | ||
- uses: MetaMask/action-publish-release@v1 | ||
node-version-file: '.nvmrc' | ||
- uses: MetaMask/action-publish-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install | ||
run: | | ||
yarn install | ||
yarn build | ||
- uses: actions/cache@v3 | ||
id: restore-build | ||
with: | ||
path: ./dist | ||
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 | ||
key: ${{ github.sha }} | ||
# Set `ignore-scripts` to skip `prepublishOnly` because the release was built already in the previous job | ||
- run: npm config set ignore-scripts true | ||
- name: Dry Run Publish | ||
# omit npm-token token to perform dry run publish | ||
uses: MetaMask/action-npm-publish@v1 | ||
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 | ||
key: ${{ github.sha }} | ||
# Set `ignore-scripts` to skip `prepublishOnly` because the release was built already in the previous job | ||
- run: npm config set ignore-scripts true | ||
- name: Publish | ||
uses: MetaMask/action-npm-publish@v1 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
set -e | ||
set -o pipefail | ||
|
||
if [[ -n $SKIP_PREPACK ]]; then | ||
echo "Notice: skipping prepack." | ||
exit 0 | ||
fi | ||
|
||
yarn build |