Skip to content

Commit 97e5739

Browse files
committed
Fix first release tag comparison issue
1 parent eca565c commit 97e5739

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,28 @@ jobs:
104104
id: release_notes
105105
run: |
106106
# Get the previous tag for comparison
107-
$previousTag = git describe --tags --abbrev=0 HEAD~1 2>$null
108-
if (-not $previousTag) {
109-
$previousTag = "HEAD~10" # Fallback if no previous tag
107+
$previousTag = $null
108+
try {
109+
$previousTag = git describe --tags --abbrev=0 HEAD~1 2>$null
110+
if ($LASTEXITCODE -ne 0) { $previousTag = $null }
111+
} catch {
112+
$previousTag = $null
110113
}
111114
112-
# Get commits since last release
113-
$commits = git log --pretty=format:"- %s" $previousTag..HEAD
115+
# Get commits since last release or all commits if no previous tag
116+
if ($previousTag) {
117+
$commits = git log --pretty=format:"- %s" $previousTag..HEAD
118+
$changelogUrl = "https://github.com/${{ github.repository }}/compare/$previousTag...${{ steps.version.outputs.version }}"
119+
} else {
120+
# First release - get recent commits
121+
$commits = git log --pretty=format:"- %s" -10
122+
$changelogUrl = "https://github.com/${{ github.repository }}/commits/${{ steps.version.outputs.version }}"
123+
}
124+
125+
# Handle case where no commits are found
126+
if (-not $commits) {
127+
$commits = "- Initial release"
128+
}
114129
115130
# Generate release notes
116131
$releaseNotes = @"
@@ -142,7 +157,7 @@ jobs:
142157
---
143158
📦 **Download**: ``${{ env.PROJECT_NAME }}-${{ steps.version.outputs.version }}-win.zip``
144159
145-
📚 **Full Changelog**: https://github.com/${{ github.repository }}/compare/$previousTag...${{ steps.version.outputs.version }}
160+
📚 **Full Changelog**: $changelogUrl
146161
"@
147162
148163
# Save release notes as multiline output

0 commit comments

Comments
 (0)