Skip to content

Commit 233e6cd

Browse files
Generate commit-based changelog for release notes
GitHub's generate_release_notes is PR-based and produces only a compare link for direct-commit repos. Build the release body from the commit log since the previous tag (fetch-depth: 0 to get full history), and let the GitHub-generated section append after it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b6a606f commit 233e6cd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
runs-on: windows-latest
2727
steps:
2828
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0 # 需要完整歷史與 tag 才能產生 changelog
2931

3032
- uses: actions/setup-python@v5
3133
with:
@@ -43,12 +45,31 @@ jobs:
4345
name: KKCardsClassifier-exe
4446
path: dist/KKCardsClassifier.exe
4547

48+
- name: Generate changelog from commits
49+
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.tag != ''
50+
id: changelog
51+
shell: bash
52+
run: |
53+
TARGET="${{ github.event.inputs.tag || github.ref_name }}"
54+
PREV=$(git tag --sort=-creatordate | grep -vx "$TARGET" | head -1)
55+
{
56+
if [ -n "$PREV" ]; then
57+
echo "## What's Changed (since $PREV)"; echo
58+
git log --no-merges --pretty='- %s' "$PREV..HEAD"
59+
else
60+
echo "## What's Changed"; echo
61+
git log --no-merges --pretty='- %s'
62+
fi
63+
} > "$RUNNER_TEMP/notes.md"
64+
echo "path=$RUNNER_TEMP/notes.md" >> "$GITHUB_OUTPUT"
65+
4666
- name: Publish release
4767
if: startsWith(github.ref, 'refs/tags/') || github.event.inputs.tag != ''
4868
uses: softprops/action-gh-release@v2
4969
with:
5070
tag_name: ${{ github.event.inputs.tag || github.ref_name }}
5171
name: KKCardsClassifier ${{ github.event.inputs.tag || github.ref_name }}
72+
body_path: ${{ steps.changelog.outputs.path }}
5273
generate_release_notes: true
5374
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
5475
files: dist/KKCardsClassifier.exe

0 commit comments

Comments
 (0)