Skip to content

Commit a6ccac9

Browse files
authored
ci: add changelog workflow for automated release notes (#2317)
* docs: add changelog generation command for self-hosted Console Custom Claude Code command that generates CHANGELOG.md entries by comparing git tags. Scoped to self-hosted Redpanda Console — excludes enterprise, ADP, AI Agents, AI Gateway, and cloud-only changes. * ci: add GitHub Actions workflow to auto-generate changelog on tag push Triggers on version tags (v*), runs Claude Code CLI to generate a changelog entry, then opens a PR to master.
1 parent fdb47c7 commit a6ccac9

2 files changed

Lines changed: 113 additions & 25 deletions

File tree

.claude/commands/changelog/update.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ Generate a succinct changelog by comparing a specified git tag with the previous
1414

1515
The version comparison logic:
1616
- For patch versions (x.y.z): compare with x.y.(z-1) or x.y.(highest patch)
17-
- Example: 2.8.9 compares with 2.8.7
17+
- Example: 2.8.9 compares with 2.8.7
1818
- For minor versions (x.y.0): compare with x.(y-1).(highest patch)
19-
- Example: 3.2.0 compares with 3.1.3
19+
- Example: 3.2.0 compares with 3.1.3
2020

2121
## Context
2222

2323
### User provided input for this command
2424

2525
The user provided the following additional input for this command (may be empty): $ARGUMENTS
2626

27-
**Usage**:
27+
**Usage**:
2828
- `changelog` - Generate changelog for the latest tag
2929
- `changelog v2.8.9` - Generate changelog for a specific tag (v2.8.9)
3030
- `changelog 2.8.9` - Generate changelog for a specific tag (accepts with or without 'v' prefix)
@@ -40,30 +40,31 @@ The user provided the following additional input for this command (may be empty)
4040

4141
### Changelog Generation Steps
4242

43-
1. **Determine Version Range**:
44-
- If $ARGUMENTS is provided, use that as the target tag (add 'v' prefix if missing)
45-
- If $ARGUMENTS is empty, get the latest tag from OSS repo
46-
- Calculate the previous version based on semantic versioning rules
47-
- Verify both tags exist
43+
1. **Determine Version Range**:
44+
- If $ARGUMENTS is provided, use that as the target tag (add 'v' prefix if missing)
45+
- If $ARGUMENTS is empty, get the latest tag from OSS repo
46+
- Calculate the previous version based on semantic versioning rules
47+
- Verify both tags exist
4848

4949
2. **Check if Changelog Entry Already Exists**:
50-
- Read CHANGELOG.md to see if the target version already has an entry
51-
- If entry exists and there are commits since the tag, update "Master / Unreleased" section instead
52-
- If no entry exists, proceed with creating a new version section
50+
- Read CHANGELOG.md to see if the target version already has an entry
51+
- If entry exists and there are commits since the tag, update "Master / Unreleased" section instead
52+
- If no entry exists, proceed with creating a new version section
5353

5454
3. **Collect Changes from OSS Repository**:
55-
- For existing entries: Get commits since the target tag: `git log --pretty=format:"%s" <target_tag>..HEAD`
56-
- For new entries: Get commits between versions: `git log --pretty=format:"%s" <prev_tag>..<target_tag>`
57-
- Filter and categorize commits into [BUGFIX], [IMPROVEMENT], [CHANGE], and [SECURITY]
58-
- Select up to 10 most significant changes
59-
-
55+
- For existing entries: Get commits since the target tag: `git log --pretty=format:"%s" <target_tag>..HEAD`
56+
- For new entries: Get commits between versions: `git log --pretty=format:"%s" <prev_tag>..<target_tag>`
57+
- Filter and categorize commits into [BUGFIX], [IMPROVEMENT], [CHANGE], and [SECURITY]
58+
- Select up to 10 most significant changes
59+
-
6060

6161
4. **Update CHANGELOG.md**:
62-
- **For existing entries**: Update "Master / Unreleased" section with new changes since the tag
63-
- **For new patch releases**: Create new version section with changes from previous version
64-
- **For new minor/major releases**: Create new version section using unreleased changes + new changes from previous version
65-
- Limit to 10 most significant changes total across both repositories
66-
- Format:
62+
- **For existing entries**: Update "Master / Unreleased" section with new changes since the tag
63+
- **For new patch releases**: Create new version section with changes from previous version
64+
- **For new minor/major releases**: Create new version section using unreleased changes + new changes from previous version
65+
- Limit to 10 most significant changes total across both repositories
66+
- Use the tag's commit date for the version heading (get it via `git log -1 --format=%ai <target_tag>` and extract the YYYY-MM-DD)
67+
- Format:
6768
```
6869
## [v<target_tag>] - YYYY-MM-DD
6970
@@ -78,7 +79,7 @@ The user provided the following additional input for this command (may be empty)
7879
**[IMPROVEMENT]** entries include:
7980
- New features (feat:, feature:)
8081
- Enhancements to existing functionality
81-
- Performance improvements (perf:)
82+
- Performance improvements (perf:)
8283
- UI/UX improvements
8384
- Documentation updates (docs:)
8485
- Refactoring that adds value (refactor:)
@@ -105,9 +106,9 @@ The user provided the following additional input for this command (may be empty)
105106
### Output Requirements
106107

107108
- Update the root `CHANGELOG.md` file appropriately based on the scenario:
108-
- **Existing version entry**: Update "Master / Unreleased" section with changes since the tag
109-
- **New patch version**: Create new version section with changes from previous version
110-
- **New minor/major version**: Incorporate existing unreleased changes into the new version section
109+
- **Existing version entry**: Update "Master / Unreleased" section with changes since the tag
110+
- **New patch version**: Create new version section with changes from previous version
111+
- **New minor/major version**: Incorporate existing unreleased changes into the new version section
111112
- Limit to 10 most significant changes total across both repositories
112113
- Display a summary of changes found
113114
- Deduplicate closely related commits — if multiple commits address the same user-facing change (e.g. a fix and a follow-up perf improvement for the same feature), merge them into a single entry

.github/workflows/changelog.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Changelog PR
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
changelog:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
ref: master
22+
23+
- name: Fetch all tags
24+
run: git fetch --tags --force
25+
26+
- name: Extract tag name
27+
id: tag
28+
run: echo "name=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
29+
30+
- name: Create changelog branch
31+
run: |
32+
git checkout -b "changelog/${{ steps.tag.outputs.name }}"
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: '22'
38+
39+
- name: Cache Claude Code
40+
id: cache-claude
41+
uses: actions/cache@v4
42+
with:
43+
path: ~/.npm
44+
key: claude-code-${{ runner.os }}
45+
46+
- name: Install Claude Code
47+
run: npm install -g @anthropic-ai/claude-code
48+
49+
- name: Run Claude Code
50+
env:
51+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
52+
run: |
53+
claude -p "/changelog:update ${{ steps.tag.outputs.name }}" \
54+
--allowedTools "Bash(git tag:*),Bash(git log:*),Bash(git status:*),Bash(git branch:*),Bash(head:*),Bash(pwd),Read,Edit"
55+
56+
- name: Check for changes, commit, and create PR
57+
env:
58+
GH_TOKEN: ${{ github.token }}
59+
run: |
60+
if git diff --quiet CHANGELOG.md; then
61+
echo "No changelog changes detected, skipping PR creation."
62+
exit 0
63+
fi
64+
65+
git config user.name "github-actions[bot]"
66+
git config user.email "github-actions[bot]@users.noreply.github.com"
67+
68+
git add CHANGELOG.md
69+
git commit -m "docs: update CHANGELOG.md for ${{ steps.tag.outputs.name }}"
70+
git push origin "changelog/${{ steps.tag.outputs.name }}"
71+
72+
gh pr create \
73+
--title "docs: update CHANGELOG.md for ${{ steps.tag.outputs.name }}" \
74+
--body "$(cat <<'EOF'
75+
## Summary
76+
77+
- Auto-generated changelog entry for release ${{ steps.tag.outputs.name }}
78+
- Created by the changelog CI workflow using Claude Code
79+
80+
## Test plan
81+
82+
- [ ] Review the CHANGELOG.md diff for accuracy
83+
- [ ] Verify commit classifications are correct
84+
EOF
85+
)" \
86+
--base master \
87+
--head "changelog/${{ steps.tag.outputs.name }}"

0 commit comments

Comments
 (0)