-
Notifications
You must be signed in to change notification settings - Fork 270
Release workflow #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Release workflow #744
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0868279
Create release.yml
acalcutt b5d547e
Create release instructions
acalcutt f44f948
Update RELEASE.md
acalcutt ce89160
add trailing return
acalcutt 271c359
Update token name
acalcutt 12dbfcf
tested working version
acalcutt 69435ea
use suggested wording
acalcutt 59b418c
use 'Triple ticks' around command
acalcutt e6cc652
add preid and prerelease info
acalcutt 0d24ac6
Update RELEASE.md
acalcutt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,107 @@ | ||
| name: release | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| release-check: | ||
| name: Check if version is published | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - name: Check if version is published | ||
| id: check | ||
| run: | | ||
| currentVersion="$( node -e "console.log(require('./package.json').version)" )" | ||
| isPublished="$( npm view @mapbox/node-pre-gyp versions --json | jq -c --arg cv "$currentVersion" 'any(. == $cv)' )" | ||
| echo "published=$isPublished" >> "$GITHUB_OUTPUT" | ||
| echo "currentVersion: $currentVersion" | ||
| echo "isPublished: $isPublished" | ||
| outputs: | ||
| published: ${{ steps.check.outputs.published }} | ||
|
|
||
| publish: | ||
| needs: release-check | ||
| if: ${{ needs.release-check.outputs.published == 'false' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
|
|
||
| - run: npm ci | ||
|
|
||
| - run: npm audit | ||
|
|
||
| - run: npm run lint | ||
|
|
||
| - run: npm run update-crosswalk # To support newer versions of Node.js | ||
|
|
||
| - run: npm run build --if-present | ||
|
|
||
| - run: npm test | ||
|
|
||
| - name: Get version | ||
| id: package-version | ||
| uses: martinbeentjes/[email protected] | ||
|
|
||
| - name: Prepare release changelog | ||
| id: prepare_release | ||
| run: | | ||
| RELEASE_TYPE="$(node -e "console.log(require('semver').prerelease('${{ steps.package-version.outputs.current-version }}') ? 'prerelease' : 'regular')")" | ||
| if [[ $RELEASE_TYPE == 'regular' ]]; then | ||
| echo "prerelease=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "prerelease=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Extract changelog for version | ||
| run: | | ||
| awk '/^##/ { p = 0 }; p == 1 { print }; $0 == "## ${{ steps.package-version.outputs.current-version }}" { p = 1 };' CHANGELOG.md > changelog_for_version.md | ||
| cat changelog_for_version.md | ||
|
|
||
| - name: Publish to Github | ||
| uses: ncipollo/release-action@v1 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| tag: v${{ steps.package-version.outputs.current-version }} | ||
| name: v${{ steps.package-version.outputs.current-version }} | ||
| bodyFile: changelog_for_version.md | ||
| allowUpdates: true | ||
| draft: false | ||
| prerelease: ${{ steps.prepare_release.outputs.prerelease }} | ||
|
|
||
| - name: Publish to NPM (release) | ||
| if: ${{ steps.prepare_release.outputs.prerelease == 'false' }} | ||
| run: | | ||
| npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" | ||
| npm publish --access public | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
|
||
| - name: Publish to NPM (prerelease) | ||
| if: ${{ steps.prepare_release.outputs.prerelease == 'true' }} | ||
| run: | | ||
| npm config set //registry.npmjs.org/:_authToken "${NPM_TOKEN}" | ||
| npm publish --tag next --access public | ||
| env: | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains hidden or 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,23 @@ | ||
| # Instructions for making a release | ||
|
|
||
| 1. Change the version number in `package.json`. Run the following command in the package root directory, replacing <update_type> with one of the semantic versioning release types (prerelease, prepatch, preminor, premajor, patch, minor, major): | ||
|
|
||
| ``` | ||
| npm version <update_type> --preid pre --no-git-tag-version | ||
| ``` | ||
|
|
||
acalcutt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| `--preid` specifies which suffix to use in the release such as `pre`, `next`, `beta`, `rc`, etc. | ||
|
|
||
| `prepatch`, `preminor`, and `premajor` start a new series of pre-releases while bumping the patch, minor, or major version. E.g. `premajor` with `--preid pre` would do a prerelease for a new major using the `-pre` suffix (i.e. it would be a new major with `-pre.0`) | ||
|
|
||
| You can use `prerelease` to bump the version for a new pre-release version. E.g. you could run `npm version prerelease --preid pre --no-git-tag-version` to go from `-pre.0` to `-pre.1`. | ||
|
|
||
| For regular versions, you can use `patch`, `minor`, or `major`. E.g. `npm version major --no-git-tag-version`. | ||
|
|
||
| 2. Update the changelog, which can be found in `CHANGELOG.md`. The heading must match `## <VERSION>` exactly, or it will not be picked up. For example, for version 1.0.11: | ||
acalcutt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ``` | ||
| ## 1.0.11 | ||
| ``` | ||
|
|
||
| 3. Commit and push the changes. On push the release workflow will automaticlly check if the release has been published on npm. If the release has not yet been published, the workflow will update the abi crosswalk file and publish a new npm release. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.