🪲 [Fix]: Release tags keep the configured version prefix - #440
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The test asserts the tag a repository with VersionPrefix 'v' expects, and keeps an unprefixed repository covered. It fails against the current derivation, which builds the tag from the manifest's Major.Minor.Patch only. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The Plan job resolves Publish.Module.VersionPrefix, but the publish action never received it, so the tag was built from the manifest's Major.Minor.Patch alone and repositories on the default 'v' prefix lost it. The prefix now flows from Settings through the action input into the tag. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
The publish job was skipped in every self-test run, so the Settings to action input to environment variable hop was never exercised in CI. That is the hop this pull request repairs. Adding 'Fix' to the Default fixture's PrereleaseLabels resolves ReleaseType to Prerelease for the framework's own bugfix pull requests, so Publish-PSModule runs under WhatIf and logs the tag it would create. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Restores the configured VersionPrefix when composing GitHub release tags in the Publish-PSModule pipeline, so repositories with historical vX.Y.Z tags continue tagging consistently (while keeping the module/gallery version unprefixed).
Changes:
- Adds
Get-ReleaseTaghelper to compose tags fromVersionPrefix + ModuleVersion (+ prerelease). - Wires
Settings.Publish.Module.VersionPrefixthrough the reusable workflow into thePublish-PSModuleaction andpublish.ps1. - Adds Pester coverage for
Get-ReleaseTagand updates the self-test repo fixture to exercise the publish path in CI.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/srcTestRepo/.github/PSModule.yml |
Adjusts fixture prerelease labels so CI runs the publish path under WhatIf. |
.github/workflows/Publish-Module.yml |
Passes Settings.Publish.Module.VersionPrefix into the publish action. |
.github/actions/Publish-PSModule/tests/Publish-PSModule.Helpers.Tests.ps1 |
Adds unit tests for release tag composition behavior. |
.github/actions/Publish-PSModule/src/publish.ps1 |
Imports helper, reads VersionPrefix input, and uses helper to build ReleaseTag. |
.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1 |
Introduces Get-ReleaseTag helper used by publish script. |
.github/actions/Publish-PSModule/action.yml |
Adds VersionPrefix action input and passes it through to the script env var. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1:53
Get-ReleaseTagallows$VersionPrefixto be$null([AllowNull()]) and the unit tests explicitly callGet-ReleaseTag -VersionPrefix $null ..., but the implementation calls$VersionPrefix.Trim()unconditionally. This throws "You cannot call a method on a null-valued expression" and breaks publish/tagging when the input is omitted or null.
$tag = "$($VersionPrefix.Trim())$ModuleVersion"
Pull request was converted to draft
Keeps the Default fixture at ReleaseType None so it stays available as the fixture that can exercise Cleanup-PSModulePrereleases, which is gated on ReleaseType != Prerelease. Both fixtures call the same workflow.yml, so the Settings to input to environment variable hop is proven identically either way. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
Suppressed comments (1)
.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1:53
Get-ReleaseTagallows$VersionPrefixto be$null([AllowNull()]) and the tests call it with$null, but the implementation does$VersionPrefix.Trim()which throws ("You cannot call a method on a null-valued expression"). This will also break publishing if the action input is omitted/unset and the env var is missing.
Handle $null by treating it as an empty string before trimming.
$tag = "$($VersionPrefix.Trim())$ModuleVersion"
Drops the PrereleaseLabels trigger, so the self-test returns to skipping Publish-Module at the job level and the pull request is limited to the tag-derivation path again. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pull request was converted to draft
The PowerShell Gallery and the module manifest only accept plain SemVer, so the prefix must not reach either. Both version strings now come from one composition, Get-ModuleVersionString, with Get-ReleaseTag adding the prefix on top, which removes the duplicated prerelease handling that could have drifted. The resolved-version summary and the closing log line report both strings so the separation is visible in the log. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (1)
.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1:103
Get-ReleaseTagcalls$VersionPrefix.Trim()even whenVersionPrefixis omitted or explicitly$null(both are exercised in the new tests). This will throw "You cannot call a method on a null-valued expression" and break publishing/tag creation for repos where the workflow doesn't pass a prefix (or passes null).
"$($VersionPrefix.Trim())$(Get-ModuleVersionString -ModuleVersion $ModuleVersion -Prerelease $Prerelease)"
Releases created by the module pipeline are tagged with the version prefix configured in
.github/PSModule.ymlagain. A repository that keeps the defaultVersionPrefix: 'v'is taggedv1.1.10, not1.1.10, and its prereleases are taggedv1.1.11-mybranch001. A repository that setsVersionPrefix: ''keeps its unprefixed tags exactly as before.Fixed: release tags no longer lose the configured version prefix
Since v6 the release tag was built from the compiled manifest's
ModuleVersionalone. That value isMajor.Minor.Patchby definition, so the prefix had nowhere to live and every repository publishing on v6 with the default prefix picked up a tag that did not match its own history —PSModule/Tomlwent fromv0.0.1to0.0.2,PSModule/Domeneshopfromv0.0.2to1.0.0,PSModule/PSSemVerfromv1.1.9to1.1.10.Nothing needs to change in a module repository. The prefix is read from the setting that already exists:
The prefix applies to the GitHub release tag and to nothing else. A PowerShell module manifest's
ModuleVersionand a PowerShell Gallery package version only accept plain SemVer, so the version published to the Gallery, the version in the Gallery link, and the name of the module zip attached to the release all stay unprefixed. WithVersionPrefix: 'v'a release looks like this:v1.1.101.1.10ModuleVersion1.1.10MyModule-1.1.10.zipRepositories that already published an unprefixed tag on v6 keep it. Those releases are public, their artifacts are linked from the release pages, and the PowerShell Gallery listing points at them, so they are left alone and the prefix resumes from the next release. An unprefixed tag left in the history does not affect future version resolution.
Technical details
What changed
.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1— new action-scoped helper module withGet-ModuleVersionString, which composes the module's SemVer string, andGet-ReleaseTag, which prefixes it..github/actions/Publish-PSModule/src/publish.ps1— reads the newVersionPrefixinput, derives both version strings from those helpers in one place, and reports both in the resolved-version summary and the closing log line..github/actions/Publish-PSModule/action.yml— new optionalVersionPrefixinput, defaulting to''..github/workflows/Publish-Module.yml— passesSettings.Publish.Module.VersionPrefixinto the action..github/actions/Publish-PSModule/tests/Publish-PSModule.Helpers.Tests.ps1— new Pester suite, picked up automatically by the existingTest-Actionsdiscovery over.github/actions/*/tests.Five files, all on the tag-derivation path. No test fixture or pipeline behaviour outside it changes.
Approach
The manifest stays the source of the numeric version.
ModuleVersionis what was built, tested, and pushed to the Gallery, so the tag has to agree with it — the^\d+\.\d+\.\d+$guard and the999.0.0placeholder check are unchanged. Only the prefix, the one piece of the tag the manifest cannot carry, is taken from the settings the Plan job already resolves. Composing the two is equivalent to usingResolution.FullVersionin the normal case and stays anchored to the artifact if the two ever disagree.Keeping the prefix off the module version.
publish.ps1previously built the Gallery version with its own copy of the prerelease composition, independent of the tag. Two independent implementations of the same string is how they drift, and drift in this direction means a prefixed version reachingPublish-PSResource. Both now come fromGet-ModuleVersionString;Get-ReleaseTagis that string with the prefix in front, so the prefix is the only possible difference between them, by construction rather than by convention.The prefix reaches: the release tag, the release title fallback, the
gh release uploadtarget, the release URL, the GitHub half of the pull request comment, andPSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTagfor cleanup. It reaches nothing else.publish.ps1never writes to the manifest — it is read-only on the artifact by design — andBuild-PSModulestamps the manifest fromResolution.VersionandResolution.Prerelease, which are unprefixed.Resolution.FullVersion, the one prefix-bearing value in the Settings object, is consumed by no downstream job.Get-ModuleVersionStringandGet-ReleaseTagboth trim their inputs, because prefix and label arrive through environment variables, and both treat a whitespace-only prerelease label as a stable release.Verification — unit tests, red then green in CI
Test actionsfd2c7d9d0f8f7a06b471432 cases now. Alongside the prefixed and unprefixed tag shapes, absent and null prefixes, whitespace normalization, and the tag shape
Cleanup-PSModulePrereleasesdepends on, athe prefix reaches the release tag and nothing elsecontext pins the separation directly:$Prefix+ the module version string;^\d+\.\d+\.\d+(-[0-9A-Za-z\-.]+)?$;Get-ModuleVersionStringhas noVersionPrefixparameter at all, so a caller cannot pass one;vfrom a prefixed tag returns the module version string.Verification — the wiring, observed once in CI on an interim commit
This bug was a wiring failure, not a logic failure.
VersionPrefixwas resolved correctly by the Plan job and present in the Settings JSON; it simply never reached the tag. Unit tests prove the helpers compose correctly given the right input — they cannot prove thatfromJson(inputs.Settings).Publish.Module.VersionPrefix→ action input →PSMODULE_PUBLISH_PSMODULE_INPUT_VersionPrefix→$versionPrefixdelivers the value.Publish-Moduleis skipped at the job level in every self-test run —Publish.Module.Enabledis(ReleaseType -ne 'None') -or shouldAutoCleanup, and an open pull request satisfies neither without a prerelease label — so the self-test does not exercise that chain on this diff.To close that gap once, an interim commit on this branch added
Fixto a fixture'sPrereleaseLabels, which made the self-test run the publish path underWhatIf. That commit has since been reset and is not part of this pull request; the observation below is from run 30759608449 and is reported as a one-time measurement, not as coverage this change carries forward.Nothing was published in that run:
Publish-PSResourcewas logged rather than executed, no release or tag was created, and theReleaseworkflow on the same push reportedCreate a prerelease: [False]/Skipping release creation.Standing publish-path coverage in CI is the subject of #436.
Verification — locally, outside CI
publish.ps1run end to end inWhatIfmode against a fabricated artifact, all four combinations, re-run after the separation change. Every line below is from those runs:…_CONTEXT_ReleaseTagv1.1.10v1.1.10PSModuleTest-1.1.10.zipv1.1.10vmybranch0011.1.11-mybranch001v1.1.11-mybranch001PSModuleTest-1.1.11-mybranch001.zipv1.1.11-mybranch001''1.1.101.1.10PSModuleTest-1.1.10.zip1.1.10''mybranch0011.1.11-mybranch0011.1.11-mybranch001PSModuleTest-1.1.11-mybranch001.zip1.1.11-mybranch001The first row is the
PSModule/PSSemVercase from the bug report, which produced tag1.1.10before this change. The Gallery link and comment carried the unprefixed version in every run:AutoCleanupwas verified the same way, runningcleanup.ps1against fixture release lists with theghCLI shadowed. It keys offtagName -like "*$prereleaseName*", which is prefix-agnostic, and excludes the published release by comparingtagNametoPSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag, which is now prefixed on both sides:v1.1.11-mybranch003v1.1.11-mybranch002,v1.1.11-mybranch001v1.1.10, another branch's prerelease1.1.11-mybranch0031.1.11-mybranch002,1.1.11-mybranch0011.1.10, another branch's prereleasev1.1.11-mybranch0031.1.11-mybranch002,1.1.11-mybranch001v1.1.11The mixed row is the migration case: a repository whose open pull request already has unprefixed prerelease tags created by the current v6 still has them cleaned up after this change.
Invoke-ScriptAnalyzer -Recurse -Settings .github/linters/.powershell-psscriptanalyzer.psd1reports no findings for the action.What is verified where
$versionPrefixAutoCleanuptag matching, prefixed / unprefixed / mixed historycleanup.ps1against fixture release listsImplementation plan progress
Completes every step of the plan in #439 — regression test confirmed failing first, tag derivation changed, prefixed and unprefixed fixtures plus the
AutoCleanuppath re-run. The two decisions the issue records are answered in a comment on it: the already-published unprefixed tags are left in place, and the prefix-consistency warning is carried by #441 rather than widened into this pull request.Standards and framework alignment
.github/actions/Publish-PSModule/src/**(PowerShell).github/actions/Publish-PSModule/tests/**(Pester)Test-Actions.yml.github/actions/Publish-PSModule/action.yml(GitHub Actions).github/actions/Publish-PSModule/(folder conventions)main.ps1, README per action.github/workflows/Publish-Module.yml(GitHub Actions)The helper module is named after the action, per the standard, and matches the existing
Resolve-PSModuleVersion.Helpers.psm1. The entry script here issrc/publish.ps1rather thansrc/main.ps1and the action has no README; both predate this change and apply toCleanup-PSModulePrereleasestoo, so they are carried by #442 instead of being renamed inside a bugfix.Issue convergence sweep
Scoped to the publish and version-resolution surface: open issues in this repository touching
Publish-PSModule,Resolve-PSModuleVersion,Cleanup-PSModulePrereleases, release tags, or versioning. #439 is the only one this diff fully satisfies. #438 (v5 to v6 migration) is affected by the fix but not delivered by it — the 48 repositories still on v5 need this merged and released before they migrate, so it is linked as context. #436 is linked as context only; this diff does not advance it. #441, #442, and #443 were opened by this session for findings deliberately left out of scope.Relevant issues (or links)