Release #116
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
| # Full release workflow — bumps version, commits, tags, and pushes. | |
| # Run manually when you need a specific bump type (patch/minor/major). | |
| # Or provide an exact_version to set a specific version directly. | |
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Type of version bump' | |
| required: true | |
| default: patch | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - prerelease | |
| exact_version: | |
| description: 'Exact version to set (overrides bump_type if provided)' | |
| required: false | |
| default: '' | |
| type: string | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN || secrets.PAT || github.token }} | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version | |
| id: bump | |
| run: | | |
| CURRENT=$(node -p "require('./package.json').version") | |
| echo "Current: $CURRENT" | |
| EXACT_VERSION='${{ github.event.inputs.exact_version }}' | |
| if [ -n "$EXACT_VERSION" ]; then | |
| NEW_VERSION=$EXACT_VERSION | |
| else | |
| BUMP_TYPE=${{ github.event.inputs.bump_type }} | |
| if [ "$BUMP_TYPE" = "prerelease" ]; then | |
| NEW_VERSION=$(npx semver $CURRENT -i prerelease --preid alpha) | |
| else | |
| NEW_VERSION=$(npx semver $CURRENT -i $BUMP_TYPE) | |
| fi | |
| fi | |
| echo "New: $NEW_VERSION" | |
| npm version $NEW_VERSION --no-git-tag-version | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Commit and tag | |
| run: | | |
| git add package.json package-lock.json | |
| EXACT_VERSION='${{ github.event.inputs.exact_version }}' | |
| if [ -n "$EXACT_VERSION" ]; then | |
| git commit -m "chore: bump version to ${{ steps.bump.outputs.version }} [skip ci]" | |
| else | |
| BUMP_TYPE=${{ github.event.inputs.bump_type }} | |
| if [ "$BUMP_TYPE" = "prerelease" ]; then | |
| git commit -m "chore: bump alpha version to ${{ steps.bump.outputs.version }} [skip ci]" | |
| else | |
| git commit -m "chore: bump version to ${{ steps.bump.outputs.version }} [skip ci]" | |
| fi | |
| fi | |
| git tag v${{ steps.bump.outputs.version }} | |
| git push origin main | |
| git push origin v${{ steps.bump.outputs.version }} | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Determine dist-tag | |
| id: dist_tag | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| if echo "$VERSION" | grep -q "alpha"; then | |
| echo "tag=alpha" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=latest" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Verify npm token | |
| run: npm whoami | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # Token publish (no --provenance flag). Provenance + token together can 404 if | |
| # trusted publishing is enabled on npmjs.com. Use trusted publishing instead | |
| # (remove NODE_AUTH_TOKEN from this step) once configured — see npm docs. | |
| - name: Publish to npm | |
| run: npm publish --access public --tag ${{ steps.dist_tag.outputs.tag }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |