Skip to content

Commit abc4d30

Browse files
🩹 [Patch]: Refactor prerelease label handling in job run conditions
1 parent 9b11d08 commit abc4d30

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

scripts/main.ps1

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ LogGroup 'Calculate Job Run Conditions:' {
249249
$prLabels = @($pullRequest.labels.name)
250250
$hasPrereleaseLabel = ($prLabels | Where-Object { $prereleaseLabels -contains $_ }).Count -gt 0
251251
$labelName = $eventData.Label.name
252-
$isPrereleaseLabeled = $isPR -and $pullRequestAction -eq 'labeled' -and ($prereleaseLabels -contains $labelName)
252+
$isPrereleaseLabeled = $pullRequestAction -eq 'labeled' -and ($prereleaseLabels -contains $labelName)
253+
$shouldPrerelease = $isPR -and (($isOpenOrUpdatedPR -and $hasPrereleaseLabel) -or $isPrereleaseLabeled)
253254

254255
# Determine ReleaseType - single source of truth for what Publish-PSModule should do
255256
# Values: 'Release', 'Prerelease', 'Cleanup', 'None'
@@ -259,23 +260,20 @@ LogGroup 'Calculate Job Run Conditions:' {
259260
'Release'
260261
} elseif ($isAbandonedPR) {
261262
'Cleanup'
262-
} elseif ($isOpenOrUpdatedPR -and $hasPrereleaseLabel) {
263-
'Prerelease'
264-
} elseif ($isPrereleaseLabeled) {
263+
} elseif ($shouldPrerelease) {
265264
'Prerelease'
266265
} else {
267266
'None'
268267
}
269268

270269
[pscustomobject]@{
271-
isPR = $isPR
272-
isOpenOrUpdatedPR = $isOpenOrUpdatedPR
273-
isAbandonedPR = $isAbandonedPR
274-
isMergedPR = $isMergedPR
275-
isNotAbandonedPR = $isNotAbandonedPR
276-
hasPrereleaseLabel = $hasPrereleaseLabel
277-
isPrereleaseLabeled = $isPrereleaseLabeled
278-
ReleaseType = $releaseType
270+
isPR = $isPR
271+
isOpenOrUpdatedPR = $isOpenOrUpdatedPR
272+
isAbandonedPR = $isAbandonedPR
273+
isMergedPR = $isMergedPR
274+
isNotAbandonedPR = $isNotAbandonedPR
275+
shouldPrerelease = $shouldPrerelease
276+
ReleaseType = $releaseType
279277
} | Format-List | Out-String
280278
}
281279

0 commit comments

Comments
 (0)