Skip to content

Release

Release #33

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
bump:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
dry-run:
description: 'Dry run (test without publishing)'
required: false
type: boolean
default: false
permissions:
contents: write
id-token: write
jobs:
release:
name: Bump, Tag & Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- run: npm ci
- run: npm test
- run: echo "node=$(node -v) npm=$(npm -v)"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Determine version
id: bump
run: |
OLD_VERSION=$(node -p "require('./package.json').version")
npm version ${{ inputs.bump }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "Bumped ${OLD_VERSION} → ${NEW_VERSION} (${{ inputs.bump }})"
echo "old_version=${OLD_VERSION}" >> $GITHUB_OUTPUT
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
- name: Update CHANGELOG
run: |
NEW_VERSION=${{ steps.bump.outputs.new_version }}
DATE=$(date +%Y-%m-%d)
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
COMMITS=$(git log "${LAST_TAG}..HEAD" --pretty=format:"- %s" --no-merges)
else
COMMITS=$(git log --pretty=format:"- %s" --no-merges)
fi
if [ -f CHANGELOG.md ]; then
{
head -1 CHANGELOG.md
echo ""
echo "## [${NEW_VERSION}] - ${DATE}"
echo ""
echo "${COMMITS}"
echo ""
tail -n +2 CHANGELOG.md
} > CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
fi
- name: Commit, tag & push
if: inputs.dry-run == false
run: |
NEW_VERSION=${{ steps.bump.outputs.new_version }}
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "chore(release): v${NEW_VERSION}"
fi
if git rev-parse "v${NEW_VERSION}" >/dev/null 2>&1; then
echo "Tag v${NEW_VERSION} already exists, skipping"
else
git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
fi
git push origin main --follow-tags
- name: Publish to npm
if: inputs.dry-run == false
run: npm publish --access public
- name: Publish to npm (dry run)
if: inputs.dry-run == true
run: npm publish --access public --dry-run
- name: Create GitHub Release
if: inputs.dry-run == false
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.bump.outputs.new_version }}
name: v${{ steps.bump.outputs.new_version }}
generate_release_notes: true