Skip to content

Commit 7850fc6

Browse files
authored
Merge pull request #215 from cloudflare/fix/github-workflow-fixes
feat: enhance changelog generation with detailed PR and commit data
2 parents 3a725c0 + 01afb74 commit 7850fc6

1 file changed

Lines changed: 99 additions & 58 deletions

File tree

.github/workflows/release-with-ai-changelog.yml

Lines changed: 99 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -45,82 +45,123 @@ jobs:
4545
echo "current_tag=$CURRENT_TAG" >> $GITHUB_OUTPUT
4646
echo "previous_tag=$PREV_TAG" >> $GITHUB_OUTPUT
4747
48-
- name: Generate changelog with Claude
48+
- name: Generate enhanced changelog with Claude Code Action
4949
uses: anthropics/claude-code-action@v1
5050
with:
5151
github_token: ${{ secrets.GITHUB_TOKEN }}
5252
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
5353
prompt: |
54-
Generate a professional changelog for this release.
54+
Generate an enhanced changelog for release ${{ needs.release-please.outputs.tag_name }}.
5555
56-
Compare tags:
57-
- From: ${{ steps.prev_tag.outputs.previous_tag }}
58-
- To: ${{ steps.prev_tag.outputs.current_tag }}
56+
**Step 1: Collect data**
5957
60-
Get commits and changes:
58+
Get release-please's generated changelog:
6159
```bash
62-
git log "${{ steps.prev_tag.outputs.previous_tag }}...${{ steps.prev_tag.outputs.current_tag }}" --pretty=format:"%s" | head -100 > /tmp/commits.txt
63-
git diff "${{ steps.prev_tag.outputs.previous_tag }}...${{ steps.prev_tag.outputs.current_tag }}" --shortstat > /tmp/stats.txt
64-
cat /tmp/commits.txt /tmp/stats.txt
60+
gh release view "${{ needs.release-please.outputs.tag_name }}" --json body -q .body > /tmp/release-please-changelog.txt
61+
cat /tmp/release-please-changelog.txt
6562
```
6663
67-
Generate changelog:
68-
1. Categorize: Added, Changed, Fixed, Security, Performance, Documentation
69-
2. Write clear, user-focused descriptions
70-
3. Explain impact and breaking changes
71-
4. Use concise bullet points
72-
5. Professional tone, no emojis
73-
6. Focus on what matters to users
64+
Get all commits with full messages (not just titles):
65+
```bash
66+
PREV_TAG="${{ steps.prev_tag.outputs.previous_tag }}"
67+
if [ -n "$PREV_TAG" ]; then
68+
git log "$PREV_TAG...${{ needs.release-please.outputs.tag_name }}" --pretty=format:"### Commit: %s%n%b%n---" | head -c 50000 > /tmp/commits.txt
69+
else
70+
git log "${{ needs.release-please.outputs.tag_name }}" --pretty=format:"### Commit: %s%n%b%n---" | head -c 50000 > /tmp/commits.txt
71+
fi
72+
cat /tmp/commits.txt
73+
```
74+
75+
Get merged PRs with descriptions:
76+
```bash
77+
PREV_TAG="${{ steps.prev_tag.outputs.previous_tag }}"
78+
if [ -n "$PREV_TAG" ]; then
79+
PREV_DATE=$(git log -1 --format=%aI "$PREV_TAG" 2>/dev/null || echo "2024-01-01T00:00:00Z")
80+
else
81+
PREV_DATE="2024-01-01T00:00:00Z"
82+
fi
83+
84+
gh pr list \
85+
--repo ${{ github.repository }} \
86+
--state merged \
87+
--json number,title,body,mergedAt \
88+
--limit 50 \
89+
--search "merged:>=$PREV_DATE" \
90+
--jq '.[] | "## PR #\(.number): \(.title)\n\(.body)\n---\n"' > /tmp/prs.txt 2>/dev/null || echo "No PRs found" > /tmp/prs.txt
91+
cat /tmp/prs.txt
92+
```
93+
94+
Get diff statistics:
95+
```bash
96+
PREV_TAG="${{ steps.prev_tag.outputs.previous_tag }}"
97+
if [ -n "$PREV_TAG" ]; then
98+
git diff "$PREV_TAG...${{ needs.release-please.outputs.tag_name }}" --shortstat > /tmp/stats.txt
99+
else
100+
git log --shortstat --oneline | head -1 > /tmp/stats.txt
101+
fi
102+
cat /tmp/stats.txt
103+
```
104+
105+
**Step 2: Generate enhanced changelog**
106+
107+
Using the data above (release-please changelog, commit messages, PR descriptions, stats):
108+
109+
1. Use release-please's changelog as the base structure
110+
2. Enhance with details from commit bodies and PR descriptions
111+
3. Categorize clearly: Features, Bug Fixes, Performance, Documentation, Breaking Changes
112+
4. Write user-focused descriptions (not just commit titles)
113+
5. If a PR/commit has detailed description, use it to provide context
114+
6. Be concise but informative
115+
7. Professional tone, no emojis in the changelog itself
116+
8. Highlight important changes and impacts
117+
118+
**Format:**
119+
```markdown
120+
## What's Changed
121+
122+
### ✨ Features
123+
- **[Feature Title]**: Description with context from PR/commit body
124+
125+
### 🐛 Bug Fixes
126+
- **[Fix Title]**: What was broken and how it's fixed
127+
128+
### ⚡ Performance
129+
- **[Improvement Title]**: Impact description
130+
131+
### 📚 Documentation
132+
- List updates
74133
75-
Save result to file:
134+
### 💥 Breaking Changes
135+
- **[Change Title]**: Migration steps if any
136+
137+
### 📊 Statistics
138+
- Files changed, insertions, deletions from git diff stats
139+
```
140+
141+
**Step 3: Save the enhanced changelog**
76142
```bash
77-
cat << 'CHANGELOG' > /tmp/changelog.md
78-
[YOUR_GENERATED_CHANGELOG_HERE]
79-
CHANGELOG
143+
cat > /tmp/enhanced-changelog.md << 'CHANGELOG_EOF'
144+
[PASTE YOUR GENERATED CHANGELOG HERE]
145+
CHANGELOG_EOF
146+
```
147+
148+
**Step 4: Update the release**
149+
```bash
150+
gh release edit "${{ needs.release-please.outputs.tag_name }}" --notes-file /tmp/enhanced-changelog.md
151+
echo "✅ Release notes updated successfully"
80152
```
81153
82154
claude_args: |
83-
--allowed-tools "Bash(git:*),Bash(cat:*),Bash(echo:*)"
84-
--max-turns 10
155+
--allowed-tools "Bash(gh release view:*),Bash(gh release edit:*),Bash(gh pr list:*),Bash(git log:*),Bash(git diff:*),Bash(cat:*),Bash(echo:*),Bash(head:*)"
156+
--max-turns 20
85157
--model claude-haiku-4-5-20251001
86158
87-
- name: Check if changelog was generated
88-
id: check_changelog
89-
run: |
90-
if [ -f /tmp/changelog.md ]; then
91-
echo "exists=true" >> $GITHUB_OUTPUT
92-
else
93-
echo "exists=false" >> $GITHUB_OUTPUT
94-
fi
95-
96-
- name: Enhance release notes
97-
if: steps.check_changelog.outputs.exists == 'true'
159+
- name: Verify changelog updated
160+
if: always()
98161
env:
99162
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100163
run: |
101164
TAG_NAME="${{ needs.release-please.outputs.tag_name }}"
102-
CURRENT_BODY=$(gh release view "$TAG_NAME" --json body -q .body)
103-
104-
# Create new release notes file
105-
cat > /tmp/release-notes.md << 'EOF'
106-
## Summary
107-
108-
EOF
109-
110-
# Append AI-generated changelog
111-
cat /tmp/changelog.md >> /tmp/release-notes.md
112-
113-
# Add separator and original notes
114-
cat >> /tmp/release-notes.md << 'EOF'
115-
116-
---
117-
118-
## Detailed Changes
119-
120-
EOF
121-
122-
# Append current body without variable expansion
123-
echo "$CURRENT_BODY" >> /tmp/release-notes.md
124-
125-
# Update release
126-
gh release edit "$TAG_NAME" --notes-file /tmp/release-notes.md
165+
echo "Verifying release notes for $TAG_NAME..."
166+
gh release view "$TAG_NAME" --json body -q .body | head -20
167+
echo "✅ Changelog verification complete"

0 commit comments

Comments
 (0)