Implement Claude-powered CHANGELOG.md maintenance

### 🚀 Features
- Added Claude action to automatically maintain CHANGELOG.md file
- Claude analyzes git commits and generates categorized changelog entries
- Automatic changelog extraction for use in release commits and PRs

### 🔧 Improvements
- Uses anthropics/claude-code-action@v1 for direct file editing
- Creates or updates CHANGELOG.md with structured release entries
- Maintains persistent changelog history across releases
- Supports fallback if CHANGELOG.md is not generated

### 📚 Documentation
- CHANGELOG.md will be automatically maintained with each release
- Organized entries by features, bug fixes, improvements, docs, and performance
- Uses [Unreleased] format for upcoming releases

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-13 14:21:54 +02:00
parent af35603abd
commit f72da26cb9

View File

@@ -97,88 +97,84 @@ jobs:
echo "source-version=$SOURCE_VERSION" >> $GITHUB_OUTPUT echo "source-version=$SOURCE_VERSION" >> $GITHUB_OUTPUT
echo "target-version=$TARGET_VERSION" >> $GITHUB_OUTPUT echo "target-version=$TARGET_VERSION" >> $GITHUB_OUTPUT
- name: Generate changelog from commits - name: Get commit information for Claude
id: changelog id: commits
run: | run: |
# Get commits since last tag # Get commits since last tag
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then if [ -z "$LAST_TAG" ]; then
COMMITS=$(git log --oneline --no-merges --since="1 week ago" || echo "No recent commits") COMMITS=$(git log --oneline --no-merges --since="1 week ago" || echo "No recent commits")
echo "📝 Generating changelog from commits since 1 week ago (no previous tags found)" echo "📝 Getting commits since 1 week ago (no previous tags found)"
else else
COMMITS=$(git log --oneline --no-merges ${LAST_TAG}..HEAD || echo "No new commits") COMMITS=$(git log --oneline --no-merges ${LAST_TAG}..HEAD || echo "No new commits")
echo "📝 Generating changelog from commits since tag: $LAST_TAG" echo "📝 Getting commits since tag: $LAST_TAG"
fi fi
echo "Commits to process:" echo "Commits found:"
echo "$COMMITS" echo "$COMMITS"
# Categorize commits based on conventional commit patterns and keywords - name: Generate changelog with Claude
FEATURES="" uses: anthropics/claude-code-action@v1
BUGFIXES="" with:
IMPROVEMENTS="" prompt: |
DOCS="" Please analyze the recent git commits and update the CHANGELOG.md file with a new release entry.
while IFS= read -r commit; do Add a new section at the top of CHANGELOG.md with today's date in this format:
if [[ -z "$commit" ]]; then continue; fi
# Extract commit message (remove hash) ## [Unreleased] - $(date +%Y-%m-%d)
MSG=$(echo "$commit" | sed 's/^[a-f0-9]* //')
# Categorize based on patterns Organize the commits into these categories based on their content and conventional commit patterns:
if echo "$MSG" | grep -qiE "^(feat|feature|add|new):|🚀|✨"; then
FEATURES="${FEATURES}- $MSG"$'\n'
elif echo "$MSG" | grep -qiE "^(fix|bug):|🐛|❌|🔧.*fix"; then
BUGFIXES="${BUGFIXES}- $MSG"$'\n'
elif echo "$MSG" | grep -qiE "^(docs|doc):|📚|📝"; then
DOCS="${DOCS}- $MSG"$'\n'
else
IMPROVEMENTS="${IMPROVEMENTS}- $MSG"$'\n'
fi
done <<< "$COMMITS"
# Build changelog
CHANGELOG="## Changes"
if [[ -n "$FEATURES" ]]; then
CHANGELOG="$CHANGELOG
### 🚀 Features ### 🚀 Features
$FEATURES" - List any new features, major additions, or enhancements
fi
if [[ -n "$BUGFIXES" ]]; then
CHANGELOG="$CHANGELOG
### 🐛 Bug Fixes ### 🐛 Bug Fixes
$BUGFIXES" - List any bug fixes, error corrections, or issue resolutions
fi
if [[ -n "$IMPROVEMENTS" ]]; then
CHANGELOG="$CHANGELOG
### 🔧 Improvements ### 🔧 Improvements
$IMPROVEMENTS" - List any refactoring, code improvements, or optimizations
fi
if [[ -n "$DOCS" ]]; then
CHANGELOG="$CHANGELOG
### 📚 Documentation ### 📚 Documentation
$DOCS" - List any documentation updates, README changes, or comment improvements
### ⚡ Performance
- List any performance improvements or optimizations
Only include sections that have actual changes. Keep descriptions concise and user-focused.
The recent commits to analyze are visible in the git history. Please examine them and create a comprehensive changelog entry.
If CHANGELOG.md doesn't exist, create it with a proper header and the new release section.
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
- name: Read generated changelog
id: changelog
run: |
if [ -f CHANGELOG.md ]; then
# Extract the latest changelog entry (from top until next ## or end of file)
CHANGELOG=$(sed -n '/^## \[Unreleased\]/,/^## /p' CHANGELOG.md | sed '$d' | head -n -1)
# If that doesn't work, try a different approach
if [ -z "$CHANGELOG" ]; then
# Get first section after any header
CHANGELOG=$(sed -n '/^## /,/^## /p' CHANGELOG.md | head -n -1)
fi fi
# If no commits found, create a simple message # Final fallback - just get the first meaningful section
if [[ -z "$FEATURES$BUGFIXES$IMPROVEMENTS$DOCS" ]]; then if [ -z "$CHANGELOG" ]; then
CHANGELOG=$(head -20 CHANGELOG.md | grep -A 20 "^## ")
fi
echo "📖 Extracted changelog from CHANGELOG.md:"
echo "$CHANGELOG"
else
echo "⚠️ CHANGELOG.md not found, creating fallback"
CHANGELOG="## Changes CHANGELOG="## Changes
### 🔧 Improvements ### 🔧 Improvements
- Version update and maintenance changes" - Version update and maintenance changes"
fi fi
echo "Generated changelog:"
echo "$CHANGELOG"
# Save changelog to output # Save changelog to output
echo "changelog<<EOF" >> $GITHUB_OUTPUT echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT echo "$CHANGELOG" >> $GITHUB_OUTPUT