@@ -2,6 +2,16 @@ name: Release
22
33on :
44 workflow_dispatch :
5+ inputs :
6+ bump :
7+ description : " Version bump level"
8+ required : false
9+ default : " patch"
10+ type : choice
11+ options :
12+ - patch
13+ - minor
14+ - major
515
616permissions :
717 contents : write
@@ -18,26 +28,42 @@ jobs:
1828 node-version : 24
1929 registry-url : https://registry.npmjs.org
2030
31+ - name : Bump version
32+ id : version
33+ run : |
34+ BUMP="${{ inputs.bump || 'patch' }}"
35+ OLD=$(node -p 'require("./package.json").version')
36+ IFS='.' read -r MAJOR MINOR PATCH <<< "$OLD"
37+ case "$BUMP" in
38+ major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
39+ minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
40+ patch) PATCH=$((PATCH + 1)) ;;
41+ esac
42+ NEW="${MAJOR}.${MINOR}.${PATCH}"
43+ npm version "$NEW" --no-git-tag-version
44+ echo "version=$NEW" >> "$GITHUB_OUTPUT"
45+ echo "old=$OLD" >> "$GITHUB_OUTPUT"
46+ echo "Bumped $OLD → $NEW ($BUMP)"
47+
2148 - run : npm ci
2249 - run : npm run typecheck
2350 - run : npm test
2451 - run : npm run build
2552
26- - name : Read version
27- id : version
28- run : echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
29-
3053 # Clear the token placeholder so npm falls through to OIDC auth.
3154 - name : Publish to npm
3255 run : |
3356 npm config delete //registry.npmjs.org/:_authToken || true
3457 npm publish --access public
3558
36- - name : Create git tag
59+ - name : Commit version bump and tag
3760 run : |
3861 git config user.name "github-actions[bot]"
3962 git config user.email "github-actions[bot]@users.noreply.github.com"
63+ git add package.json package-lock.json
64+ git commit -m "release: v${{ steps.version.outputs.version }}"
4065 git tag "v${{ steps.version.outputs.version }}"
66+ git push origin HEAD:main
4167 git push origin "v${{ steps.version.outputs.version }}"
4268
4369 - name : Create GitHub Release
0 commit comments