From 7e38253d7786b3ce0820d687e6f2766a124aa234 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 May 2025 09:35:40 +0200 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20options?= =?UTF-8?q?=20for=20using=20PR=20title=20and=20body=20as=20release=20name?= =?UTF-8?q?=20and=20notes=20in=20GitHub=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 13 +++++ action.yml | 15 ++++++ scripts/helpers/Publish-PSModule.ps1 | 80 ++++++++++++++++++---------- 3 files changed, 81 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 83faa3c..4afdd03 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,19 @@ The action can be configured using the following settings: | `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | | `false` | | `Prerelease` | Allow prerelease versions if available. | `'false'` | `false` | | `WorkingDirectory` | The working directory where the script runs. | `'false'` | `'.'` | +| `UsePRTitleAsReleaseName` | When enabled, uses the pull request title as the name for the GitHub release. If not set or the PR has no title, the version string is used. | `false` | false | +| `UsePRBodyAsReleaseNotes` | When enabled, uses the pull request body as the release notes for the GitHub release. If not set or the PR has no body, the release notes are auto-generated. | `true` | false | +| `UsePRTitleAsNotesHeading` | When enabled, the release notes will begin with the pull request title as a H1 heading followed by the pull request body, including a reference to the PR number. | `true` | false | + +## Release Title and Notes Logic + +- If `UsePRTitleAsReleaseName` is enabled and the pull request has a title, the release name will be set to the PR title. Otherwise, it defaults to the version string. +- If `UsePRTitleAsNotesHeading` is enabled and the PR has both a title and body, the release notes will start with the PR title as a heading (with PR number), followed by the PR body. +- If only `UsePRBodyAsReleaseNotes` is enabled and the PR has a body, the release notes will use the PR body. +- If neither is enabled or the PR has no body, the release notes are auto-generated (`--generate-notes`). +- The GitHub CLI command for creating the release is constructed stepwise, with `--title`, `--notes` (if provided), and `--generate-notes` as a fallback, matching the logic from Auto-Release. + +The action outputs the calculated release name and body in the logs for visibility and testing. ## Example diff --git a/action.yml b/action.yml index 2b0fac0..b6b0426 100644 --- a/action.yml +++ b/action.yml @@ -75,6 +75,18 @@ inputs: description: The working directory where the script will run from. required: false default: '.' + UsePRTitleAsReleaseName: + description: When enabled, uses the pull request title as the name for the GitHub release. If not set, the version string is used. + required: false + default: 'false' + UsePRBodyAsReleaseNotes: + description: When enabled, uses the pull request body as the release notes for the GitHub release. If not set, the release notes are auto-generated. + required: false + default: 'true' + UsePRTitleAsNotesHeading: + description: When enabled, the release notes will begin with the pull request title as a H1 heading followed by the pull request body. The title will reference the pull request number. + required: false + default: 'true' runs: using: composite @@ -99,6 +111,9 @@ runs: PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }} PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }} PSMODULE_PUBLISH_PSMODULE_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }} + PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }} + PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }} + PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }} with: Name: Publish-PSModule Debug: ${{ inputs.Debug }} diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 96ce20d..4aad51e 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -45,18 +45,24 @@ $majorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels -split ',' | ForEach-Object { $_.Trim() } $minorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels -split ',' | ForEach-Object { $_.Trim() } $patchLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels -split ',' | ForEach-Object { $_.Trim() } + $usePRBodyAsReleaseNotes = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes -eq 'true' + $usePRTitleAsReleaseName = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName -eq 'true' + $usePRTitleAsNotesHeading = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading -eq 'true' [pscustomobject]@{ - AutoCleanup = $autoCleanup - AutoPatching = $autoPatching - IncrementalPrerelease = $incrementalPrerelease - DatePrereleaseFormat = $datePrereleaseFormat - VersionPrefix = $versionPrefix - WhatIf = $whatIf - IgnoreLabels = $ignoreLabels - MajorLabels = $majorLabels - MinorLabels = $minorLabels - PatchLabels = $patchLabels + AutoCleanup = $autoCleanup + AutoPatching = $autoPatching + IncrementalPrerelease = $incrementalPrerelease + DatePrereleaseFormat = $datePrereleaseFormat + VersionPrefix = $versionPrefix + WhatIf = $whatIf + IgnoreLabels = $ignoreLabels + MajorLabels = $majorLabels + MinorLabels = $minorLabels + PatchLabels = $patchLabels + UsePRBodyAsReleaseNotes = $usePRBodyAsReleaseNotes + UsePRTitleAsReleaseName = $usePRTitleAsReleaseName + UsePRTitleAsNotesHeading = $usePRTitleAsNotesHeading } | Format-List | Out-String } @@ -355,25 +361,45 @@ LogGroup 'New-GitHubRelease' { Write-Output 'Create new GitHub release' + $releaseCreateCommand = @('release', 'create', $newVersion.ToString()) + + # Add title parameter + if ($usePRTitleAsReleaseName -and $pull_request.title) { + $prTitle = $pull_request.title + $releaseCreateCommand += @('--title', $prTitle) + Write-Output "Using PR title as release name: [$prTitle]" + } else { + $releaseCreateCommand += @('--title', $newVersion.ToString()) + } + + # Add notes parameter + if ($usePRTitleAsNotesHeading -and $pull_request.title -and $pull_request.body) { + $prTitle = $pull_request.title + $prNumber = $pull_request.number + $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 -and $pull_request.body) { + $prBody = $pull_request.body + $releaseCreateCommand += @('--notes', $prBody) + Write-Output 'Using PR body as release notes' + } else { + $releaseCreateCommand += '--generate-notes' + } + + # Add remaining parameters if ($createPrerelease) { - if ($whatIf) { - Write-Output "WhatIf: gh release create $newVersion --title $newVersion --target $prHeadRef --generate-notes --prerelease" - } else { - $releaseURL = gh release create $newVersion --title $newVersion --target $prHeadRef --generate-notes --prerelease - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to create the release [$newVersion]." - exit $LASTEXITCODE - } - } + $releaseCreateCommand += @('--target', $prHeadRef, '--prerelease') + } + + if ($whatIf) { + Write-Output "WhatIf: gh $($releaseCreateCommand -join ' ')" } else { - if ($whatIf) { - Write-Output "WhatIf: gh release create $newVersion --title $newVersion --generate-notes" - } else { - $releaseURL = gh release create $newVersion --title $newVersion --generate-notes - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to create the release [$newVersion]." - exit $LASTEXITCODE - } + $releaseURL = gh @releaseCreateCommand + if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to create the release [$newVersion]." + exit $LASTEXITCODE } } if ($whatIf) { From 38d052bdfce4b961c9d2a0c2d39f62189f15c669 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Jan 2026 23:17:41 +0100 Subject: [PATCH 02/12] Fix zizmor linting errors and disable BIOME_FORMAT --- .github/PSModule.yml | 3 +++ .github/dependabot.yml | 4 ++++ .github/workflows/Action-Test.yml | 2 ++ .github/workflows/Auto-Release.yml | 4 ++++ .github/workflows/Linter.yml | 2 ++ action.yml | 1 + 6 files changed, 16 insertions(+) create mode 100644 .github/PSModule.yml diff --git a/.github/PSModule.yml b/.github/PSModule.yml new file mode 100644 index 0000000..ca234f5 --- /dev/null +++ b/.github/PSModule.yml @@ -0,0 +1,3 @@ +Linter: + env: + VALIDATE_BIOME_FORMAT: false diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 53188fe..410be35 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,3 +12,7 @@ updates: - github-actions schedule: interval: weekly + groups: + github-actions: + patterns: + - '*' diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 664004f..d3e08c7 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -23,6 +23,8 @@ jobs: steps: - name: Checkout repo uses: actions/checkout@v6 + with: + persist-credentials: false - name: Action-Test uses: ./ diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index 976b40c..bded620 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -2,6 +2,7 @@ name: Auto-Release run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" +# zizmor: ignore[dangerous-triggers] intentional - Auto-Release needs write access to create releases on PR merge on: pull_request_target: branches: @@ -27,8 +28,11 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v6 + with: + persist-credentials: false - name: Auto-Release + # zizmor: ignore[unpinned-uses] not our action uses: PSModule/Auto-Release@v1 with: IncrementalPrerelease: false diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 1962629..8e0d92f 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -22,8 +22,10 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + persist-credentials: false - name: Lint code base + # zizmor: ignore[unpinned-uses] not our action uses: super-linter/super-linter@latest env: GITHUB_TOKEN: ${{ github.token }} diff --git a/action.yml b/action.yml index 13fd9ac..1a9b30c 100644 --- a/action.yml +++ b/action.yml @@ -74,6 +74,7 @@ runs: using: composite steps: - name: Install-PSModuleHelpers + # zizmor: ignore[unpinned-uses] not our action uses: PSModule/Install-PSModuleHelpers@v1 - name: Run Publish-PSModule From 0aa3bb388189216fb5f1189b1cf8f90edaa7362b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Jan 2026 23:23:12 +0100 Subject: [PATCH 03/12] Move BIOME_FORMAT disable to Linter.yml --- .github/PSModule.yml | 3 --- .github/workflows/Linter.yml | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 .github/PSModule.yml diff --git a/.github/PSModule.yml b/.github/PSModule.yml deleted file mode 100644 index ca234f5..0000000 --- a/.github/PSModule.yml +++ /dev/null @@ -1,3 +0,0 @@ -Linter: - env: - VALIDATE_BIOME_FORMAT: false diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 8e0d92f..5f98fd3 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -29,6 +29,7 @@ jobs: uses: super-linter/super-linter@latest env: GITHUB_TOKEN: ${{ github.token }} + VALIDATE_BIOME_FORMAT: false VALIDATE_JSON_PRETTIER: false VALIDATE_MARKDOWN_PRETTIER: false VALIDATE_YAML_PRETTIER: false From d3861557c8f78653e3aba098dace770e2ec0357d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Jan 2026 23:27:31 +0100 Subject: [PATCH 04/12] Move zizmor ignores to .github/linters/zizmor.yml --- .github/linters/zizmor.yml | 10 ++++++++++ .github/workflows/Auto-Release.yml | 2 -- .github/workflows/Linter.yml | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .github/linters/zizmor.yml diff --git a/.github/linters/zizmor.yml b/.github/linters/zizmor.yml new file mode 100644 index 0000000..9b2e6f5 --- /dev/null +++ b/.github/linters/zizmor.yml @@ -0,0 +1,10 @@ +rules: + dangerous-triggers: + ignore: + # Auto-Release needs write access to create releases on PR merge + - Auto-Release.yml + unpinned-uses: + ignore: + # External actions - not pinned by design + - Auto-Release.yml + - Linter.yml diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index bded620..bbe9c34 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -2,7 +2,6 @@ name: Auto-Release run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" -# zizmor: ignore[dangerous-triggers] intentional - Auto-Release needs write access to create releases on PR merge on: pull_request_target: branches: @@ -32,7 +31,6 @@ jobs: persist-credentials: false - name: Auto-Release - # zizmor: ignore[unpinned-uses] not our action uses: PSModule/Auto-Release@v1 with: IncrementalPrerelease: false diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 5f98fd3..3ce5666 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -25,7 +25,6 @@ jobs: persist-credentials: false - name: Lint code base - # zizmor: ignore[unpinned-uses] not our action uses: super-linter/super-linter@latest env: GITHUB_TOKEN: ${{ github.token }} From 95e5b0a59abf4e95c723d34a69d734cae55252bc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Jan 2026 23:52:54 +0100 Subject: [PATCH 05/12] Switch Auto-Release from pull_request_target to pull_request --- .github/linters/zizmor.yml | 4 ---- .github/workflows/Auto-Release.yml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/linters/zizmor.yml b/.github/linters/zizmor.yml index 9b2e6f5..d61644d 100644 --- a/.github/linters/zizmor.yml +++ b/.github/linters/zizmor.yml @@ -1,8 +1,4 @@ rules: - dangerous-triggers: - ignore: - # Auto-Release needs write access to create releases on PR merge - - Auto-Release.yml unpinned-uses: ignore: # External actions - not pinned by design diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index bbe9c34..8c45403 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -3,7 +3,7 @@ name: Auto-Release run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" on: - pull_request_target: + pull_request: branches: - main types: From 1c405440f1419d32f5d3e1b495a507da8d4a979c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Jan 2026 23:59:03 +0100 Subject: [PATCH 06/12] Pin all action references to commit SHAs --- .github/linters/zizmor.yml | 6 ------ .github/workflows/Action-Test.yml | 2 +- .github/workflows/Auto-Release.yml | 4 ++-- .github/workflows/Linter.yml | 4 ++-- action.yml | 3 +-- 5 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 .github/linters/zizmor.yml diff --git a/.github/linters/zizmor.yml b/.github/linters/zizmor.yml deleted file mode 100644 index d61644d..0000000 --- a/.github/linters/zizmor.yml +++ /dev/null @@ -1,6 +0,0 @@ -rules: - unpinned-uses: - ignore: - # External actions - not pinned by design - - Auto-Release.yml - - Linter.yml diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index d3e08c7..03da0a6 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index 8c45403..643724c 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -26,11 +26,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: Auto-Release - uses: PSModule/Auto-Release@v1 + uses: PSModule/Auto-Release@eabd533035e2cb9822160f26f2eda584bd012356 # v1.9.5 with: IncrementalPrerelease: false diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 3ce5666..377763a 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -19,13 +19,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repo - uses: actions/checkout@v6 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 persist-credentials: false - name: Lint code base - uses: super-linter/super-linter@latest + uses: super-linter/super-linter@d5b0a2ab116623730dd094f15ddc1b6b25bf7b99 # v8.3.2 env: GITHUB_TOKEN: ${{ github.token }} VALIDATE_BIOME_FORMAT: false diff --git a/action.yml b/action.yml index 1a9b30c..71c6d4b 100644 --- a/action.yml +++ b/action.yml @@ -74,8 +74,7 @@ runs: using: composite steps: - name: Install-PSModuleHelpers - # zizmor: ignore[unpinned-uses] not our action - uses: PSModule/Install-PSModuleHelpers@v1 + uses: PSModule/Install-PSModuleHelpers@d60d63e4be477d1ca0c67c6085101fb109bce8f1 # v1.0.6 - name: Run Publish-PSModule shell: pwsh From 4e51b8c9e11a45a0375be09c44db34f5c907a187 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 00:08:20 +0100 Subject: [PATCH 07/12] Update Dependabot schedule to daily for GitHub Actions --- .github/dependabot.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 410be35..0da2fac 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,8 +11,6 @@ updates: - dependencies - github-actions schedule: - interval: weekly - groups: - github-actions: - patterns: - - '*' + interval: daily + cooldown: + default-days: 7 From 944fa9544265ca6d50df118a7d7a2ae3fc392872 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 00:22:19 +0100 Subject: [PATCH 08/12] Fix logical operator casing and enhance release notes handling in Publish-PSModule --- scripts/helpers/Publish-PSModule.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index a73f189..cd84a99 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -82,7 +82,7 @@ Set-GitHubLogGroup 'Event information - Details' { $defaultBranchName = (gh repo view --json defaultBranchRef | ConvertFrom-Json | Select-Object -ExpandProperty defaultBranchRef).name - $isPullRequest = $githubEvent.PSObject.Properties.Name -Contains 'pull_request' + $isPullRequest = $githubEvent.PSObject.Properties.Name -contains 'pull_request' if (-not ($isPullRequest -or $whatIf)) { Write-Warning '⚠️ A release should not be created in this context. Exiting.' exit @@ -119,7 +119,7 @@ Set-GitHubLogGroup 'Calculate release type' { $createRelease = $isMerged -and $targetIsDefaultBranch $closedPullRequest = $prIsClosed -and -not $isMerged - $createPrerelease = $labels -Contains 'prerelease' -and -not $createRelease -and -not $closedPullRequest + $createPrerelease = $labels -contains 'prerelease' -and -not $createRelease -and -not $closedPullRequest $prereleaseName = $prHeadRef -replace '[^a-zA-Z0-9]' $ignoreRelease = ($labels | Where-Object { $ignoreLabels -contains $_ }).Count -gt 0 @@ -376,7 +376,7 @@ } # Add notes parameter - if ($usePRTitleAsNotesHeading -and $pull_request.title -and $pull_request.body) { + if ($usePRTitleAsNotesHeading -and $usePRBodyAsReleaseNotes -and $pull_request.title -and $pull_request.body) { $prTitle = $pull_request.title $prNumber = $pull_request.number $prBody = $pull_request.body From 970970934b9548f4f1648db23cc8ad3e1fdeb9c7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 00:27:34 +0100 Subject: [PATCH 09/12] Fix release notes command formatting in Publish-PSModule --- scripts/helpers/Publish-PSModule.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index cd84a99..c52d817 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -388,7 +388,7 @@ $releaseCreateCommand += @('--notes', $prBody) Write-Output 'Using PR body as release notes' } else { - $releaseCreateCommand += '--generate-notes' + $releaseCreateCommand += @('--generate-notes') } # Add remaining parameters From 5e96c35e31a4bae64c6474ddc369c79342d28349 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 00:32:04 +0100 Subject: [PATCH 10/12] Enhance GitHub release notes handling by using temporary files to avoid escaping issues --- scripts/helpers/Publish-PSModule.ps1 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index c52d817..5323e56 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -365,6 +365,7 @@ Set-GitHubLogGroup 'New-GitHubRelease' { Write-Output 'Create new GitHub release' $releaseCreateCommand = @('release', 'create', $newVersion.ToString()) + $notesFilePath = $null # Add title parameter if ($usePRTitleAsReleaseName -and $pull_request.title) { @@ -375,17 +376,21 @@ $releaseCreateCommand += @('--title', $newVersion.ToString()) } - # Add notes parameter + # Add notes parameter - use temp file to avoid escaping issues with special characters if ($usePRTitleAsNotesHeading -and $usePRBodyAsReleaseNotes -and $pull_request.title -and $pull_request.body) { $prTitle = $pull_request.title $prNumber = $pull_request.number $prBody = $pull_request.body $notes = "# $prTitle (#$prNumber)`n`n$prBody" - $releaseCreateCommand += @('--notes', $notes) + $notesFilePath = [System.IO.Path]::GetTempFileName() + Set-Content -Path $notesFilePath -Value $notes -Encoding utf8 + $releaseCreateCommand += @('--notes-file', $notesFilePath) Write-Output 'Using PR title as H1 heading with link and body as release notes' } elseif ($usePRBodyAsReleaseNotes -and $pull_request.body) { $prBody = $pull_request.body - $releaseCreateCommand += @('--notes', $prBody) + $notesFilePath = [System.IO.Path]::GetTempFileName() + Set-Content -Path $notesFilePath -Value $prBody -Encoding utf8 + $releaseCreateCommand += @('--notes-file', $notesFilePath) Write-Output 'Using PR body as release notes' } else { $releaseCreateCommand += @('--generate-notes') @@ -405,6 +410,12 @@ exit $LASTEXITCODE } } + + # Clean up temporary notes file if created + if ($notesFilePath -and (Test-Path -Path $notesFilePath)) { + Remove-Item -Path $notesFilePath -Force + } + if ($whatIf) { Write-Output 'WhatIf: gh pr comment $pull_request.number -b "The release [$newVersion] has been created."' } else { From e45167feeccb9a9347c3b55d9bd162ce49c3c2eb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 00:37:22 +0100 Subject: [PATCH 11/12] Enhance release notes handling by building content from PR title and body, using a temp file to avoid escaping issues --- scripts/helpers/Publish-PSModule.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/helpers/Publish-PSModule.ps1 b/scripts/helpers/Publish-PSModule.ps1 index 5323e56..addd0b8 100644 --- a/scripts/helpers/Publish-PSModule.ps1 +++ b/scripts/helpers/Publish-PSModule.ps1 @@ -376,8 +376,15 @@ $releaseCreateCommand += @('--title', $newVersion.ToString()) } - # Add notes parameter - use temp file to avoid escaping issues with special characters + # Build release notes content. Uses temp file to avoid escaping issues with special characters. + # Precedence rules for the three UsePR* parameters: + # 1. UsePRTitleAsNotesHeading + UsePRBodyAsReleaseNotes: Creates "# Title (#PR)\n\nBody" format. + # Requires both parameters enabled AND both PR title and body to be present. + # 2. UsePRBodyAsReleaseNotes only: Uses PR body as-is for release notes. + # Takes effect when heading option is disabled/missing title, but body is available. + # 3. Fallback: Auto-generates notes via GitHub's --generate-notes when no PR content is used. if ($usePRTitleAsNotesHeading -and $usePRBodyAsReleaseNotes -and $pull_request.title -and $pull_request.body) { + # Path 1: Full PR-based notes with title as H1 heading and PR number link $prTitle = $pull_request.title $prNumber = $pull_request.number $prBody = $pull_request.body @@ -387,12 +394,14 @@ $releaseCreateCommand += @('--notes-file', $notesFilePath) Write-Output 'Using PR title as H1 heading with link and body as release notes' } elseif ($usePRBodyAsReleaseNotes -and $pull_request.body) { + # Path 2: PR body only - no heading, just the body content $prBody = $pull_request.body $notesFilePath = [System.IO.Path]::GetTempFileName() Set-Content -Path $notesFilePath -Value $prBody -Encoding utf8 $releaseCreateCommand += @('--notes-file', $notesFilePath) Write-Output 'Using PR body as release notes' } else { + # Path 3: Fallback to GitHub's auto-generated release notes $releaseCreateCommand += @('--generate-notes') } From eca2098ac73c5fd0afbc05922667deb4845158b4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 00:39:49 +0100 Subject: [PATCH 12/12] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 71c6d4b..7d0c08c 100644 --- a/action.yml +++ b/action.yml @@ -66,7 +66,7 @@ inputs: required: false default: 'true' UsePRTitleAsNotesHeading: - description: When enabled, the release notes will begin with the pull request title as a H1 heading followed by the pull request body. The title will reference the pull request number. + description: When enabled along with UsePRBodyAsReleaseNotes, the release notes will begin with the pull request title as a H1 heading followed by the pull request body. The title will reference the pull request number. required: false default: 'true'