diff --git a/README.md b/README.md index aba9bb9..a892a3e 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ The action can be configured using the following settings: | `PatchLabels` | A comma separated list of labels that trigger a patch release. | `patch, fix` | false | | `UsePRTitleAsReleaseName` | When enabled, uses the pull request title as the name for the GitHub release. | `false` | false | | `UsePRBodyAsReleaseNotes` | When enabled, uses the pull request body as the release notes for the GitHub release. | `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. The title will include a reference to the PR number. | `true` | false | | `VersionPrefix` | The prefix to use for the version number. | `v` | false | | `WhatIf` | Control wether to simulate the action. If enabled, the action will not create any releases. Used for testing. | `false` | false | | `Debug` | Enable debug output. | `'false'` | false | diff --git a/action.yml b/action.yml index 9c1360a..016e711 100644 --- a/action.yml +++ b/action.yml @@ -58,6 +58,10 @@ inputs: description: When enabled, uses the pull request body as the release notes for the GitHub release. 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' VersionPrefix: description: The prefix to use for the version number. required: false @@ -105,6 +109,7 @@ runs: PSMODULE_AUTO_RELEASE_INPUT_PatchLabels: ${{ inputs.PatchLabels }} PSMODULE_AUTO_RELEASE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }} PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }} + PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }} PSMODULE_AUTO_RELEASE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }} PSMODULE_AUTO_RELEASE_INPUT_WhatIf: ${{ inputs.WhatIf }} with: diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 516bbc6..306378e 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -47,6 +47,7 @@ LogGroup 'Set configuration' { $incrementalPrerelease = ![string]::IsNullOrEmpty($configuration.IncrementalPrerelease) ? $configuration.IncrementalPrerelease -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_IncrementalPrerelease -eq 'true' $usePRBodyAsReleaseNotes = ![string]::IsNullOrEmpty($configuration.UsePRBodyAsReleaseNotes) ? $configuration.UsePRBodyAsReleaseNotes -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_UsePRBodyAsReleaseNotes -eq 'true' $usePRTitleAsReleaseName = ![string]::IsNullOrEmpty($configuration.UsePRTitleAsReleaseName) ? $configuration.UsePRTitleAsReleaseName -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsReleaseName -eq 'true' + $usePRTitleAsNotesHeading = ![string]::IsNullOrEmpty($configuration.UsePRTitleAsNotesHeading) ? $configuration.UsePRTitleAsNotesHeading -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsNotesHeading -eq 'true' $versionPrefix = ![string]::IsNullOrEmpty($configuration.VersionPrefix) ? $configuration.VersionPrefix : $env:PSMODULE_AUTO_RELEASE_INPUT_VersionPrefix $whatIf = ![string]::IsNullOrEmpty($configuration.WhatIf) ? $configuration.WhatIf -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_WhatIf -eq 'true' @@ -64,6 +65,7 @@ LogGroup 'Set configuration' { Write-Output "Incremental prerelease enabled: [$incrementalPrerelease]" Write-Output "Use PR body as release notes: [$usePRBodyAsReleaseNotes]" Write-Output "Use PR title as release name: [$usePRTitleAsReleaseName]" + Write-Output "Use PR title as notes heading: [$usePRTitleAsNotesHeading]" Write-Output "Version prefix: [$versionPrefix]" Write-Output "What if mode: [$whatIf]" Write-Output '' @@ -243,7 +245,14 @@ if ($createPrerelease -or $createRelease -or $whatIf) { } # Add notes parameter - if ($usePRBodyAsReleaseNotes) { + if ($usePRTitleAsNotesHeading) { + $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) { $prBody = $pull_request.body $releaseCreateCommand += @("--notes", "$prBody") Write-Output 'Using PR body as release notes' @@ -288,7 +297,14 @@ if ($createPrerelease -or $createRelease -or $whatIf) { } # Add notes parameter - if ($usePRBodyAsReleaseNotes) { + if ($usePRTitleAsNotesHeading) { + $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) { $prBody = $pull_request.body $releaseCreateCommand += @("--notes", "$prBody") Write-Output 'Using PR body as release notes'