11' powershell-yaml' , ' Hashtable' | Install-PSResource - Repository PSGallery - TrustRepository
2+ Import-Module - Name " $PSScriptRoot /Get-PSModuleSettings.Helpers.psm1" - Force
23
34$name = $env: PSMODULE_GET_SETTINGS_INPUT_Name
45$settingsPath = $env: PSMODULE_GET_SETTINGS_INPUT_SettingsPath
@@ -300,21 +301,17 @@ LogGroup 'Calculate Job Run Conditions:' {
300301 TargetBranch = $targetBranch
301302 DefaultBranch = $defaultBranch
302303 IsTargetDefaultBranch = $isTargetDefaultBranch
303- IsPushToDefaultBranch = $isPushToDefaultBranch
304- AssociatedPullRequest = $pullRequestContext.Number
304+ IsPushToDefaultBranch = $isPushToDefaultBranch
305+ AssociatedPullRequest = $pullRequestContext.Number
305306 } | Format-List | Out-String
306307
307308 $isOpenOrUpdatedPR = $isPR -and $pullRequestAction -in @ (' opened' , ' reopened' , ' synchronize' , ' labeled' , ' unlabeled' )
308- $isClosedPR = $isPR -and $pullRequestAction -eq ' closed'
309- $isAbandonedPR = $isPR -and $pullRequestAction -eq ' closed' -and $pullRequestIsMerged -ne $true
310- $isMergedPR = $isPR -and $pullRequestAction -eq ' closed' -and $pullRequestIsMerged -eq $true
311309 $hasPullRequestContext = $null -ne $pullRequestContext
312310
313311 # Check if a prerelease label exists on the PR
314312 $prereleaseLabels = $settings.Publish.Module.PrereleaseLabels -split ' ,' | ForEach-Object { $_.Trim () }
315313 $prLabels = @ ($pullRequestContext.Labels )
316314 $hasPrereleaseLabel = ($prLabels | Where-Object { $prereleaseLabels -contains $_ }).Count -gt 0
317- $isOpenOrLabeledPR = $isPR -and $pullRequestAction -in @ (' opened' , ' reopened' , ' synchronize' , ' labeled' )
318315
319316 # Check if important files have changed in the PR
320317 # Important files are determined by the configured ImportantFilePatterns setting
@@ -406,35 +403,28 @@ If you believe this is incorrect, please verify that your changes are in the cor
406403 Write-Host ' Non-PR event - treating as having important changes'
407404 }
408405
409- # Prerelease requires both: prerelease label AND important file changes
410- # No point creating a prerelease if only non-module files changed
411- $shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel -and $hasImportantChanges
412-
413- # Determine ReleaseType - what type of release to create
414- # Values: 'Release', 'Prerelease', 'None'
415- # Stable releases are push-driven. A direct push requires explicit opt-in.
416- $releaseType = if (
417- $isPushToDefaultBranch -and
418- $hasImportantChanges -and
419- ($hasPullRequestContext -or $settings.Publish.Module.AllowDirectPushRelease )
420- ) {
421- ' Release'
422- } elseif ($shouldPrerelease ) {
423- ' Prerelease'
424- } else {
425- ' None'
426- }
406+ $routing = Resolve-WorkflowEventRouting - EventName $eventName `
407+ - EventAction $pullRequestAction `
408+ - PullRequestIsMerged $pullRequestIsMerged `
409+ - IsTargetDefaultBranch $isTargetDefaultBranch `
410+ - IsPushToDefaultBranch $isPushToDefaultBranch `
411+ - HasPullRequestContext $hasPullRequestContext `
412+ - HasImportantChanges $hasImportantChanges `
413+ - HasPrereleaseLabel $hasPrereleaseLabel `
414+ - AllowDirectPushRelease $settings.Publish.Module.AllowDirectPushRelease
415+ $shouldPrerelease = $routing.ShouldPrerelease
416+ $releaseType = $routing.ReleaseType
427417
428418 [pscustomobject ]@ {
429- isPR = $isPR
430- isOpenOrUpdatedPR = $isOpenOrUpdatedPR
431- isOpenOrLabeledPR = $isOpenOrLabeledPR
432- isClosedPR = $isClosedPR
433- isAbandonedPR = $isAbandonedPR
434- isMergedPR = $isMergedPR
435- isPush = $isPush
436- isPushToDefaultBranch = $isPushToDefaultBranch
437- isTargetDefaultBranch = $isTargetDefaultBranch
419+ isPR = $routing .IsPR
420+ isOpenOrUpdatedPR = $routing .IsOpenOrUpdatedPR
421+ isOpenOrLabeledPR = $routing .IsOpenOrLabeledPR
422+ isClosedPR = $routing .IsClosedPR
423+ isAbandonedPR = $routing .IsAbandonedPR
424+ isMergedPR = $routing .IsMergedPR
425+ isPush = $routing .IsPush
426+ isPushToDefaultBranch = $routing .IsPushToDefaultBranch
427+ isTargetDefaultBranch = $routing .IsTargetDefaultBranch
438428 hasPullRequestContext = $hasPullRequestContext
439429 hasPrereleaseLabel = $hasPrereleaseLabel
440430 shouldPrerelease = $shouldPrerelease
@@ -607,11 +597,7 @@ $settings.Test.Module | Add-Member -MemberType NoteProperty -Name Suites -Value
607597LogGroup ' Calculate Job Run Conditions:' {
608598 # Calculate if prereleases should be cleaned up:
609599 # Closed PRs only clean up prereleases. Push runs also clean up the associated PR channel.
610- $shouldCleanupEvent = (
611- ($releaseType -eq ' Release' ) -or
612- $isClosedPR -or
613- ($isPushToDefaultBranch -and $hasPullRequestContext )
614- )
600+ $shouldCleanupEvent = $routing.ShouldCleanupEvent
615601 $shouldAutoCleanup = $shouldCleanupEvent -and ($settings.Publish.Module.AutoCleanup -eq $true )
616602
617603 # Update Publish.Module with computed release values
@@ -621,7 +607,7 @@ LogGroup 'Calculate Job Run Conditions:' {
621607 # For open PRs, we only want to run build/test stages if important files changed.
622608 # Closed PR events are cleanup-only. workflow_dispatch and schedule retain build/test behavior.
623609 # Note: $shouldPrerelease already requires $hasImportantChanges, so no separate check needed.
624- $shouldRunBuildTest = ( -not $isClosedPR ) -and $hasImportantChanges
610+ $shouldRunBuildTest = $routing .ShouldRunBuildTest
625611
626612 # Check if setup/teardown scripts exist in the repository
627613 $hasBeforeAllScript = Test-Path - Path ' tests/BeforeAll.ps1'
0 commit comments