From d78716383381d34cea98bd28913aa6233e7ef484 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 04:45:59 +0100 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20AutoClea?= =?UTF-8?q?nup=20to=20CleanupPrereleases=20and=20update=20descriptions=20i?= =?UTF-8?q?n=20schema=20and=20related=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Settings.schema.json | 11 +++++--- scripts/main.ps1 | 25 +++++++++---------- .../invalid-percent-target/PSModule.yml | 3 ++- tests/scenarios/valid/PSModule.yml | 3 ++- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/scripts/Settings.schema.json b/scripts/Settings.schema.json index d35a11e..54fde7f 100644 --- a/scripts/Settings.schema.json +++ b/scripts/Settings.schema.json @@ -126,9 +126,9 @@ "type": "boolean", "description": "Skip module publish" }, - "AutoCleanup": { + "CleanupPrereleases": { "type": "boolean", - "description": "Automatically cleanup after publish" + "description": "When enabled (default: true), automatically cleans up old prerelease tags when merging to main or when a PR is abandoned" }, "AutoPatching": { "type": "boolean", @@ -334,7 +334,12 @@ }, "ReleaseType": { "type": "string", - "enum": ["Release", "Prerelease", "Cleanup", "None"], + "enum": [ + "Release", + "Prerelease", + "Cleanup", + "None" + ], "description": "The type of release to create: Release (stable), Prerelease, Cleanup (delete old prereleases), or None" }, "BuildDocs": { diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 1b04145..e96245d 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -163,7 +163,7 @@ $settings = [pscustomobject]@{ Publish = [pscustomobject]@{ Module = [pscustomobject]@{ Skip = $settings.Publish.Module.Skip ?? $false - AutoCleanup = $settings.Publish.Module.AutoCleanup ?? $true + CleanupPrereleases = $settings.Publish.Module.CleanupPrereleases ?? $true AutoPatching = $settings.Publish.Module.AutoPatching ?? $true IncrementalPrerelease = $settings.Publish.Module.IncrementalPrerelease ?? $true DatePrereleaseFormat = $settings.Publish.Module.DatePrereleaseFormat ?? '' @@ -232,17 +232,11 @@ LogGroup 'Calculate Job Run Conditions:' { $isPrereleaseLabeled = $pullRequestAction -eq 'labeled' -and ($prereleaseLabels -contains $labelName) $shouldPrerelease = $isPR -and (($isOpenOrUpdatedPR -and $hasPrereleaseLabel) -or $isPrereleaseLabeled) - # Determine ReleaseType - single source of truth for what Publish-PSModule should do - # Values: 'Release', 'Prerelease', 'Cleanup', 'None' - # Release only happens when PR is merged into the default branch - $releaseType = if (-not $isPR) { - 'None' - } elseif ($isMergedPR -and $isTargetDefaultBranch) { + # Determine ReleaseType - what type of release to create + # Values: 'Release', 'Prerelease', 'None' + # Note: Cleanup is a separate decision handled by CleanupPrereleases + $releaseType = if ($isMergedPR -and $isTargetDefaultBranch) { 'Release' - } elseif ($isMergedPR -and -not $isTargetDefaultBranch) { - 'None' # Merged to non-default branch - no release - } elseif ($isAbandonedPR) { - 'Cleanup' } elseif ($shouldPrerelease) { 'Prerelease' } else { @@ -431,6 +425,10 @@ if ($settings.Test.Skip) { # Calculate job-specific conditions and add to settings LogGroup 'Calculate Job Run Conditions:' { + # Calculate if prereleases should be cleaned up: + # True if (Release or Abandoned PR) AND user has CleanupPrereleases enabled (defaults to true) + $shouldCleanupPrereleases = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.CleanupPrereleases -eq $true) + # Create Run object with all job-specific conditions $run = [pscustomobject]@{ LintRepository = $isOpenOrUpdatedPR -and (-not $settings.Linter.Skip) @@ -447,8 +445,9 @@ LogGroup 'Calculate Job Run Conditions:' { GetCodeCoverage = $isNotAbandonedPR -and (-not $settings.Test.CodeCoverage.Skip) -and ( ($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module) ) - PublishModule = $releaseType -ne 'None' - ReleaseType = $releaseType # 'Release', 'Prerelease', 'Cleanup', or 'None' + PublishModule = ($releaseType -ne 'None') -or $shouldCleanupPrereleases + ReleaseType = $releaseType # 'Release', 'Prerelease', or 'None' + CleanupPrereleases = $shouldCleanupPrereleases BuildDocs = $isNotAbandonedPR -and (-not $settings.Build.Docs.Skip) BuildSite = $isNotAbandonedPR -and (-not $settings.Build.Site.Skip) PublishSite = $isMergedPR -and $isTargetDefaultBranch diff --git a/tests/scenarios/invalid-percent-target/PSModule.yml b/tests/scenarios/invalid-percent-target/PSModule.yml index 3349481..9cef3eb 100644 --- a/tests/scenarios/invalid-percent-target/PSModule.yml +++ b/tests/scenarios/invalid-percent-target/PSModule.yml @@ -10,7 +10,8 @@ Test: CodeCoverage: PercentTarget: 101 Publish: - AutoCleanup: false + Module: + CleanupPrereleases: false Linter: env: VALIDATE_BIOME_FORMAT: false diff --git a/tests/scenarios/valid/PSModule.yml b/tests/scenarios/valid/PSModule.yml index ceaf2ff..61d254b 100644 --- a/tests/scenarios/valid/PSModule.yml +++ b/tests/scenarios/valid/PSModule.yml @@ -10,7 +10,8 @@ Test: CodeCoverage: PercentTarget: 1 Publish: - AutoCleanup: false + Module: + CleanupPrereleases: false Linter: env: VALIDATE_BIOME_FORMAT: false From a02369c40cba3594e361d88ff40aa5432bdcc218 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 10:36:21 +0100 Subject: [PATCH 2/9] Move ReleaseType and computed CleanupPrereleases to Publish.Module section --- scripts/main.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index e96245d..ff13d0c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -429,6 +429,10 @@ LogGroup 'Calculate Job Run Conditions:' { # True if (Release or Abandoned PR) AND user has CleanupPrereleases enabled (defaults to true) $shouldCleanupPrereleases = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.CleanupPrereleases -eq $true) + # Update Publish.Module with computed release values + $settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force + $settings.Publish.Module.CleanupPrereleases = $shouldCleanupPrereleases + # Create Run object with all job-specific conditions $run = [pscustomobject]@{ LintRepository = $isOpenOrUpdatedPR -and (-not $settings.Linter.Skip) @@ -446,8 +450,6 @@ LogGroup 'Calculate Job Run Conditions:' { ($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module) ) PublishModule = ($releaseType -ne 'None') -or $shouldCleanupPrereleases - ReleaseType = $releaseType # 'Release', 'Prerelease', or 'None' - CleanupPrereleases = $shouldCleanupPrereleases BuildDocs = $isNotAbandonedPR -and (-not $settings.Build.Docs.Skip) BuildSite = $isNotAbandonedPR -and (-not $settings.Build.Site.Skip) PublishSite = $isMergedPR -and $isTargetDefaultBranch From ab7eac23d1f62f179fc23960d07f567720c19963 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 10:56:21 +0100 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20'Cleanup?= =?UTF-8?q?'=20option=20from=20ReleaseType=20enum=20and=20update=20descrip?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Settings.schema.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/Settings.schema.json b/scripts/Settings.schema.json index 54fde7f..787469c 100644 --- a/scripts/Settings.schema.json +++ b/scripts/Settings.schema.json @@ -337,10 +337,9 @@ "enum": [ "Release", "Prerelease", - "Cleanup", "None" ], - "description": "The type of release to create: Release (stable), Prerelease, Cleanup (delete old prereleases), or None" + "description": "The type of release to create: Release (stable), Prerelease, or None." }, "BuildDocs": { "type": "boolean", From f73e0bc876e4946b4ef9bb4177bfedaf1f0738ec Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 11:22:41 +0100 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20ReleaseType?= =?UTF-8?q?=20property=20to=20settings=20schema=20and=20remove=20duplicate?= =?UTF-8?q?=20definition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Settings.schema.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/Settings.schema.json b/scripts/Settings.schema.json index 787469c..da7d470 100644 --- a/scripts/Settings.schema.json +++ b/scripts/Settings.schema.json @@ -177,6 +177,15 @@ "UsePRTitleAsNotesHeading": { "type": "boolean", "description": "Add pull request title as H1 heading in release notes" + }, + "ReleaseType": { + "type": "string", + "enum": [ + "Release", + "Prerelease", + "None" + ], + "description": "The type of release to create: Release (stable), Prerelease, or None." } } } @@ -332,15 +341,6 @@ "type": "boolean", "description": "Publish the module" }, - "ReleaseType": { - "type": "string", - "enum": [ - "Release", - "Prerelease", - "None" - ], - "description": "The type of release to create: Release (stable), Prerelease, or None." - }, "BuildDocs": { "type": "boolean", "description": "Build documentation" From 152eb8f013a4524ef65b54a9c6f053d4515b66f3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 13:41:10 +0100 Subject: [PATCH 5/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20CleanupP?= =?UTF-8?q?rereleases=20to=20AutoCleanup=20and=20update=20related=20logic?= =?UTF-8?q?=20in=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ff13d0c..6c9e769 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -163,7 +163,7 @@ $settings = [pscustomobject]@{ Publish = [pscustomobject]@{ Module = [pscustomobject]@{ Skip = $settings.Publish.Module.Skip ?? $false - CleanupPrereleases = $settings.Publish.Module.CleanupPrereleases ?? $true + AutoCleanup = $settings.Publish.Module.AutoCleanup ?? $true AutoPatching = $settings.Publish.Module.AutoPatching ?? $true IncrementalPrerelease = $settings.Publish.Module.IncrementalPrerelease ?? $true DatePrereleaseFormat = $settings.Publish.Module.DatePrereleaseFormat ?? '' @@ -234,7 +234,7 @@ LogGroup 'Calculate Job Run Conditions:' { # Determine ReleaseType - what type of release to create # Values: 'Release', 'Prerelease', 'None' - # Note: Cleanup is a separate decision handled by CleanupPrereleases + # Note: Cleanup is a separate decision handled by AutoCleanup $releaseType = if ($isMergedPR -and $isTargetDefaultBranch) { 'Release' } elseif ($shouldPrerelease) { @@ -426,12 +426,12 @@ if ($settings.Test.Skip) { # Calculate job-specific conditions and add to settings LogGroup 'Calculate Job Run Conditions:' { # Calculate if prereleases should be cleaned up: - # True if (Release or Abandoned PR) AND user has CleanupPrereleases enabled (defaults to true) - $shouldCleanupPrereleases = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.CleanupPrereleases -eq $true) + # True if (Release or Abandoned PR) AND user has AutoCleanup enabled (defaults to true) + $shouldAutoCleanup = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.AutoCleanup -eq $true) # Update Publish.Module with computed release values $settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force - $settings.Publish.Module.CleanupPrereleases = $shouldCleanupPrereleases + $settings.Publish.Module.AutoCleanup = $shouldAutoCleanup # Create Run object with all job-specific conditions $run = [pscustomobject]@{ @@ -449,7 +449,7 @@ LogGroup 'Calculate Job Run Conditions:' { GetCodeCoverage = $isNotAbandonedPR -and (-not $settings.Test.CodeCoverage.Skip) -and ( ($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module) ) - PublishModule = ($releaseType -ne 'None') -or $shouldCleanupPrereleases + PublishModule = ($releaseType -ne 'None') -or $shouldAutoCleanup BuildDocs = $isNotAbandonedPR -and (-not $settings.Build.Docs.Skip) BuildSite = $isNotAbandonedPR -and (-not $settings.Build.Site.Skip) PublishSite = $isMergedPR -and $isTargetDefaultBranch From d33ef57584191d2c9f8ae87111f8761286d1089a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 13:42:58 +0100 Subject: [PATCH 6/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20CleanupP?= =?UTF-8?q?rereleases=20to=20AutoCleanup=20in=20settings=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Settings.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Settings.schema.json b/scripts/Settings.schema.json index da7d470..898b5d3 100644 --- a/scripts/Settings.schema.json +++ b/scripts/Settings.schema.json @@ -126,7 +126,7 @@ "type": "boolean", "description": "Skip module publish" }, - "CleanupPrereleases": { + "AutoCleanup": { "type": "boolean", "description": "When enabled (default: true), automatically cleans up old prerelease tags when merging to main or when a PR is abandoned" }, From e3fd1d6ee94d132fd23f233f7b4cde8cee9c61ad Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 13:55:10 +0100 Subject: [PATCH 7/9] Refactor prerelease label handling in job run conditions --- scripts/main.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 6c9e769..0ff7762 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -224,13 +224,12 @@ LogGroup 'Calculate Job Run Conditions:' { $isMergedPR = $isPR -and $pullRequestAction -eq 'closed' -and $pullRequestIsMerged -eq $true $isNotAbandonedPR = -not $isAbandonedPR - # Check if a prerelease label was added or exists on the PR + # 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 - $labelName = $eventData.Label.name - $isPrereleaseLabeled = $pullRequestAction -eq 'labeled' -and ($prereleaseLabels -contains $labelName) - $shouldPrerelease = $isPR -and (($isOpenOrUpdatedPR -and $hasPrereleaseLabel) -or $isPrereleaseLabeled) + $isOpenOrLabeledPR = $isPR -and $pullRequestAction -in @('opened', 'reopened', 'synchronize', 'labeled') + $shouldPrerelease = $isOpenOrLabeledPR -and $hasPrereleaseLabel # Determine ReleaseType - what type of release to create # Values: 'Release', 'Prerelease', 'None' @@ -246,10 +245,12 @@ LogGroup 'Calculate Job Run Conditions:' { [pscustomobject]@{ isPR = $isPR isOpenOrUpdatedPR = $isOpenOrUpdatedPR + isOpenOrLabeledPR = $isOpenOrLabeledPR isAbandonedPR = $isAbandonedPR isMergedPR = $isMergedPR isNotAbandonedPR = $isNotAbandonedPR isTargetDefaultBranch = $isTargetDefaultBranch + hasPrereleaseLabel = $hasPrereleaseLabel shouldPrerelease = $shouldPrerelease ReleaseType = $releaseType } | Format-List | Out-String From 21c61c66c8c5bb1099a9ce67ffa332788544f908 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 14:53:41 +0100 Subject: [PATCH 8/9] Keep AutoCleanup name instead of renaming to CleanupPrereleases --- tests/scenarios/invalid-percent-target/PSModule.yml | 2 +- tests/scenarios/valid/PSModule.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/scenarios/invalid-percent-target/PSModule.yml b/tests/scenarios/invalid-percent-target/PSModule.yml index 9cef3eb..e60825a 100644 --- a/tests/scenarios/invalid-percent-target/PSModule.yml +++ b/tests/scenarios/invalid-percent-target/PSModule.yml @@ -11,7 +11,7 @@ Test: PercentTarget: 101 Publish: Module: - CleanupPrereleases: false + AutoCleanup: false Linter: env: VALIDATE_BIOME_FORMAT: false diff --git a/tests/scenarios/valid/PSModule.yml b/tests/scenarios/valid/PSModule.yml index 61d254b..4ecb911 100644 --- a/tests/scenarios/valid/PSModule.yml +++ b/tests/scenarios/valid/PSModule.yml @@ -11,7 +11,7 @@ Test: PercentTarget: 1 Publish: Module: - CleanupPrereleases: false + AutoCleanup: false Linter: env: VALIDATE_BIOME_FORMAT: false From c4f041bde47b4bd92b5ae59004773056b4e9214a Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 18 Jan 2026 14:59:41 +0100 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20note=20a?= =?UTF-8?q?bout=20Cleanup=20handling=20in=20release=20type=20determination?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 0ff7762..c7bbdb7 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -233,7 +233,6 @@ LogGroup 'Calculate Job Run Conditions:' { # Determine ReleaseType - what type of release to create # Values: 'Release', 'Prerelease', 'None' - # Note: Cleanup is a separate decision handled by AutoCleanup $releaseType = if ($isMergedPR -and $isTargetDefaultBranch) { 'Release' } elseif ($shouldPrerelease) {