|
45 | 45 | $majorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels -split ',' | ForEach-Object { $_.Trim() } |
46 | 46 | $minorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels -split ',' | ForEach-Object { $_.Trim() } |
47 | 47 | $patchLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels -split ',' | ForEach-Object { $_.Trim() } |
| 48 | + $usePRBodyAsReleaseNotes = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes -eq 'true' |
| 49 | + $usePRTitleAsReleaseName = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName -eq 'true' |
| 50 | + $usePRTitleAsNotesHeading = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading -eq 'true' |
48 | 51 |
|
49 | 52 | [pscustomobject]@{ |
50 | | - AutoCleanup = $autoCleanup |
51 | | - AutoPatching = $autoPatching |
52 | | - IncrementalPrerelease = $incrementalPrerelease |
53 | | - DatePrereleaseFormat = $datePrereleaseFormat |
54 | | - VersionPrefix = $versionPrefix |
55 | | - WhatIf = $whatIf |
56 | | - IgnoreLabels = $ignoreLabels |
57 | | - MajorLabels = $majorLabels |
58 | | - MinorLabels = $minorLabels |
59 | | - PatchLabels = $patchLabels |
| 53 | + AutoCleanup = $autoCleanup |
| 54 | + AutoPatching = $autoPatching |
| 55 | + IncrementalPrerelease = $incrementalPrerelease |
| 56 | + DatePrereleaseFormat = $datePrereleaseFormat |
| 57 | + VersionPrefix = $versionPrefix |
| 58 | + WhatIf = $whatIf |
| 59 | + IgnoreLabels = $ignoreLabels |
| 60 | + MajorLabels = $majorLabels |
| 61 | + MinorLabels = $minorLabels |
| 62 | + PatchLabels = $patchLabels |
| 63 | + UsePRBodyAsReleaseNotes = $usePRBodyAsReleaseNotes |
| 64 | + UsePRTitleAsReleaseName = $usePRTitleAsReleaseName |
| 65 | + UsePRTitleAsNotesHeading = $usePRTitleAsNotesHeading |
60 | 66 | } | Format-List | Out-String |
61 | 67 | } |
62 | 68 |
|
|
355 | 361 |
|
356 | 362 | LogGroup 'New-GitHubRelease' { |
357 | 363 | Write-Output 'Create new GitHub release' |
| 364 | + $releaseCreateCommand = @('release', 'create', $newVersion.ToString()) |
| 365 | + |
| 366 | + # Add title parameter |
| 367 | + if ($usePRTitleAsReleaseName -and $pull_request.title) { |
| 368 | + $prTitle = $pull_request.title |
| 369 | + $releaseCreateCommand += @('--title', $prTitle) |
| 370 | + Write-Output "Using PR title as release name: [$prTitle]" |
| 371 | + } else { |
| 372 | + $releaseCreateCommand += @('--title', $newVersion.ToString()) |
| 373 | + } |
| 374 | + |
| 375 | + # Add notes parameter |
| 376 | + if ($usePRTitleAsNotesHeading -and $pull_request.title -and $pull_request.body) { |
| 377 | + $prTitle = $pull_request.title |
| 378 | + $prNumber = $pull_request.number |
| 379 | + $prBody = $pull_request.body |
| 380 | + $notes = "# $prTitle (#$prNumber)`n`n$prBody" |
| 381 | + $releaseCreateCommand += @('--notes', $notes) |
| 382 | + Write-Output 'Using PR title as H1 heading with link and body as release notes' |
| 383 | + } elseif ($usePRBodyAsReleaseNotes -and $pull_request.body) { |
| 384 | + $prBody = $pull_request.body |
| 385 | + $releaseCreateCommand += @('--notes', $prBody) |
| 386 | + Write-Output 'Using PR body as release notes' |
| 387 | + } else { |
| 388 | + $releaseCreateCommand += '--generate-notes' |
| 389 | + } |
| 390 | + |
| 391 | + # Add remaining parameters |
358 | 392 | if ($createPrerelease) { |
359 | | - if ($whatIf) { |
360 | | - Write-Output "WhatIf: gh release create $newVersion --title $newVersion --target $prHeadRef --generate-notes --prerelease" |
361 | | - } else { |
362 | | - $releaseURL = gh release create $newVersion --title $newVersion --target $prHeadRef --generate-notes --prerelease |
363 | | - if ($LASTEXITCODE -ne 0) { |
364 | | - Write-Error "Failed to create the release [$newVersion]." |
365 | | - exit $LASTEXITCODE |
366 | | - } |
367 | | - } |
| 393 | + $releaseCreateCommand += @('--target', $prHeadRef, '--prerelease') |
| 394 | + } |
| 395 | + |
| 396 | + if ($whatIf) { |
| 397 | + Write-Output "WhatIf: gh $($releaseCreateCommand -join ' ')" |
368 | 398 | } else { |
369 | | - if ($whatIf) { |
370 | | - Write-Output "WhatIf: gh release create $newVersion --title $newVersion --generate-notes" |
371 | | - } else { |
372 | | - $releaseURL = gh release create $newVersion --title $newVersion --generate-notes |
373 | | - if ($LASTEXITCODE -ne 0) { |
374 | | - Write-Error "Failed to create the release [$newVersion]." |
375 | | - exit $LASTEXITCODE |
376 | | - } |
| 399 | + $releaseURL = gh @releaseCreateCommand |
| 400 | + if ($LASTEXITCODE -ne 0) { |
| 401 | + Write-Error "Failed to create the release [$newVersion]." |
| 402 | + exit $LASTEXITCODE |
377 | 403 | } |
378 | 404 | } |
379 | 405 | if ($whatIf) { |
|
0 commit comments