-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflows for automated release & publish (#151)
- Loading branch information
Showing
7 changed files
with
324 additions
and
288 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Create Release Pull Request | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
base-branch: | ||
description: 'The base branch for git operations and the pull request.' | ||
default: 'main' | ||
required: true | ||
release-type: | ||
description: 'A SemVer version diff, i.e. major, minor, patch, prerelease etc. Mutually exclusive with "release-version".' | ||
required: false | ||
release-version: | ||
description: 'A specific version to bump to. Mutually exclusive with "release-type".' | ||
required: false | ||
|
||
jobs: | ||
create-release-pr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
# This is to guarantee that the most recent tag is fetched. | ||
# This can be configured to a more reasonable value by consumers. | ||
fetch-depth: 0 | ||
# 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: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
- uses: MetaMask/action-create-release-pr@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
release-type: ${{ github.event.inputs.release-type }} | ||
release-version: ${{ github.event.inputs.release-version }} |
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,61 @@ | ||
name: Main | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
jobs: | ||
build-lint-test: | ||
name: Test | ||
uses: ./.github/workflows/build-lint-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@v2 | ||
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 }} |
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,83 @@ | ||
name: Publish Release | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
NPM_TOKEN: | ||
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@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
# TODO: use default version when node.engines has been bumped to at least v16 in package.json | ||
node-version: '20.x' | ||
- uses: MetaMask/action-publish-release@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Install | ||
run: | | ||
yarn --frozen-lockfile --ignore-scripts | ||
yarn build | ||
- uses: actions/cache@v4 | ||
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@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- uses: actions/cache@v4 | ||
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@v4 | ||
with: | ||
ref: ${{ github.sha }} | ||
- uses: actions/cache@v4 | ||
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 |
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,39 +1,30 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [3.1.1] - 2024-03-12 | ||
|
||
### Fixed | ||
|
||
- Fix ESM module path ([#143](https://github.com/MetaMask/safe-event-emitter/pull/143)) | ||
- Fix ESM source map paths ([#146](https://github.com/MetaMask/safe-event-emitter/pull/146)) | ||
|
||
## [3.1.0] - 2024-03-08 | ||
|
||
### Added | ||
|
||
- Add ESM build ([#141](https://github.com/MetaMask/safe-event-emitter/pull/141)) | ||
|
||
## [3.0.0] - 2023-04-24 | ||
|
||
### Breaking | ||
|
||
- Drop support for Node.js < v12 ([#101](https://github.com/MetaMask/safe-event-emitter/pull/101)) | ||
|
||
### Changed | ||
|
||
- devDependencies and CI updates | ||
- **BREAKING**: Drop support for Node.js < v12 ([#101](https://github.com/MetaMask/safe-event-emitter/pull/101)) | ||
|
||
## [2.0.0] - 2020-09-02 | ||
|
||
### Changed | ||
|
||
- Migrate to TypeScript ([#1](https://github.com/MetaMask/safe-event-emitter/pull/1)) | ||
|
||
[Unreleased]:https://github.com/MetaMask/safe-event-emitter/compare/v2.0.0...HEAD | ||
[2.0.0]:https://github.com/MetaMask/safe-event-emitter/tree/v2.0.0 | ||
[Unreleased]: https://github.com/MetaMask/safe-event-emitter/compare/v3.1.1...HEAD | ||
[3.1.1]: https://github.com/MetaMask/safe-event-emitter/compare/v3.1.0...v3.1.1 | ||
[3.1.0]: https://github.com/MetaMask/safe-event-emitter/compare/v3.0.0...v3.1.0 | ||
[3.0.0]: https://github.com/MetaMask/safe-event-emitter/compare/v2.0.0...v3.0.0 | ||
[2.0.0]: https://github.com/MetaMask/safe-event-emitter/releases/tag/v2.0.0 |
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
Oops, something went wrong.