Skip to content

Commit 09e7eaf

Browse files
🚀[Feature]: Add option to use PR title heading in release notes (#80)
## Summary This update introduces a new configuration option, `UsePRTitleAsNotesHeading`, which uses the pull request (PR) title to be used as a heading in the generated release notes. When enabled, the PR title will appear as a first-level heading (`#`) in the release notes, enhancing readability and organization. ### ✅ Changes * Added `UsePRTitleAsNotesHeading` configuration option to control the inclusion of PR titles as headings in release notes. * Updated the release note generation logic to conditionally include PR titles based on the new configuration setting. ### 🛠 Configuration As this feature is enabled by default, disable it by setting the `UsePRTitleAsNotesHeading` option to `false` on the action. --------- Co-authored-by: Copilot <[email protected]>
1 parent 9c8306e commit 09e7eaf

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The action can be configured using the following settings:
5252
| `PatchLabels` | A comma separated list of labels that trigger a patch release. | `patch, fix` | false |
5353
| `UsePRTitleAsReleaseName` | When enabled, uses the pull request title as the name for the GitHub release. | `false` | false |
5454
| `UsePRBodyAsReleaseNotes` | When enabled, uses the pull request body as the release notes for the GitHub release. | `true` | false |
55+
| `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 |
5556
| `VersionPrefix` | The prefix to use for the version number. | `v` | false |
5657
| `WhatIf` | Control wether to simulate the action. If enabled, the action will not create any releases. Used for testing. | `false` | false |
5758
| `Debug` | Enable debug output. | `'false'` | false |

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ inputs:
5858
description: When enabled, uses the pull request body as the release notes for the GitHub release.
5959
required: false
6060
default: 'true'
61+
UsePRTitleAsNotesHeading:
62+
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.
63+
required: false
64+
default: 'true'
6165
VersionPrefix:
6266
description: The prefix to use for the version number.
6367
required: false
@@ -105,6 +109,7 @@ runs:
105109
PSMODULE_AUTO_RELEASE_INPUT_PatchLabels: ${{ inputs.PatchLabels }}
106110
PSMODULE_AUTO_RELEASE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }}
107111
PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }}
112+
PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }}
108113
PSMODULE_AUTO_RELEASE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }}
109114
PSMODULE_AUTO_RELEASE_INPUT_WhatIf: ${{ inputs.WhatIf }}
110115
with:

scripts/main.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ LogGroup 'Set configuration' {
4747
$incrementalPrerelease = ![string]::IsNullOrEmpty($configuration.IncrementalPrerelease) ? $configuration.IncrementalPrerelease -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_IncrementalPrerelease -eq 'true'
4848
$usePRBodyAsReleaseNotes = ![string]::IsNullOrEmpty($configuration.UsePRBodyAsReleaseNotes) ? $configuration.UsePRBodyAsReleaseNotes -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_UsePRBodyAsReleaseNotes -eq 'true'
4949
$usePRTitleAsReleaseName = ![string]::IsNullOrEmpty($configuration.UsePRTitleAsReleaseName) ? $configuration.UsePRTitleAsReleaseName -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsReleaseName -eq 'true'
50+
$usePRTitleAsNotesHeading = ![string]::IsNullOrEmpty($configuration.UsePRTitleAsNotesHeading) ? $configuration.UsePRTitleAsNotesHeading -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_UsePRTitleAsNotesHeading -eq 'true'
5051
$versionPrefix = ![string]::IsNullOrEmpty($configuration.VersionPrefix) ? $configuration.VersionPrefix : $env:PSMODULE_AUTO_RELEASE_INPUT_VersionPrefix
5152
$whatIf = ![string]::IsNullOrEmpty($configuration.WhatIf) ? $configuration.WhatIf -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_WhatIf -eq 'true'
5253

@@ -64,6 +65,7 @@ LogGroup 'Set configuration' {
6465
Write-Output "Incremental prerelease enabled: [$incrementalPrerelease]"
6566
Write-Output "Use PR body as release notes: [$usePRBodyAsReleaseNotes]"
6667
Write-Output "Use PR title as release name: [$usePRTitleAsReleaseName]"
68+
Write-Output "Use PR title as notes heading: [$usePRTitleAsNotesHeading]"
6769
Write-Output "Version prefix: [$versionPrefix]"
6870
Write-Output "What if mode: [$whatIf]"
6971
Write-Output ''
@@ -243,7 +245,14 @@ if ($createPrerelease -or $createRelease -or $whatIf) {
243245
}
244246

245247
# Add notes parameter
246-
if ($usePRBodyAsReleaseNotes) {
248+
if ($usePRTitleAsNotesHeading) {
249+
$prTitle = $pull_request.title
250+
$prNumber = $pull_request.number
251+
$prBody = $pull_request.body
252+
$notes = "# $prTitle (#$prNumber)`n`n$prBody"
253+
$releaseCreateCommand += @("--notes", "$notes")
254+
Write-Output 'Using PR title as H1 heading with link and body as release notes'
255+
} elseif ($usePRBodyAsReleaseNotes) {
247256
$prBody = $pull_request.body
248257
$releaseCreateCommand += @("--notes", "$prBody")
249258
Write-Output 'Using PR body as release notes'
@@ -288,7 +297,14 @@ if ($createPrerelease -or $createRelease -or $whatIf) {
288297
}
289298

290299
# Add notes parameter
291-
if ($usePRBodyAsReleaseNotes) {
300+
if ($usePRTitleAsNotesHeading) {
301+
$prTitle = $pull_request.title
302+
$prNumber = $pull_request.number
303+
$prBody = $pull_request.body
304+
$notes = "# $prTitle (#$prNumber)`n`n$prBody"
305+
$releaseCreateCommand += @("--notes", "$notes")
306+
Write-Output 'Using PR title as H1 heading with link and body as release notes'
307+
} elseif ($usePRBodyAsReleaseNotes) {
292308
$prBody = $pull_request.body
293309
$releaseCreateCommand += @("--notes", "$prBody")
294310
Write-Output 'Using PR body as release notes'

0 commit comments

Comments
 (0)