-
Notifications
You must be signed in to change notification settings - Fork 0
πͺ² [Fix]: Release tags keep the configured version prefix #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Marius Storhaug (MariusStorhaug)
merged 7 commits into
main
from
fix-version-prefix-release-tag
Aug 3, 2026
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fd2c7d9
Extract release tag derivation into a testable helper
MariusStorhaug d0f8f7a
Add regression test for the version prefix on release tags
MariusStorhaug 06b4714
Apply the configured version prefix to the created release tag
MariusStorhaug 29e2329
Trigger the self-test publish path from the Fix label
MariusStorhaug e20f1d4
Move the self-test publish trigger to the WithManifest fixture
MariusStorhaug 2d23d93
Reset the WithManifest fixture settings
MariusStorhaug f017813
Keep the version prefix on the release tag only
MariusStorhaug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| ο»Ώfunction Get-ReleaseTag { | ||
| <# | ||
| .SYNOPSIS | ||
| Builds the git tag used for the GitHub release. | ||
|
|
||
| .DESCRIPTION | ||
| Composes the release tag from the configured version prefix, the module version, and the | ||
| prerelease label when there is one. The version comes from the compiled manifest, which is the | ||
| artifact that is published, so the tag always names the exact bytes that were tested and pushed | ||
| to the PowerShell Gallery. The manifest's ModuleVersion is Major.Minor.Patch by definition and | ||
| cannot carry the prefix, so the prefix is supplied from the resolved settings | ||
| (Publish.Module.VersionPrefix) instead. An empty prefix produces an unprefixed tag. | ||
|
|
||
| .OUTPUTS | ||
| String with the release tag. | ||
|
|
||
| .EXAMPLE | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' | ||
|
|
||
| Returns 'v1.1.10'. | ||
|
|
||
| .EXAMPLE | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | ||
|
|
||
| Returns 'v1.1.10-mybranch001'. | ||
|
|
||
| .EXAMPLE | ||
| Get-ReleaseTag -VersionPrefix '' -ModuleVersion '1.1.10' | ||
|
|
||
| Returns '1.1.10'. | ||
| #> | ||
| [CmdletBinding()] | ||
| [OutputType([string])] | ||
| param( | ||
| # The module version from the compiled manifest, in Major.Minor.Patch format. | ||
| [Parameter(Mandatory)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string] $ModuleVersion, | ||
|
|
||
| # The prefix put in front of the version, for example 'v'. Empty for an unprefixed repository. | ||
| [Parameter()] | ||
| [AllowEmptyString()] | ||
| [AllowNull()] | ||
| [string] $VersionPrefix, | ||
|
|
||
| # The prerelease label from the compiled manifest. Empty for a stable release. | ||
| [Parameter()] | ||
| [AllowEmptyString()] | ||
| [AllowNull()] | ||
| [string] $Prerelease | ||
| ) | ||
|
|
||
| $tag = "$($VersionPrefix.Trim())$ModuleVersion" | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace($Prerelease)) { | ||
| return $tag | ||
| } | ||
|
|
||
| "$tag-$($Prerelease.Trim())" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
.github/actions/Publish-PSModule/tests/Publish-PSModule.Helpers.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| ο»Ώ[Diagnostics.CodeAnalysis.SuppressMessageAttribute( | ||
| 'PSUseDeclaredVarsMoreThanAssignments', '', | ||
| Justification = 'Variables are assigned in BeforeAll and used inside It blocks.' | ||
| )] | ||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| BeforeAll { | ||
| Import-Module -Name 'PSModule' -Force | ||
| Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../src/Publish-PSModule.Helpers.psm1') -Force | ||
| } | ||
|
|
||
| Describe 'Publish-PSModule.Helpers' { | ||
| Describe 'Get-ReleaseTag' { | ||
| Context 'Get-ReleaseTag - repository with a version prefix' { | ||
| It 'Get-ReleaseTag - prefixes a stable release tag with the configured prefix' { | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' | Should -Be 'v1.1.10' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - prefixes a stable release tag when the prerelease label is empty' { | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease '' | Should -Be 'v1.1.10' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - prefixes a prerelease tag with the configured prefix' { | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | | ||
| Should -Be 'v1.1.10-mybranch001' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - supports a multi-character prefix' { | ||
| Get-ReleaseTag -VersionPrefix 'release-v' -ModuleVersion '2.0.0' | Should -Be 'release-v2.0.0' | ||
| } | ||
| } | ||
|
|
||
| Context 'Get-ReleaseTag - repository without a version prefix' { | ||
| It 'Get-ReleaseTag - leaves a stable release tag unprefixed' { | ||
| Get-ReleaseTag -VersionPrefix '' -ModuleVersion '1.1.10' | Should -Be '1.1.10' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - leaves a prerelease tag unprefixed' { | ||
| Get-ReleaseTag -VersionPrefix '' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | | ||
| Should -Be '1.1.10-mybranch001' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - treats an absent prefix as no prefix' { | ||
| Get-ReleaseTag -ModuleVersion '1.1.10' | Should -Be '1.1.10' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - treats a null prefix as no prefix' { | ||
| Get-ReleaseTag -VersionPrefix $null -ModuleVersion '1.1.10' | Should -Be '1.1.10' | ||
| } | ||
| } | ||
|
|
||
| Context 'Get-ReleaseTag - input normalization' { | ||
| It 'Get-ReleaseTag - trims whitespace around the prefix' { | ||
| Get-ReleaseTag -VersionPrefix ' v ' -ModuleVersion '1.1.10' | Should -Be 'v1.1.10' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - trims whitespace around the prerelease label' { | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease ' mybranch001 ' | | ||
| Should -Be 'v1.1.10-mybranch001' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - treats a whitespace-only prerelease label as a stable release' { | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease ' ' | Should -Be 'v1.1.10' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - requires a module version' { | ||
| { Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '' } | Should -Throw | ||
| } | ||
| } | ||
|
|
||
| # Cleanup-PSModulePrereleases selects the releases to delete with | ||
| # `tagName -like "*$prereleaseName*" -and tagName -ne $publishedReleaseTag`, where the published tag is | ||
| # the value publish.ps1 exports as PSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag. Both halves of that | ||
| # filter have to keep working once the tag carries a prefix. | ||
| Context 'Get-ReleaseTag - AutoCleanup tag matching contract' { | ||
| It 'Get-ReleaseTag - keeps the prerelease name inside a prefixed tag so cleanup still matches it' { | ||
| Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | | ||
| Should -BeLike '*mybranch*' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - keeps the prerelease name inside an unprefixed tag so cleanup still matches it' { | ||
| Get-ReleaseTag -VersionPrefix '' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | | ||
| Should -BeLike '*mybranch*' | ||
| } | ||
|
|
||
| It 'Get-ReleaseTag - produces the same tag twice so cleanup can exclude the published release' { | ||
| $first = Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | ||
| $second = Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' | ||
| $first | Should -Be $second | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,18 @@ | ||
| Name: PSModuleTest2 | ||
| Linter: | ||
| Skip: true | ||
| Publish: | ||
| Module: | ||
| # 'Fix' is here so that Process-PSModule's own self-test exercises the publish path. The framework | ||
| # repository labels its bugfix pull requests 'Fix', which makes Get-PSModuleSettings resolve | ||
| # ReleaseType to 'Prerelease' for this fixture, so Publish-PSModule actually runs and its resolved | ||
| # release tag is visible in the workflow log. Publish-Module.yml sets WhatIf whenever the workflow | ||
| # runs in PSModule/Process-PSModule, so nothing is published and no release is created. | ||
| # | ||
| # Never add a label that PSModule/Auto-Release recognises. It matches the literal string 'prerelease' | ||
| # with -Contains, which is case-insensitive in PowerShell, and would make this repository create a | ||
| # real prerelease release and tag of itself. | ||
| # | ||
| # This is a stopgap that covers the Settings -> action input -> environment variable hop until the | ||
| # end-to-end publish harness in PSModule/Process-PSModule#436 exists. | ||
| PrereleaseLabels: 'prerelease, Fix' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.