Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions scripts/Settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@
"type": "string",
"description": "Comma-separated labels that prevent release"
},
"PrereleaseLabels": {
"type": "string",
"description": "Comma-separated labels that trigger a prerelease"
},
"UsePRTitleAsReleaseName": {
"type": "boolean",
"description": "Use pull request title as the GitHub release name"
Expand Down Expand Up @@ -328,6 +332,11 @@
"type": "boolean",
"description": "Publish the module"
},
"ReleaseType": {
"type": "string",
"enum": ["Release", "Prerelease", "Cleanup", "None"],
"description": "The type of release to create: Release (stable), Prerelease, Cleanup (delete old prereleases), or None"
},
"BuildDocs": {
"type": "boolean",
"description": "Build documentation"
Expand Down
28 changes: 27 additions & 1 deletion scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ $settings = [pscustomobject]@{
MinorLabels = $settings.Publish.Module.MinorLabels ?? 'minor, feature'
PatchLabels = $settings.Publish.Module.PatchLabels ?? 'patch, fix'
IgnoreLabels = $settings.Publish.Module.IgnoreLabels ?? 'NoRelease'
PrereleaseLabels = $settings.Publish.Module.PrereleaseLabels ?? 'prerelease'
UsePRTitleAsReleaseName = $settings.Publish.Module.UsePRTitleAsReleaseName ?? $false
UsePRBodyAsReleaseNotes = $settings.Publish.Module.UsePRBodyAsReleaseNotes ?? $true
UsePRTitleAsNotesHeading = $settings.Publish.Module.UsePRTitleAsNotesHeading ?? $true
Expand Down Expand Up @@ -243,12 +244,36 @@ LogGroup 'Calculate Job Run Conditions:' {
$isMergedPR = $isPR -and $pullRequestAction -eq 'closed' -and $pullRequestIsMerged -eq $true
$isNotAbandonedPR = -not $isAbandonedPR

# Check if a prerelease label was added or exists on the PR
$prereleaseLabels = $settings.Publish.Module.PrereleaseLabels -split ',' | ForEach-Object { $_.Trim() }
$prLabels = @($pullRequest.labels.name)
$hasPrereleaseLabel = ($prLabels | Where-Object { $prereleaseLabels -contains $_ }).Count -gt 0
$labelName = $eventData.Label.name
$isPrereleaseLabeled = $pullRequestAction -eq 'labeled' -and ($prereleaseLabels -contains $labelName)
$shouldPrerelease = $isPR -and (($isOpenOrUpdatedPR -and $hasPrereleaseLabel) -or $isPrereleaseLabeled)

# Determine ReleaseType - single source of truth for what Publish-PSModule should do
# Values: 'Release', 'Prerelease', 'Cleanup', 'None'
$releaseType = if (-not $isPR) {
'None'
} elseif ($isMergedPR) {
'Release'
} elseif ($isAbandonedPR) {
'Cleanup'
} elseif ($shouldPrerelease) {
'Prerelease'
} else {
'None'
}

[pscustomobject]@{
isPR = $isPR
isOpenOrUpdatedPR = $isOpenOrUpdatedPR
isAbandonedPR = $isAbandonedPR
isMergedPR = $isMergedPR
isNotAbandonedPR = $isNotAbandonedPR
shouldPrerelease = $shouldPrerelease
ReleaseType = $releaseType
} | Format-List | Out-String
}

Expand Down Expand Up @@ -438,7 +463,8 @@ LogGroup 'Calculate Job Run Conditions:' {
GetCodeCoverage = $isNotAbandonedPR -and (-not $settings.Test.CodeCoverage.Skip) -and (
($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module)
)
PublishModule = $isPR -and ($isAbandonedPR -or ($isOpenOrUpdatedPR -or $isMergedPR))
PublishModule = $releaseType -ne 'None'
ReleaseType = $releaseType # 'Release', 'Prerelease', 'Cleanup', or 'None'
BuildDocs = $isNotAbandonedPR -and (-not $settings.Build.Docs.Skip)
BuildSite = $isNotAbandonedPR -and (-not $settings.Build.Site.Skip)
PublishSite = $isMergedPR
Expand Down
Loading