Skip to content

Commit d787163

Browse files
🩹 [Patch]: Rename AutoCleanup to CleanupPrereleases and update descriptions in schema and related scripts
1 parent 98ce7ab commit d787163

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

‎scripts/Settings.schema.json‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@
126126
"type": "boolean",
127127
"description": "Skip module publish"
128128
},
129-
"AutoCleanup": {
129+
"CleanupPrereleases": {
130130
"type": "boolean",
131-
"description": "Automatically cleanup after publish"
131+
"description": "When enabled (default: true), automatically cleans up old prerelease tags when merging to main or when a PR is abandoned"
132132
},
133133
"AutoPatching": {
134134
"type": "boolean",
@@ -334,7 +334,12 @@
334334
},
335335
"ReleaseType": {
336336
"type": "string",
337-
"enum": ["Release", "Prerelease", "Cleanup", "None"],
337+
"enum": [
338+
"Release",
339+
"Prerelease",
340+
"Cleanup",
341+
"None"
342+
],
338343
"description": "The type of release to create: Release (stable), Prerelease, Cleanup (delete old prereleases), or None"
339344
},
340345
"BuildDocs": {

‎scripts/main.ps1‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ $settings = [pscustomobject]@{
163163
Publish = [pscustomobject]@{
164164
Module = [pscustomobject]@{
165165
Skip = $settings.Publish.Module.Skip ?? $false
166-
AutoCleanup = $settings.Publish.Module.AutoCleanup ?? $true
166+
CleanupPrereleases = $settings.Publish.Module.CleanupPrereleases ?? $true
167167
AutoPatching = $settings.Publish.Module.AutoPatching ?? $true
168168
IncrementalPrerelease = $settings.Publish.Module.IncrementalPrerelease ?? $true
169169
DatePrereleaseFormat = $settings.Publish.Module.DatePrereleaseFormat ?? ''
@@ -232,17 +232,11 @@ LogGroup 'Calculate Job Run Conditions:' {
232232
$isPrereleaseLabeled = $pullRequestAction -eq 'labeled' -and ($prereleaseLabels -contains $labelName)
233233
$shouldPrerelease = $isPR -and (($isOpenOrUpdatedPR -and $hasPrereleaseLabel) -or $isPrereleaseLabeled)
234234

235-
# Determine ReleaseType - single source of truth for what Publish-PSModule should do
236-
# Values: 'Release', 'Prerelease', 'Cleanup', 'None'
237-
# Release only happens when PR is merged into the default branch
238-
$releaseType = if (-not $isPR) {
239-
'None'
240-
} elseif ($isMergedPR -and $isTargetDefaultBranch) {
235+
# Determine ReleaseType - what type of release to create
236+
# Values: 'Release', 'Prerelease', 'None'
237+
# Note: Cleanup is a separate decision handled by CleanupPrereleases
238+
$releaseType = if ($isMergedPR -and $isTargetDefaultBranch) {
241239
'Release'
242-
} elseif ($isMergedPR -and -not $isTargetDefaultBranch) {
243-
'None' # Merged to non-default branch - no release
244-
} elseif ($isAbandonedPR) {
245-
'Cleanup'
246240
} elseif ($shouldPrerelease) {
247241
'Prerelease'
248242
} else {
@@ -431,6 +425,10 @@ if ($settings.Test.Skip) {
431425

432426
# Calculate job-specific conditions and add to settings
433427
LogGroup 'Calculate Job Run Conditions:' {
428+
# Calculate if prereleases should be cleaned up:
429+
# True if (Release or Abandoned PR) AND user has CleanupPrereleases enabled (defaults to true)
430+
$shouldCleanupPrereleases = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.CleanupPrereleases -eq $true)
431+
434432
# Create Run object with all job-specific conditions
435433
$run = [pscustomobject]@{
436434
LintRepository = $isOpenOrUpdatedPR -and (-not $settings.Linter.Skip)
@@ -447,8 +445,9 @@ LogGroup 'Calculate Job Run Conditions:' {
447445
GetCodeCoverage = $isNotAbandonedPR -and (-not $settings.Test.CodeCoverage.Skip) -and (
448446
($null -ne $settings.TestSuites.PSModule) -or ($null -ne $settings.TestSuites.Module)
449447
)
450-
PublishModule = $releaseType -ne 'None'
451-
ReleaseType = $releaseType # 'Release', 'Prerelease', 'Cleanup', or 'None'
448+
PublishModule = ($releaseType -ne 'None') -or $shouldCleanupPrereleases
449+
ReleaseType = $releaseType # 'Release', 'Prerelease', or 'None'
450+
CleanupPrereleases = $shouldCleanupPrereleases
452451
BuildDocs = $isNotAbandonedPR -and (-not $settings.Build.Docs.Skip)
453452
BuildSite = $isNotAbandonedPR -and (-not $settings.Build.Site.Skip)
454453
PublishSite = $isMergedPR -and $isTargetDefaultBranch

‎tests/scenarios/invalid-percent-target/PSModule.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Test:
1010
CodeCoverage:
1111
PercentTarget: 101
1212
Publish:
13-
AutoCleanup: false
13+
Module:
14+
CleanupPrereleases: false
1415
Linter:
1516
env:
1617
VALIDATE_BIOME_FORMAT: false

‎tests/scenarios/valid/PSModule.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ Test:
1010
CodeCoverage:
1111
PercentTarget: 1
1212
Publish:
13-
AutoCleanup: false
13+
Module:
14+
CleanupPrereleases: false
1415
Linter:
1516
env:
1617
VALIDATE_BIOME_FORMAT: false

0 commit comments

Comments
 (0)