Skip to content

Commit 72a66e3

Browse files
committed
fix workflow to properly generate changelog
1 parent d5124ce commit 72a66e3

1 file changed

Lines changed: 46 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,28 +166,61 @@ jobs:
166166
Write-Host "Not a release commit"
167167
}
168168
169+
- name: Get last tag for changelog
170+
id: last_tag
171+
if: steps.check_release.outputs.IS_RELEASE == 'true'
172+
shell: pwsh
173+
run: |
174+
$lastTag = git describe --tags --abbrev=0 2>$null
175+
if ($lastTag) {
176+
echo "LAST_TAG=$lastTag" >> $env:GITHUB_OUTPUT
177+
Write-Host "Last tag: $lastTag"
178+
} else {
179+
echo "LAST_TAG=" >> $env:GITHUB_OUTPUT
180+
Write-Host "No previous tags found"
181+
}
182+
169183
- name: Generate Changelog
170184
id: changelog
171185
if: steps.check_release.outputs.IS_RELEASE == 'true'
172186
shell: pwsh
173187
run: |
174-
$msg = "${{ github.event.head_commit.message }}"
175-
$parts = $msg -split " - "
188+
Write-Host "Generating changelog..."
189+
190+
# Get commits since last tag (excluding release and chore commits)
191+
$lastTag = "${{ steps.last_tag.outputs.LAST_TAG }}"
192+
193+
if ($lastTag) {
194+
$commits = git log --pretty=format:"%s" "$lastTag..HEAD"
195+
} else {
196+
$commits = git log --pretty=format:"%s" HEAD
197+
}
198+
199+
# Filter and format commits
176200
$changelog = ""
177-
foreach ($part in $parts) {
178-
if ($part -match "^release:") { continue }
179-
$part = $part.Trim()
180-
if ($part) {
181-
$changelog += "- $part`n"
201+
foreach ($commit in $commits -split "`n") {
202+
# Skip release commits, chore commits, and empty lines
203+
if ($commit -match "^release:" -or $commit -match "^chore:" -or [string]::IsNullOrWhiteSpace($commit)) {
204+
continue
182205
}
206+
$changelog += "- $commit`n"
183207
}
184-
if (-not $changelog) {
185-
$changelog = "- Bug fixes and improvements"
208+
209+
# Fallback if no commits found
210+
if ([string]::IsNullOrWhiteSpace($changelog)) {
211+
$changelog = "- Bug fixes and improvements`n"
186212
}
187213
188-
# Escape for GitHub Actions output
189-
$changelog = $changelog -replace '%', '%25' -replace '\n', '%0A' -replace '\r', '%0D'
190-
echo "LOGS=$changelog" >> $env:GITHUB_OUTPUT
214+
Write-Host "Generated changelog:"
215+
Write-Host $changelog
216+
217+
# Save to file instead of using escaped output
218+
$changelog | Out-File -FilePath changelog.txt -Encoding utf8 -NoNewline
219+
220+
# Also set as output using multiline string syntax
221+
"LOGS<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
222+
$changelog | Out-File -FilePath $env:GITHUB_OUTPUT -Append
223+
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
191224
192225
- name: Create Release
193226
if: steps.check_release.outputs.IS_RELEASE == 'true'
@@ -203,13 +236,11 @@ jobs:
203236
1. Download `SteamLuaPatcher.exe` below
204237
2. Double-click to run - **no installation required!**
205238
206-
> 📦 **This is a standalone executable** - no DLLs, no folders, just one file!
207-
208239
## Requirements
209240
- Windows 10/11 (64-bit)
210241
files: |
211242
dist/SteamLuaPatcher.exe
212243
draft: false
213244
prerelease: false
214245
env:
215-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
246+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)