Release #16
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
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "patch | minor | major | 1.2.3" | |
| required: true | |
| default: "patch" | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| environment: npm | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| registry-url: https://registry.npmjs.org | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Test | |
| run: npm test | |
| - name: Build | |
| run: npm run build | |
| - name: Configure git | |
| run: | | |
| git config user.name "release-bot" | |
| git config user.email "release-bot@users.noreply.github.com" | |
| - name: Bump version and create release tag | |
| id: version | |
| run: | | |
| npm version "${{ inputs.version }}" -m "chore(release): v%s" | |
| VERSION=$(node -p "require('./package.json').version") | |
| MAJOR=$(node -p "require('./package.json').version.split('.')[0]") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "release_tag=v$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "major_tag=v$MAJOR" >> "$GITHUB_OUTPUT" | |
| - name: Push release commit and immutable tag | |
| run: | | |
| git push origin HEAD:${{ github.event.repository.default_branch }} | |
| git push origin "${{ steps.version.outputs.release_tag }}" | |
| - name: Update movable major tag | |
| run: | | |
| git tag -f "${{ steps.version.outputs.major_tag }}" "${{ steps.version.outputs.release_tag }}" | |
| git push origin "${{ steps.version.outputs.major_tag }}" --force | |
| - name: Create GitHub Release with generated changelog | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh release create "${{ steps.version.outputs.release_tag }}" \ | |
| --verify-tag \ | |
| --title "${{ steps.version.outputs.release_tag }}" \ | |
| --generate-notes | |
| - name: Publish to npm via Trusted Publisher | |
| run: npm publish --access public |