Skip to content

Commit e3fd1d6

Browse files
Refactor prerelease label handling in job run conditions
1 parent d33ef57 commit e3fd1d6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

scripts/main.ps1

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,12 @@ LogGroup 'Calculate Job Run Conditions:' {
224224
$isMergedPR = $isPR -and $pullRequestAction -eq 'closed' -and $pullRequestIsMerged -eq $true
225225
$isNotAbandonedPR = -not $isAbandonedPR
226226

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

235234
# Determine ReleaseType - what type of release to create
236235
# Values: 'Release', 'Prerelease', 'None'
@@ -246,10 +245,12 @@ LogGroup 'Calculate Job Run Conditions:' {
246245
[pscustomobject]@{
247246
isPR = $isPR
248247
isOpenOrUpdatedPR = $isOpenOrUpdatedPR
248+
isOpenOrLabeledPR = $isOpenOrLabeledPR
249249
isAbandonedPR = $isAbandonedPR
250250
isMergedPR = $isMergedPR
251251
isNotAbandonedPR = $isNotAbandonedPR
252252
isTargetDefaultBranch = $isTargetDefaultBranch
253+
hasPrereleaseLabel = $hasPrereleaseLabel
253254
shouldPrerelease = $shouldPrerelease
254255
ReleaseType = $releaseType
255256
} | Format-List | Out-String

0 commit comments

Comments
 (0)