44 workflow_dispatch :
55 inputs :
66 bump :
7- description : ' Version bump type'
7+ description : ' Version bump type (use "current" to publish as-is) '
88 required : true
99 type : choice
1010 options :
11+ - current
1112 - patch
1213 - minor
1314 - major
2425 - uses : actions/checkout@v4
2526 with :
2627 fetch-depth : 0
27- token : ${{ secrets.GITHUB_TOKEN }}
28+ token : ${{ secrets.RELEASE_PAT }}
2829
2930 - uses : actions/setup-node@v4
3031 with :
@@ -40,32 +41,34 @@ jobs:
4041 git config user.name "github-actions[bot]"
4142 git config user.email "github-actions[bot]@users.noreply.github.com"
4243
43- - name : Bump version
44+ - name : Determine version
4445 id : bump
4546 run : |
4647 OLD_VERSION=$(node -p "require('./package.json').version")
47- npm version ${{ inputs.bump }} --no-git-tag-version
48- NEW_VERSION=$(node -p "require('./package.json').version")
48+ if [ "${{ inputs.bump }}" = "current" ]; then
49+ NEW_VERSION="${OLD_VERSION}"
50+ echo "Publishing current version ${NEW_VERSION}"
51+ else
52+ npm version ${{ inputs.bump }} --no-git-tag-version
53+ NEW_VERSION=$(node -p "require('./package.json').version")
54+ echo "Bumped ${OLD_VERSION} → ${NEW_VERSION} (${{ inputs.bump }})"
55+ fi
4956 echo "old_version=${OLD_VERSION}" >> $GITHUB_OUTPUT
5057 echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
51- echo "Bumped ${OLD_VERSION} → ${NEW_VERSION} (${{ inputs.bump }})"
58+ echo "is_bump=${{ inputs.bump != 'current' }}" >> $GITHUB_OUTPUT
5259
5360 - name : Update CHANGELOG
61+ if : inputs.bump != 'current'
5462 run : |
5563 NEW_VERSION=${{ steps.bump.outputs.new_version }}
5664 DATE=$(date +%Y-%m-%d)
57- # Get commits since last tag
5865 LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
5966 if [ -n "$LAST_TAG" ]; then
6067 COMMITS=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s" --no-merges)
6168 else
6269 COMMITS=$(git log --pretty=format:"- %s" --no-merges)
6370 fi
64-
65- # Build new changelog entry
6671 ENTRY="## [${NEW_VERSION}] - ${DATE}\n\n${COMMITS}\n"
67-
68- # Insert after the first line (# Changelog header)
6972 if [ -f CHANGELOG.md ]; then
7073 sed -i "0,/^## /s//$(printf '%s\n\n' "${ENTRY}")## /" CHANGELOG.md 2>/dev/null || \
7174 awk -v entry="$ENTRY" 'NR==1{print; print ""; print entry; next}1' CHANGELOG.md > CHANGELOG.tmp && mv CHANGELOG.tmp CHANGELOG.md
7477 - name : Commit, tag & push
7578 run : |
7679 NEW_VERSION=${{ steps.bump.outputs.new_version }}
77- git add package.json package-lock.json CHANGELOG.md
78- git commit -m "chore(release): v${NEW_VERSION}"
80+ git add -A
81+ if git diff --cached --quiet; then
82+ echo "No changes to commit"
83+ else
84+ git commit -m "chore(release): v${NEW_VERSION}"
85+ fi
7986 git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
8087 git push origin main --follow-tags
8188
0 commit comments