1818 required : false
1919 default : false
2020 type : boolean
21+ update_changelog :
22+ description : " Update CHANGELOG.md with release notes"
23+ required : false
24+ default : true
25+ type : boolean
2126
2227jobs :
2328 publish :
7378 npm version ${{ github.event.inputs.version }} --no-git-tag-version
7479 echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
7580
81+ - name : Get previous release tag
82+ id : prev-tag
83+ run : |
84+ PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
85+ echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT
86+ echo "Previous tag: $PREV_TAG"
87+
88+ - name : Generate Changelog
89+ if : github.event.inputs.update_changelog == 'true' && github.event.inputs.dry_run == 'false' && steps.prev-tag.outputs.tag != ''
90+ uses : anthropics/claude-code-action@v1
91+ with :
92+ anthropic_api_key : ${{ secrets.ANTHROPIC_API_KEY }}
93+ prompt : |
94+ Generate a changelog entry for version ${{ env.NEW_VERSION }} (release date: today).
95+ Previous version tag: ${{ steps.prev-tag.outputs.tag }}
96+
97+ ## Instructions
98+
99+ 1. Get commits since last release:
100+ `git log ${{ steps.prev-tag.outputs.tag }}..HEAD --pretty=format:"%s (%h)" --no-merges`
101+
102+ 2. Get merged PRs (for better context):
103+ `gh pr list --state merged --json number,title,body,mergedAt --limit 100`
104+
105+ 3. Analyze and categorize changes using these categories (only include sections that have changes):
106+ - **Added** - new features
107+ - **Changed** - changes in existing functionality
108+ - **Deprecated** - soon-to-be removed features
109+ - **Removed** - now removed features
110+ - **Fixed** - bug fixes
111+ - **Security** - vulnerability fixes
112+
113+ 4. Update CHANGELOG.md by inserting the new version entry AFTER the `## [Unreleased]` line.
114+
115+ ## Important Rules
116+
117+ - **EXCLUDE** any commits/PRs related to:
118+ - Changelog updates (commits mentioning "changelog", "CHANGELOG")
119+ - Version bumps (commits like "chore: bump version to X.X.X")
120+ - Release commits (commits like "chore: release vX.X.X")
121+ - Be concise but descriptive - focus on user-facing changes
122+ - Include PR numbers in parentheses when available, e.g., "Added foo feature (#123)"
123+ - Follow keepachangelog.com format exactly
124+ - Use ISO date format: YYYY-MM-DD
125+
126+ ## Example Output Format
127+
128+ ```markdown
129+ ## [0.0.8] - 2026-01-19
130+
131+ ### Added
132+ - Non-interactive mode for `create` command (#67)
133+
134+ ### Changed
135+ - Improved intro/outro alignment across all commands (#61)
136+
137+ ### Fixed
138+ - Various small fixes and improvements (#60)
139+ ```
140+
141+ claude_args : ' --allowed-tools "Bash(git log:*),Bash(git diff:*),Bash(gh pr:*),Read,Write"'
142+
76143 - name : Build package
77144 run : npm run build
78145
@@ -99,7 +166,11 @@ jobs:
99166 git config --local user.email "action@github.com"
100167 git config --local user.name "GitHub Action"
101168 git add package.json package-lock.json
102- git commit -m "chore: bump version to ${{ env.NEW_VERSION }}"
169+ # Add CHANGELOG.md only if changelog update was requested
170+ if [[ "${{ github.event.inputs.update_changelog }}" == "true" ]]; then
171+ git add CHANGELOG.md
172+ fi
173+ git commit -m "chore: release v${{ env.NEW_VERSION }}"
103174 git tag v${{ env.NEW_VERSION }}
104175 git push origin HEAD:${{ github.ref }}
105176 git push origin v${{ env.NEW_VERSION }}
@@ -131,4 +202,5 @@ jobs:
131202permissions :
132203 contents : write
133204 packages : write
205+ pull-requests : read
134206 id-token : write
0 commit comments