Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions scripts/Settings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
},
"AutoCleanup": {
Comment thread
MariusStorhaug marked this conversation as resolved.
"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",
Expand Down Expand Up @@ -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."
Comment thread
MariusStorhaug marked this conversation as resolved.
}
}
}
Expand Down Expand Up @@ -332,11 +341,6 @@
"type": "boolean",
"description": "Publish the module"
},
"ReleaseType": {
"type": "string",
"enum": ["Release", "Prerelease", "Cleanup", "None"],
"description": "The type of release to create: Release (stable), Prerelease, Cleanup (delete old prereleases), or None"
},
"BuildDocs": {
"type": "boolean",
"description": "Build documentation"
Expand Down
25 changes: 13 additions & 12 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 AutoCleanup
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$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 {
Expand Down Expand Up @@ -431,6 +425,14 @@ 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 AutoCleanup enabled (defaults to true)
Comment thread
MariusStorhaug marked this conversation as resolved.
Comment thread
MariusStorhaug marked this conversation as resolved.
$shouldAutoCleanup = (($releaseType -eq 'Release') -or $isAbandonedPR) -and ($settings.Publish.Module.AutoCleanup -eq $true)
Comment thread
MariusStorhaug marked this conversation as resolved.
Comment thread
MariusStorhaug marked this conversation as resolved.

# Update Publish.Module with computed release values
$settings.Publish.Module | Add-Member -MemberType NoteProperty -Name ReleaseType -Value $releaseType -Force
$settings.Publish.Module.AutoCleanup = $shouldAutoCleanup
Comment thread
MariusStorhaug marked this conversation as resolved.
Comment thread
MariusStorhaug marked this conversation as resolved.

# Create Run object with all job-specific conditions
$run = [pscustomobject]@{
LintRepository = $isOpenOrUpdatedPR -and (-not $settings.Linter.Skip)
Expand All @@ -447,8 +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'
ReleaseType = $releaseType # 'Release', 'Prerelease', 'Cleanup', or 'None'
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
Expand Down
3 changes: 2 additions & 1 deletion tests/scenarios/invalid-percent-target/PSModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Test:
CodeCoverage:
PercentTarget: 101
Publish:
AutoCleanup: false
Module:
CleanupPrereleases: false
Linter:
env:
VALIDATE_BIOME_FORMAT: false
Expand Down
3 changes: 2 additions & 1 deletion tests/scenarios/valid/PSModule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Test:
CodeCoverage:
PercentTarget: 1
Publish:
AutoCleanup: false
Module:
CleanupPrereleases: false
Linter:
env:
VALIDATE_BIOME_FORMAT: false
Expand Down
Loading