Release #65
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
# docs: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions | |
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
newversion: | |
# is param from `npm version`. therefore the description should reference all the options from there | |
description: 'one of: [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]' | |
required: true | |
commitMessage: | |
description: 'Release/commit message (%s will be replaced with the resulting version number)' | |
default: '%s' | |
required: true | |
preid: | |
description: 'The "prerelease identifier" to use as a prefix for the "prerelease" part of a semver. Like the rc in `1.2.0-rc.8`.' | |
type: choice | |
options: | |
- rc | |
- beta | |
- alpha | |
default: rc | |
required: false | |
prerelease: | |
description: "This a pre-release" | |
type: boolean | |
default: false | |
required: false | |
env: | |
# https://nodejs.dev/en/about/releases/ | |
NODE_ACTIVE_LTS: "20" | |
jobs: | |
bump: | |
name: bump and tag release | |
concurrency: release-bump | |
outputs: | |
version: ${{ steps.bump.outputs.version }} | |
version_plain: ${{ steps.bump.outputs.version_plain }} | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
- name: Configure Git | |
# needed for push back of changes | |
run: | | |
set -ex | |
git config --local user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git config --local user.name "${GITHUB_ACTOR}" | |
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }} | |
# see https://github.com/actions/setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_ACTIVE_LTS }} | |
- name: bump VERSION | |
id: bump | |
run: | | |
set -ex | |
VERSION="$(npm version "$NPMV_NEWVERSION" --message "$NPMV_MESSAGE" --preid "$NPMV_PREID")" | |
echo "::debug::new version = $VERSION" | |
VERSION_PLAIN="${VERSION:1}" # remove 'v' prefix | |
echo "::debug::plain version = $VERSION_PLAIN" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "version_plain=$VERSION_PLAIN" >> $GITHUB_OUTPUT | |
env: | |
NPMV_NEWVERSION: ${{ github.event.inputs.newversion }} | |
NPMV_MESSAGE: ${{ github.event.inputs.commitMessage }} | |
NPMV_PREID: ${{ github.event.inputs.preid }} | |
- name: git push back | |
run: git push --follow-tags | |
publish-NPMJS: | |
needs: | |
- "bump" | |
name: publish NPMJS | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout code | |
# see https://github.com/actions/checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.bump.outputs.version }} | |
- name: Setup Node.js ${{ env.NODE_ACTIVE_LTS }} | |
# see https://github.com/actions/setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_ACTIVE_LTS }} | |
- name: login to NPMJS | |
run: npm config set "//registry.npmjs.org/:_authToken=$NPMJS_AUTH_TOKEN" | |
env: | |
NPMJS_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: publish to NPMJS as "latest" | |
if: ${{ github.event.inputs.prerelease != 'true' }} | |
run: npm publish --access public --tag 'latest' | |
- name: publish to NPMJS as "unstable-prerelease" | |
if: ${{ github.event.inputs.prerelease == 'true' }} | |
run: npm publish --access public --tag 'unstable-prerelease' | |
release-GH: | |
needs: | |
- "bump" | |
- "publish-NPMJS" | |
name: publish GitHub | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Create Release | |
id: release | |
# see https://github.com/softprops/action-gh-release | |
uses: softprops/action-gh-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.bump.outputs.version }} | |
name: ${{ needs.bump.outputs.version_plain }} | |
prerelease: ${{ github.event.inputs.prerelease }} |