Skip to content

Commit 41fe3eb

Browse files
Restore Prerelease label gate; add PrereleaseLabels config and ignore label early-exit
1 parent b0a7372 commit 41fe3eb

1 file changed

Lines changed: 19 additions & 21 deletions

File tree

src/main.ps1

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ $settings = [pscustomobject]@{
196196
MajorLabels = $settings.Publish.Module.MajorLabels ?? 'major, breaking'
197197
MinorLabels = $settings.Publish.Module.MinorLabels ?? 'minor, feature'
198198
PatchLabels = $settings.Publish.Module.PatchLabels ?? 'patch, fix'
199+
PrereleaseLabels = $settings.Publish.Module.PrereleaseLabels ?? 'Prerelease'
199200
IgnoreLabels = $settings.Publish.Module.IgnoreLabels ?? 'NoRelease'
200201
UsePRTitleAsReleaseName = $settings.Publish.Module.UsePRTitleAsReleaseName ?? $false
201202
UsePRBodyAsReleaseNotes = $settings.Publish.Module.UsePRBodyAsReleaseNotes ?? $true
@@ -335,17 +336,15 @@ If you believe this is incorrect, please verify that your changes are in the cor
335336

336337
# Evaluate PR labels against configured label lists
337338
$prLabels = @($pullRequest.Labels | ForEach-Object { $_.Name })
339+
$prereleaseLabels = ($settings.Publish.Module.PrereleaseLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }
338340
$ignoreLabels = ($settings.Publish.Module.IgnoreLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }
339-
$majorLabels = ($settings.Publish.Module.MajorLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }
340-
$minorLabels = ($settings.Publish.Module.MinorLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }
341-
$patchLabels = ($settings.Publish.Module.PatchLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ }
342341

342+
$hasPrereleaseLabel = ($prLabels | Where-Object { $prereleaseLabels -contains $_ }).Count -gt 0
343343
$hasIgnoreLabel = ($prLabels | Where-Object { $ignoreLabels -contains $_ }).Count -gt 0
344-
$hasVersionBumpLabel = ($prLabels | Where-Object { ($majorLabels + $minorLabels + $patchLabels) -contains $_ }).Count -gt 0
345-
$hasVersionBumpOrAutoPatch = $settings.Publish.Module.AutoPatching -or $hasVersionBumpLabel
346344

347-
# Prerelease: open PR with important changes, not opted out, and either AutoPatching or an explicit version bump label.
348-
$shouldPrerelease = $isOpenOrLabeledPR -and $hasImportantChanges -and $hasVersionBumpOrAutoPatch -and -not $hasIgnoreLabel
345+
# Prerelease: open PR with the Prerelease label, important changes, and not opted out via ignore label.
346+
# Version level (patch/minor/major) is determined by Resolve-PSModuleVersion based on version bump labels and AutoPatching.
347+
$shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel -and $hasImportantChanges -and -not $hasIgnoreLabel
349348

350349
# Determine ReleaseType - what type of release to create
351350
# Values: 'Release', 'Prerelease', 'None'
@@ -360,19 +359,18 @@ If you believe this is incorrect, please verify that your changes are in the cor
360359
}
361360

362361
[pscustomobject]@{
363-
isPR = $isPR
364-
isOpenOrUpdatedPR = $isOpenOrUpdatedPR
365-
isOpenOrLabeledPR = $isOpenOrLabeledPR
366-
isAbandonedPR = $isAbandonedPR
367-
isMergedPR = $isMergedPR
368-
isNotAbandonedPR = $isNotAbandonedPR
369-
isTargetDefaultBranch = $isTargetDefaultBranch
370-
hasIgnoreLabel = $hasIgnoreLabel
371-
hasVersionBumpLabel = $hasVersionBumpLabel
372-
hasVersionBumpOrAutoPatch = $hasVersionBumpOrAutoPatch
373-
shouldPrerelease = $shouldPrerelease
374-
ReleaseType = $releaseType
375-
HasImportantChanges = $hasImportantChanges
362+
isPR = $isPR
363+
isOpenOrUpdatedPR = $isOpenOrUpdatedPR
364+
isOpenOrLabeledPR = $isOpenOrLabeledPR
365+
isAbandonedPR = $isAbandonedPR
366+
isMergedPR = $isMergedPR
367+
isNotAbandonedPR = $isNotAbandonedPR
368+
isTargetDefaultBranch = $isTargetDefaultBranch
369+
hasPrereleaseLabel = $hasPrereleaseLabel
370+
hasIgnoreLabel = $hasIgnoreLabel
371+
shouldPrerelease = $shouldPrerelease
372+
ReleaseType = $releaseType
373+
HasImportantChanges = $hasImportantChanges
376374
} | Format-List | Out-String
377375
}
378376

@@ -568,7 +566,7 @@ LogGroup 'Calculate Job Run Conditions:' {
568566
# Check if setup/teardown scripts exist in the repository
569567
$hasBeforeAllScript = Test-Path -Path 'tests/BeforeAll.ps1'
570568
$hasAfterAllScript = Test-Path -Path 'tests/AfterAll.ps1'
571-
Write-Host "Setup/teardown script detection:"
569+
Write-Host 'Setup/teardown script detection:'
572570
Write-Host " tests/BeforeAll.ps1 exists: $hasBeforeAllScript"
573571
Write-Host " tests/AfterAll.ps1 exists: $hasAfterAllScript"
574572

0 commit comments

Comments
 (0)