Skip to content

Commit ded24b4

Browse files
committed
feat(release): generate changelog for release drafts
Add a step to generate a changelog based on commits since the last tag. This changelog will be included in the release draft body for better visibility of changes.
1 parent 8b1a038 commit ded24b4

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

.github/workflows/publish.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,34 @@ jobs:
114114
if: startsWith(github.ref, 'refs/tags/v')
115115

116116
steps:
117+
- name: Checkout code
118+
uses: actions/checkout@v4
119+
with:
120+
fetch-depth: 0
121+
122+
- name: Generate changelog
123+
id: changelog
124+
run: |
125+
# Get the previous tag
126+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
127+
128+
if [ -n "$PREV_TAG" ]; then
129+
echo "Getting changes since $PREV_TAG"
130+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREV_TAG..HEAD)
131+
else
132+
echo "Getting all commits"
133+
CHANGELOG=$(git log --pretty=format:"- %s (%h)")
134+
fi
135+
136+
# Output for use in release
137+
{
138+
echo 'body<<EOF'
139+
echo "## What's Changed"
140+
echo ""
141+
echo "$CHANGELOG"
142+
echo EOF
143+
} >> $GITHUB_OUTPUT
144+
117145
- name: Download JAR artifacts
118146
uses: actions/download-artifact@v4
119147
with:
@@ -133,8 +161,8 @@ jobs:
133161
uses: softprops/action-gh-release@v2
134162
with:
135163
draft: true
136-
generate_release_notes: true
137164
name: CFSolver v${{ needs.build.outputs.version }}
165+
body: ${{ steps.changelog.outputs.body }}
138166
files: |
139167
artifacts/cfsolver-*-all.jar
140168
artifacts/cfsolver.exe

0 commit comments

Comments
 (0)