Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
68919b7
Add ReleaseType input for explicit release control
MariusStorhaug Jan 18, 2026
2f56a03
Make ReleaseType required and remove autodetection fallback
MariusStorhaug Jan 18, 2026
9d1cc76
Update for PR
MariusStorhaug Jan 18, 2026
d405e6b
Add warning for WhatIf mode in Publish-PSModule function
MariusStorhaug Jan 18, 2026
8f40324
Update scripts/helpers/Publish-PSModule.ps1
MariusStorhaug Jan 18, 2026
958ddab
Validate ReleaseType input to ensure it is provided and valid, updati…
MariusStorhaug Jan 18, 2026
b6b4e9c
Merge branch 'feature/releasetype-input' of https://github.com/PSModu…
MariusStorhaug Jan 18, 2026
6dc9cd1
Improve warning message for WhatIf mode in Publish-PSModule function …
MariusStorhaug Jan 18, 2026
f5e1a40
Rename AutoCleanup to CleanupPrereleases and remove Cleanup from Rele…
MariusStorhaug Jan 18, 2026
de0ed31
Refactor publishing workflow:
MariusStorhaug Jan 18, 2026
19f2e0a
Add step to update Microsoft.PowerShell.PSResourceGet and update down…
MariusStorhaug Jan 18, 2026
ad87f5e
Refactor environment variable storage to use GITHUB_ENV and improve o…
MariusStorhaug Jan 18, 2026
36cbceb
Refactor cleanup input handling: rename CleanupPrereleases to AutoCle…
MariusStorhaug Jan 18, 2026
695752f
Fix error message to reference init.ps1 instead of main.ps1 for missi…
MariusStorhaug Jan 18, 2026
4c96fb4
Remove dependency installation logic for PSSemVer from publish script…
MariusStorhaug Jan 18, 2026
600e0f3
Enhance ReleaseType validation and version bump logic for improved er…
MariusStorhaug Jan 18, 2026
11e4fe6
Fix typos in descriptions for AutoCleanup and AutoPatching inputs in …
MariusStorhaug Jan 18, 2026
c495e6a
Fix error message to reference init.ps1 for missing PUBLISH_CONTEXT_N…
MariusStorhaug Jan 18, 2026
f4bd288
Add module artifact upload step to Action-Test workflow
MariusStorhaug Jan 18, 2026
d5fb369
Update PR comment messages for clarity and consistency in publish script
MariusStorhaug Jan 18, 2026
651597c
Refactor logging regions in init.ps1 and cleanup.ps1 for improved rea…
MariusStorhaug Jan 18, 2026
9a630d8
Fix exit code in publish script to ensure consistent error handling
MariusStorhaug Jan 18, 2026
c4adf94
Add Import-Module 'Helpers' to cleanup and init scripts for consistency
MariusStorhaug Jan 18, 2026
dfe5b08
Update publish script to mask API key in output for security
MariusStorhaug Jan 18, 2026
d5eff73
Refactor release type calculation for clarity and accuracy in init.ps1
MariusStorhaug Jan 18, 2026
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
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ inputs:
description: A comma separated list of labels that do not trigger a release.
required: false
default: NoRelease
ReleaseType:
description: The type of release to create. Values are 'Release' (stable), 'Prerelease', 'Cleanup' (delete old prereleases), or 'None'.
required: false
default: Release
Comment thread
MariusStorhaug marked this conversation as resolved.
WhatIf:
description: If specified, the action will only log the changes it would make, but will not actually create or delete any releases or tags.
required: false
Expand Down Expand Up @@ -87,6 +91,7 @@ runs:
PSMODULE_PUBLISH_PSMODULE_INPUT_AutoPatching: ${{ inputs.AutoPatching }}
PSMODULE_PUBLISH_PSMODULE_INPUT_DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }}
PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels: ${{ inputs.IgnoreLabels }}
PSMODULE_PUBLISH_PSMODULE_INPUT_ReleaseType: ${{ inputs.ReleaseType }}
PSMODULE_PUBLISH_PSMODULE_INPUT_IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }}
PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels: ${{ inputs.MajorLabels }}
PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels: ${{ inputs.MinorLabels }}
Expand Down
54 changes: 32 additions & 22 deletions scripts/helpers/Publish-PSModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,18 @@
$versionPrefix = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix
$whatIf = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true'
$ignoreLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_IgnoreLabels -split ',' | ForEach-Object { $_.Trim() }
$releaseType = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_ReleaseType # 'Release', 'Prerelease', 'Cleanup', or 'None'
$majorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MajorLabels -split ',' | ForEach-Object { $_.Trim() }
$minorLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_MinorLabels -split ',' | ForEach-Object { $_.Trim() }
$patchLabels = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_PatchLabels -split ',' | ForEach-Object { $_.Trim() }
$usePRBodyAsReleaseNotes = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRBodyAsReleaseNotes -eq 'true'
$usePRTitleAsReleaseName = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsReleaseName -eq 'true'
$usePRTitleAsNotesHeading = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_UsePRTitleAsNotesHeading -eq 'true'

