Skip to content
Merged
Changes from all 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
55 changes: 27 additions & 28 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -233,39 +233,39 @@ if ($createPrerelease -or $createRelease -or $whatIf) {
}

# Build release creation command with options
$releaseCreateCommand = @("release", "create", "$newVersion")
$releaseCreateCommand = @('release', 'create', "$newVersion")

# Add title parameter
if ($usePRTitleAsReleaseName) {
$prTitle = $pull_request.title
$releaseCreateCommand += @("--title", "$prTitle")
$releaseCreateCommand += @('--title', "$prTitle")
Write-Output "Using PR title as release name: [$prTitle]"
} else {
$releaseCreateCommand += @("--title", "$newVersion")
$releaseCreateCommand += @('--title', "$newVersion")
}

# Add notes parameter
$notes = ''
if ($usePRTitleAsNotesHeading) {
$prTitle = $pull_request.title
$prNumber = $pull_request.number
$notes += "# $prTitle (#$prNumber)`n`n"
}
if ($usePRBodyAsReleaseNotes) {
$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'
$notes += $prBody
}
if (-not [string]::IsNullOrWhiteSpace($notes)) {
$releaseCreateCommand += @('--notes', $notes)
} else {
$releaseCreateCommand += '--generate-notes'
}

# Add remaining parameters
$releaseCreateCommand += @("--target", $prHeadRef, "--prerelease")
$releaseCreateCommand += @('--target', $prHeadRef, '--prerelease')

if ($whatIf) {
Write-Output "WhatIf: $releaseCreateCommand"
} else {
Write-Output "gh $($releaseCreateCommand -join ' ')"
if (-not $whatIf) {
# Execute the command and capture the output
$releaseURL = gh @releaseCreateCommand
if ($LASTEXITCODE -ne 0) {
Expand All @@ -285,37 +285,36 @@ if ($createPrerelease -or $createRelease -or $whatIf) {
}
} else {
# Build release creation command with options
$releaseCreateCommand = @("release", "create", "$newVersion")
$releaseCreateCommand = @('release', 'create', "$newVersion")

# Add title parameter
if ($usePRTitleAsReleaseName) {
$prTitle = $pull_request.title
$releaseCreateCommand += @("--title", "$prTitle")
$releaseCreateCommand += @('--title', "$prTitle")
Write-Output "Using PR title as release name: [$prTitle]"
} else {
$releaseCreateCommand += @("--title", "$newVersion")
$releaseCreateCommand += @('--title', "$newVersion")
}

# Add notes parameter
$notes = ''
if ($usePRTitleAsNotesHeading) {
$prTitle = $pull_request.title
$prNumber = $pull_request.number
$notes += "# $prTitle (#$prNumber)`n`n"
}
if ($usePRBodyAsReleaseNotes) {
$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'
$notes += $prBody
}
if (-not [string]::IsNullOrWhiteSpace($notes)) {
$releaseCreateCommand += @('--notes', $notes)
} else {
$releaseCreateCommand += '--generate-notes'
}

if ($whatIf) {
Write-Output "WhatIf: $releaseCreateCommand"
} else {
# Execute the command
Write-Output "gh $($releaseCreateCommand -join ' ')"
if (-not $whatIf) {
gh @releaseCreateCommand
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create the release [$newVersion]."
Expand Down
Loading