From 92f2aef94bfbb2d962669af913a121dfe76169e7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 May 2025 17:46:51 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20releas?= =?UTF-8?q?e=20notes=20handling=20to=20improve=20clarity=20and=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 306378e..e823b53 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -245,19 +245,23 @@ if ($createPrerelease -or $createRelease -or $whatIf) { } # Add notes parameter + $notes = "" if ($usePRTitleAsNotesHeading) { $prTitle = $pull_request.title $prNumber = $pull_request.number + $notes += "# $prTitle (#$prNumber)`n`n" + } + if ($usePRBodyAsReleaseNotes) { $prBody = $pull_request.body - $notes = "# $prTitle (#$prNumber)`n`n$prBody" - $releaseCreateCommand += @("--notes", "$notes") - Write-Output 'Using PR title as H1 heading with link and body as release notes' - } elseif ($usePRBodyAsReleaseNotes) { - $prBody = $pull_request.body - $releaseCreateCommand += @("--notes", "$prBody") - Write-Output 'Using PR body as release notes' + $notes += $prBody + } + Write-Output 'gh arguments:' + if (-not [string]::IsNullOrWhiteSpace($notes)) { + $releaseCreateCommand += @('--notes', $notes) + Write-Output "$($releaseCreateCommand -join ' ')" } else { $releaseCreateCommand += '--generate-notes' + Write-Output "$($releaseCreateCommand -join ' ')" } # Add remaining parameters @@ -297,19 +301,23 @@ if ($createPrerelease -or $createRelease -or $whatIf) { } # Add notes parameter + $notes = "" if ($usePRTitleAsNotesHeading) { $prTitle = $pull_request.title $prNumber = $pull_request.number + $notes += "# $prTitle (#$prNumber)`n`n" + } + if ($usePRBodyAsReleaseNotes) { $prBody = $pull_request.body - $notes = "# $prTitle (#$prNumber)`n`n$prBody" - $releaseCreateCommand += @("--notes", "$notes") - Write-Output 'Using PR title as H1 heading with link and body as release notes' - } elseif ($usePRBodyAsReleaseNotes) { - $prBody = $pull_request.body - $releaseCreateCommand += @("--notes", "$prBody") - Write-Output 'Using PR body as release notes' + $notes += $prBody + } + Write-Output "gh arguments:" + if (-not [string]::IsNullOrWhiteSpace($notes)) { + $releaseCreateCommand += @('--notes', $notes) + Write-Output "$($releaseCreateCommand -join ' ')" } else { $releaseCreateCommand += '--generate-notes' + Write-Output "$($releaseCreateCommand -join ' ')" } if ($whatIf) { From d0b6f5ab9811efc78c3b6369ab63722a6c2f6ec4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 May 2025 18:02:25 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20releas?= =?UTF-8?q?e=20creation=20command=20for=20consistency=20and=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index e823b53..089a75f 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -233,19 +233,19 @@ if ($createPrerelease -or $createRelease -or $whatIf) { } # Build release creation command with options - $releaseCreateCommand = @("release", "create", "$newVersion") + $releaseCreateCommand = @('release', 'create', "$newVersion") # Add title parameter if ($usePRTitleAsReleaseName) { $prTitle = $pull_request.title - $releaseCreateCommand += @("--title", "$prTitle") + $releaseCreateCommand += @('--title', "$prTitle") Write-Output "Using PR title as release name: [$prTitle]" } else { - $releaseCreateCommand += @("--title", "$newVersion") + $releaseCreateCommand += @('--title', "$newVersion") } # Add notes parameter - $notes = "" + $notes = '' if ($usePRTitleAsNotesHeading) { $prTitle = $pull_request.title $prNumber = $pull_request.number @@ -255,21 +255,17 @@ if ($createPrerelease -or $createRelease -or $whatIf) { $prBody = $pull_request.body $notes += $prBody } - Write-Output 'gh arguments:' if (-not [string]::IsNullOrWhiteSpace($notes)) { $releaseCreateCommand += @('--notes', $notes) - Write-Output "$($releaseCreateCommand -join ' ')" } else { $releaseCreateCommand += '--generate-notes' - Write-Output "$($releaseCreateCommand -join ' ')" } # Add remaining parameters - $releaseCreateCommand += @("--target", $prHeadRef, "--prerelease") + $releaseCreateCommand += @('--target', $prHeadRef, '--prerelease') - if ($whatIf) { - Write-Output "WhatIf: $releaseCreateCommand" - } else { + Write-Output "gh $($releaseCreateCommand -join ' ')" + if (-not $whatIf) { # Execute the command and capture the output $releaseURL = gh @releaseCreateCommand if ($LASTEXITCODE -ne 0) { @@ -289,19 +285,19 @@ if ($createPrerelease -or $createRelease -or $whatIf) { } } else { # Build release creation command with options - $releaseCreateCommand = @("release", "create", "$newVersion") + $releaseCreateCommand = @('release', 'create', "$newVersion") # Add title parameter if ($usePRTitleAsReleaseName) { $prTitle = $pull_request.title - $releaseCreateCommand += @("--title", "$prTitle") + $releaseCreateCommand += @('--title', "$prTitle") Write-Output "Using PR title as release name: [$prTitle]" } else { - $releaseCreateCommand += @("--title", "$newVersion") + $releaseCreateCommand += @('--title', "$newVersion") } # Add notes parameter - $notes = "" + $notes = '' if ($usePRTitleAsNotesHeading) { $prTitle = $pull_request.title $prNumber = $pull_request.number @@ -311,19 +307,14 @@ if ($createPrerelease -or $createRelease -or $whatIf) { $prBody = $pull_request.body $notes += $prBody } - Write-Output "gh arguments:" if (-not [string]::IsNullOrWhiteSpace($notes)) { $releaseCreateCommand += @('--notes', $notes) - Write-Output "$($releaseCreateCommand -join ' ')" } else { $releaseCreateCommand += '--generate-notes' - Write-Output "$($releaseCreateCommand -join ' ')" } - if ($whatIf) { - Write-Output "WhatIf: $releaseCreateCommand" - } else { - # Execute the command + Write-Output "gh $($releaseCreateCommand -join ' ')" + if (-not $whatIf) { gh @releaseCreateCommand if ($LASTEXITCODE -ne 0) { Write-Error "Failed to create the release [$newVersion]."