Skip to content

Release

Release #126

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: read
jobs:
release:
name: Bump, Tag & Publish
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- run: npm ci
- name: Build frontend
run: cd src/frontend && npm ci && npm run build
- 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
id: changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NEW_VERSION=${{ steps.bump.outputs.new_version }}
DATE=$(date +%Y-%m-%d)
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
REPO="${{ github.repository }}"
if [ -n "$LAST_TAG" ]; then
COMMITS=$(gh api "/repos/${REPO}/compare/${LAST_TAG}...HEAD" \
--jq '.commits[]
| select(.parents | length == 1)
| "- \(.commit.message | split("\n")[0]) (\(if .author.login then "@\(.author.login)" else .commit.author.name end))"' \
|| true)
else
COMMITS=$(git log --pretty=format:"- %s (%aN)" --no-merges)
fi
: "${COMMITS:=- Maintenance and improvements}"
SECTION="## [${NEW_VERSION}] - ${DATE}
${COMMITS}"
{
echo "section<<CHANGELOG_EOF"
echo "$SECTION"
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
if [ -f CHANGELOG.md ]; then
{
head -1 CHANGELOG.md
echo ""
echo "$SECTION"
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} [skip ci]"
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@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v2
with:
tag_name: v${{ steps.bump.outputs.new_version }}
name: v${{ steps.bump.outputs.new_version }}
body: ${{ steps.changelog.outputs.section }}
generate_release_notes: true