Skip to content

Commit 5e96c35

Browse files
Enhance GitHub release notes handling by using temporary files to avoid escaping issues
1 parent 9709709 commit 5e96c35

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

scripts/helpers/Publish-PSModule.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@
365365
Set-GitHubLogGroup 'New-GitHubRelease' {
366366
Write-Output 'Create new GitHub release'
367367
$releaseCreateCommand = @('release', 'create', $newVersion.ToString())
368+
$notesFilePath = $null
368369

369370
# Add title parameter
370371
if ($usePRTitleAsReleaseName -and $pull_request.title) {
@@ -375,17 +376,21 @@
375376
$releaseCreateCommand += @('--title', $newVersion.ToString())
376377
}
377378

378-
# Add notes parameter
379+
# Add notes parameter - use temp file to avoid escaping issues with special characters
379380
if ($usePRTitleAsNotesHeading -and $usePRBodyAsReleaseNotes -and $pull_request.title -and $pull_request.body) {
380381
$prTitle = $pull_request.title
381382
$prNumber = $pull_request.number
382383
$prBody = $pull_request.body
383384
$notes = "# $prTitle (#$prNumber)`n`n$prBody"
384-
$releaseCreateCommand += @('--notes', $notes)
385+
$notesFilePath = [System.IO.Path]::GetTempFileName()
386+
Set-Content -Path $notesFilePath -Value $notes -Encoding utf8
387+
$releaseCreateCommand += @('--notes-file', $notesFilePath)
385388
Write-Output 'Using PR title as H1 heading with link and body as release notes'
386389
} elseif ($usePRBodyAsReleaseNotes -and $pull_request.body) {
387390
$prBody = $pull_request.body
388-
$releaseCreateCommand += @('--notes', $prBody)
391+
$notesFilePath = [System.IO.Path]::GetTempFileName()
392+
Set-Content -Path $notesFilePath -Value $prBody -Encoding utf8
393+
$releaseCreateCommand += @('--notes-file', $notesFilePath)
389394
Write-Output 'Using PR body as release notes'
390395
} else {
391396
$releaseCreateCommand += @('--generate-notes')
@@ -405,6 +410,12 @@
405410
exit $LASTEXITCODE
406411
}
407412
}
413+
414+
# Clean up temporary notes file if created
415+
if ($notesFilePath -and (Test-Path -Path $notesFilePath)) {
416+
Remove-Item -Path $notesFilePath -Force
417+
}
418+
408419
if ($whatIf) {
409420
Write-Output 'WhatIf: gh pr comment $pull_request.number -b "The release [$newVersion] has been created."'
410421
} else {

0 commit comments

Comments
 (0)