Skip to content

Commit 0dba2cf

Browse files
committed
Release bod 生成提交日志
1 parent 884557b commit 0dba2cf

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,34 @@ jobs:
4040
run: |
4141
Compress-Archive -Path * -DestinationPath ../ServicesApp-win-x64.zip
4242
43+
- name: 生成提交日志 (Generate Changelog)
44+
id: changelog
45+
run: |
46+
$tag = "${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }}"
47+
$prevTag = git describe --tags --abbrev=0 "$tag^" 2>$null
48+
if ($prevTag) {
49+
$commits = git log "$prevTag..$tag" --pretty=format:"- %s (%h)" --no-merges
50+
} else {
51+
$commits = git log --pretty=format:"- %s (%h)" --no-merges -10
52+
}
53+
$changelog = $commits -join "`n"
54+
if ([string]::IsNullOrWhiteSpace($changelog)) {
55+
$changelog = "- 初始版本发布"
56+
}
57+
$changelog | Out-File -FilePath changelog.txt -Encoding utf8
58+
echo "CHANGELOG<<EOF" >> $env:GITHUB_OUTPUT
59+
echo $changelog >> $env:GITHUB_OUTPUT
60+
echo "EOF" >> $env:GITHUB_OUTPUT
61+
4362
- name: 创建 GitHub Release
4463
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
4564
uses: softprops/action-gh-release@v1
4665
with:
4766
files: ServicesApp-win-x64.zip
48-
generate_release_notes: true
67+
body: |
68+
## 更新内容
69+
70+
${{ steps.changelog.outputs.CHANGELOG }}
4971
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }}
5072
name: Release ${{ github.event_name == 'workflow_dispatch' && inputs.tag_name || github.ref_name }}
5173
draft: false

0 commit comments

Comments
 (0)