-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update workflows and automate releases (#125)
* chore: Update workflows and automate releases The GitHub Action workflows have been updated based on the module template. The changes made from the template are: * There are no tests, so the test step from "build-lint-test" was removed. * The "build" step is now run on three Node.js versions rathern than just one. In the template we rely more on tests for compatibility, but that won't work with no tests of course. * The "build" step builds the demo, not the package. There is no build step for the package, it's not in TypeScript (yet). * The API doc publishing was removed (this repo uses the `gh-pages` branch for the demo). * The changelog doesn't use Prettier formatting yet (this requires more lint tooling/config updates). The changes made from the previous workflows in this repository are: * Automated npm publishing * Removed "require additional reviewer" workflow (we've stopped using this) * Additional workflow linting * Updated vertions of various actions * Update base image to `ubuntu-latest` * Add Node.js v22.x to the test matrix * Add checks for a dirty working tree Additionally, the "publish-gh-pages" workflow was updated to use the same "checkout, install Node.js, and install dependencies" steps as elsewhere. This workflow has no analog in the module template. * Remove non-existent build step and build artifacts from publishing workflow * Update to latest version of npm publish action Co-authored-by: Elliot Winkler <[email protected]> --------- Co-authored-by: Elliot Winkler <[email protected]>
- Loading branch information
Showing
7 changed files
with
221 additions
and
90 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
check-workflows: | ||
name: Check workflows | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Download actionlint | ||
id: download-actionlint | ||
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/7fdc9630cc360ea1a469eed64ac6d78caeda1234/scripts/download-actionlint.bash) 1.6.23 | ||
shell: bash | ||
- name: Check workflow files | ||
run: ${{ steps.download-actionlint.outputs.executable }} -color | ||
shell: bash | ||
|
||
build-lint: | ||
name: Build and lint | ||
uses: ./.github/workflows/build-lint.yml | ||
|
||
all-jobs-completed: | ||
name: All jobs completed | ||
runs-on: ubuntu-latest | ||
needs: | ||
- check-workflows | ||
- build-lint | ||
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 }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
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,73 @@ | ||
name: Publish Release | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
workflow_call: | ||
secrets: | ||
NPM_TOKEN: | ||
required: true | ||
SLACK_WEBHOOK_URL: | ||
required: true | ||
|
||
jobs: | ||
publish-release: | ||
permissions: | ||
contents: write | ||
if: | | ||
github.event.pull_request.merged == true && | ||
startsWith(github.event.pull_request.head.ref, 'release/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
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 ::set-output name=NODE_VERSION::$(cat .nvmrc) | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ steps.nvm.outputs.NODE_VERSION }} | ||
- uses: MetaMask/action-publish-release@v1 | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Install Corepack via Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Install Yarn | ||
run: corepack enable | ||
- uses: MetaMask/action-publish-release@v3 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
publish-npm-dry-run: | ||
needs: publish-release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Install Corepack via Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Install Yarn | ||
run: corepack enable | ||
- name: Dry Run Publish | ||
# omit npm-token token to perform dry run publish | ||
uses: MetaMask/action-npm-publish@v5 | ||
with: | ||
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
subteam: S042S7RE4AE # @metamask-npm-publishers | ||
env: | ||
SKIP_PREPACK: true | ||
|
||
publish-npm: | ||
needs: publish-npm-dry-run | ||
runs-on: ubuntu-latest | ||
environment: npm-publish | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Install Corepack via Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- name: Install Yarn | ||
run: corepack enable | ||
- name: Publish | ||
uses: MetaMask/action-npm-publish@v5 | ||
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 was deleted.
Oops, something went wrong.
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