Skip to content

Commit 2b8f5e2

Browse files
committed
Enhance GitHub Actions workflow to collect commits for release notes. Added a step to retrieve commits since the last release tag or all commits if no tag exists, and handle empty commit lists appropriately.
1 parent 8104e34 commit 2b8f5e2

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

.github/workflows/build-and-release.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,54 @@ jobs:
7878
Write-Host "Building release for version: ${{ steps.get_version.outputs.version }}"
7979
Write-Host "Version is controlled by the VERSION file in the repository"
8080
81+
- name: Collect commits for release notes
82+
id: collect_commits
83+
run: |
84+
# Try to find the last release tag
85+
$lastTag = $null
86+
try {
87+
$lastTag = git describe --tags --abbrev=0 --match "v*" 2>$null
88+
if ($LASTEXITCODE -ne 0) {
89+
$lastTag = $null
90+
}
91+
} catch {
92+
$lastTag = $null
93+
}
94+
95+
# Get commits since last tag (or all commits if no tag exists)
96+
$commits = ""
97+
if ($lastTag) {
98+
Write-Host "Collecting commits since tag: $lastTag"
99+
$commits = git log --pretty=format:"- %s" --no-merges "$lastTag..HEAD" 2>$null
100+
} else {
101+
Write-Host "No previous tag found, collecting all commits"
102+
$commits = git log --pretty=format:"- %s" --no-merges
103+
}
104+
105+
# Handle empty commit list
106+
if ([string]::IsNullOrWhiteSpace($commits)) {
107+
$commits = "- No changes (only merge commits)"
108+
Write-Host "Warning: No non-merge commits found"
109+
} else {
110+
Write-Host "Found commits for release notes"
111+
}
112+
113+
# Store in GitHub output (escape newlines and special characters)
114+
$commitsEscaped = $commits -replace "`r?`n", "`n" -replace '"', '`"'
115+
echo "commits<<EOF" >> $env:GITHUB_OUTPUT
116+
echo "$commitsEscaped" >> $env:GITHUB_OUTPUT
117+
echo "EOF" >> $env:GITHUB_OUTPUT
118+
81119
- name: Create Release
82120
run: |
83121
$version = "${{ steps.get_version.outputs.version }}"
84122
$exeName = "${{ steps.build_executable.outputs.exe_name }}"
85123
$exePath = "${{ steps.build_executable.outputs.exe_path }}"
124+
$commits = "${{ steps.collect_commits.outputs.commits }}"
86125
$notes = @"
87126
## Changes in v$version
88127
89-
This release includes the latest changes from the main branch.
128+
$commits
90129
91130
### Download
92131
Download the ``$exeName`` file below and run it to use the latest version.

0 commit comments

Comments
 (0)