Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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.
Comment thread
MariusStorhaug marked this conversation as resolved.
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.
Comment thread
MariusStorhaug marked this conversation as resolved.
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.
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
required: false
default: 'true'

runs:
using: composite
Expand All @@ -81,4 +93,7 @@ runs:
PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels: ${{ inputs.PatchLabels }}
PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix: ${{ inputs.VersionPrefix }}
PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf: ${{ inputs.WhatIf }}
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes: ${{ inputs.UsePRBodyAsReleaseNotes }}
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName: ${{ inputs.UsePRTitleAsReleaseName }}
PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading: ${{ inputs.UsePRTitleAsNotesHeading }}
run: ${{ github.action_path }}/scripts/main.ps1
80 changes: 53 additions & 27 deletions scripts/helpers/Publish-PSModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,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'
Comment thread
MariusStorhaug marked this conversation as resolved.

[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
}

Expand Down Expand Up @@ -358,25 +364,45 @@

Set-GitHubLogGroup '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) {
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$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'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Comment thread
MariusStorhaug marked this conversation as resolved.
} elseif ($usePRBodyAsReleaseNotes -and $pull_request.body) {
$prBody = $pull_request.body
$releaseCreateCommand += @('--notes', $prBody)
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Write-Output 'Using PR body as release notes'
} else {
$releaseCreateCommand += '--generate-notes'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
}
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated

# 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 ' ')"
Comment thread
MariusStorhaug marked this conversation as resolved.
} 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) {
Expand Down
Loading