if ($whatIf) {
Write-Host '::warning::WhatIf mode is enabled. No actual releases will be created, no modules will be published, and no tags will be deleted.'
}

[pscustomobject]@{
AutoCleanup = $autoCleanup
AutoPatching = $autoPatching
Expand All @@ -60,6 +65,7 @@
VersionPrefix = $versionPrefix
WhatIf = $whatIf
IgnoreLabels = $ignoreLabels
ReleaseType = $releaseType
MajorLabels = $majorLabels
MinorLabels = $minorLabels
PatchLabels = $patchLabels
Expand All @@ -81,28 +87,14 @@
}

Set-GitHubLogGroup 'Event information - Details' {
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$defaultBranchName = (gh repo view --json defaultBranchRef | ConvertFrom-Json | Select-Object -ExpandProperty defaultBranchRef).name
$isPullRequest = $githubEvent.PSObject.Properties.Name -contains 'pull_request'
if (-not ($isPullRequest -or $whatIf)) {
Write-Warning '⚠️ A release should not be created in this context. Exiting.'
exit
if (-not $pull_request) {
throw 'GitHub event does not contain pull_request data. This script must be run from a pull_request event.'
}
$actionType = $githubEvent.action
$isMerged = $pull_request.merged -eq 'True'
$prIsClosed = $pull_request.state -eq 'closed'
$prBaseRef = $pull_request.base.ref
$prHeadRef = $pull_request.head.ref
$targetIsDefaultBranch = $pull_request.base.ref -eq $defaultBranchName

Write-Output '-------------------------------------------------'
Write-Output "Default branch: [$defaultBranchName]"
Write-Output "Is a pull request event: [$isPullRequest]"
Write-Output "Action type: [$actionType]"
Write-Output "PR Merged: [$isMerged]"
Write-Output "PR Closed: [$prIsClosed]"
Write-Output "PR Base Ref: [$prBaseRef]"
Write-Output "PR Head Ref: [$prHeadRef]"
Write-Output "Target is default branch: [$targetIsDefaultBranch]"
Write-Output "ReleaseType: [$releaseType]"
Write-Output '-------------------------------------------------'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
}

Expand All @@ -117,14 +109,31 @@
}

Set-GitHubLogGroup 'Calculate release type' {
$createRelease = $isMerged -and $targetIsDefaultBranch
$closedPullRequest = $prIsClosed -and -not $isMerged
$createPrerelease = $labels -contains 'prerelease' -and -not $createRelease -and -not $closedPullRequest
$prereleaseName = $prHeadRef -replace '[^a-zA-Z0-9]'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated

# Validate ReleaseType - must be provided by Get-PSModuleSettings
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$validReleaseTypes = @('Release', 'Prerelease', 'Cleanup', 'None')
if ([string]::IsNullOrWhiteSpace($releaseType)) {
Write-Error "ReleaseType input is required. Valid values are: $($validReleaseTypes -join ', ')"
exit 1
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
}
if ($releaseType -notin $validReleaseTypes) {
Write-Error "Invalid ReleaseType: [$releaseType]. Valid values are: $($validReleaseTypes -join ', ')"
exit 1
}

$createRelease = $releaseType -eq 'Release'
$createPrerelease = $releaseType -eq 'Prerelease'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$closedPullRequest = $releaseType -eq 'Cleanup'
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated

if ($releaseType -eq 'None') {
Write-Output 'ReleaseType is None. Skipping release creation.'
return
}
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated

Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
$ignoreRelease = ($labels | Where-Object { $ignoreLabels -contains $_ }).Count -gt 0
if ($ignoreRelease) {
Write-Output 'Ignoring release creation.'
Write-Output 'Ignoring release creation due to ignore label.'
return
}

Expand All @@ -135,12 +144,13 @@
).Count -gt 0 -or $autoPatching) -and -not $majorRelease -and -not $minorRelease

Write-Output '-------------------------------------------------'
Write-Output "ReleaseType: [$releaseType]"
Write-Output "Create a release: [$createRelease]"
Write-Output "Create a prerelease: [$createPrerelease]"
Write-Output "Create a major release: [$majorRelease]"
Write-Output "Create a minor release: [$minorRelease]"
Write-Output "Create a patch release: [$patchRelease]"
Write-Output "Closed pull request: [$closedPullRequest]"
Write-Output "Cleanup prereleases: [$closedPullRequest]"
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
Write-Output '-------------------------------------------------'
}

Expand Down
Loading