diff --git a/src/main.ps1 b/src/main.ps1 index 83ad38a..dbe4868 100644 --- a/src/main.ps1 +++ b/src/main.ps1 @@ -196,8 +196,8 @@ $settings = [pscustomobject]@{ MajorLabels = $settings.Publish.Module.MajorLabels ?? 'major, breaking' MinorLabels = $settings.Publish.Module.MinorLabels ?? 'minor, feature' PatchLabels = $settings.Publish.Module.PatchLabels ?? 'patch, fix' + PrereleaseLabels = $settings.Publish.Module.PrereleaseLabels ?? 'Prerelease' 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 @@ -249,10 +249,6 @@ LogGroup 'Calculate Job Run Conditions:' { $isMergedPR = $isPR -and $pullRequestAction -eq 'closed' -and $pullRequestIsMerged -eq $true $isNotAbandonedPR = -not $isAbandonedPR - # Check if a prerelease label 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 $isOpenOrLabeledPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize', 'labeled') # Check if important files have changed in the PR @@ -338,9 +334,17 @@ If you believe this is incorrect, please verify that your changes are in the cor Write-Host 'Not a PR event or missing PR number - treating as having important changes' } - # Prerelease requires both: prerelease label AND important file changes - # No point creating a prerelease if only non-module files changed - $shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel -and $hasImportantChanges + # Evaluate PR labels against configured label lists + $prLabels = @($pullRequest.Labels | ForEach-Object { $_.Name }) + $prereleaseLabels = ($settings.Publish.Module.PrereleaseLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ } + $ignoreLabels = ($settings.Publish.Module.IgnoreLabels -split ',') | ForEach-Object { $_.Trim() } | Where-Object { $_ } + + $hasPrereleaseLabel = ($prLabels | Where-Object { $prereleaseLabels -contains $_ }).Count -gt 0 + $hasIgnoreLabel = ($prLabels | Where-Object { $ignoreLabels -contains $_ }).Count -gt 0 + + # Prerelease: open PR with the Prerelease label, important changes, and not opted out via ignore label. + # Version level (patch/minor/major) is determined by Resolve-PSModuleVersion based on version bump labels and AutoPatching. + $shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel -and $hasImportantChanges -and -not $hasIgnoreLabel # Determine ReleaseType - what type of release to create # Values: 'Release', 'Prerelease', 'None' @@ -363,6 +367,7 @@ If you believe this is incorrect, please verify that your changes are in the cor isNotAbandonedPR = $isNotAbandonedPR isTargetDefaultBranch = $isTargetDefaultBranch hasPrereleaseLabel = $hasPrereleaseLabel + hasIgnoreLabel = $hasIgnoreLabel shouldPrerelease = $shouldPrerelease ReleaseType = $releaseType HasImportantChanges = $hasImportantChanges @@ -561,7 +566,7 @@ LogGroup 'Calculate Job Run Conditions:' { # Check if setup/teardown scripts exist in the repository $hasBeforeAllScript = Test-Path -Path 'tests/BeforeAll.ps1' $hasAfterAllScript = Test-Path -Path 'tests/AfterAll.ps1' - Write-Host "Setup/teardown script detection:" + Write-Host 'Setup/teardown script detection:' Write-Host " tests/BeforeAll.ps1 exists: $hasBeforeAllScript" Write-Host " tests/AfterAll.ps1 exists: $hasAfterAllScript"