Skip to content

Commit a766d28

Browse files
committed
generate CHANGELOG in release workflow
1 parent bc9f762 commit a766d28

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,49 @@ jobs:
1414
steps:
1515
- name: Checkout code
1616
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Fetch all history for changelog generation
1719

1820
- name: Extract version from tag
1921
id: get_version
2022
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
2123

24+
- name: Generate CHANGELOG
25+
run: |
26+
echo "# Changelog" > CHANGELOG.md
27+
echo "" >> CHANGELOG.md
28+
echo "All notable changes to this project will be documented in this file." >> CHANGELOG.md
29+
echo "" >> CHANGELOG.md
30+
31+
# Get all tags sorted by version
32+
TAGS=$(git tag -l 'v*' --sort=-v:refname)
33+
34+
PREV_TAG=""
35+
for TAG in $TAGS; do
36+
echo "## [$TAG] - $(git log -1 --format=%ai $TAG | cut -d' ' -f1)" >> CHANGELOG.md
37+
echo "" >> CHANGELOG.md
38+
39+
if [ -z "$PREV_TAG" ]; then
40+
# First tag - show all commits up to this tag
41+
git log $TAG --pretty=format:"- %s (%h)" --no-merges >> CHANGELOG.md
42+
else
43+
# Show commits between previous tag and current tag
44+
git log $PREV_TAG..$TAG --pretty=format:"- %s (%h)" --no-merges >> CHANGELOG.md
45+
fi
46+
47+
echo "" >> CHANGELOG.md
48+
echo "" >> CHANGELOG.md
49+
PREV_TAG=$TAG
50+
done
51+
52+
- name: Commit CHANGELOG
53+
run: |
54+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
55+
git config --local user.name "github-actions[bot]"
56+
git add CHANGELOG.md
57+
git diff --staged --quiet || git commit -m "Update CHANGELOG for ${{ github.ref_name }}"
58+
git push origin HEAD:main
59+
2260
- name: Create header archive
2361
run: |
2462
cd include

0 commit comments

Comments
 (0)