🪲 [Fix]: Version resolution no longer fails on repositories without releases - #432
Conversation
…rsion A repository with no GitHub releases returned $null from the releases lookup, and the Mandatory [array] parameters rejected both $null and an empty collection before any logic could run. The releases list is now optional throughout the action and normalised to an array at the source, so a brand-new repository resolves to a 0.0.0 baseline. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Covers a null releases list, an empty releases list, releases with none marked as latest, and the full brand-new-module path resolving to the first major, minor, and patch version. 21 of the 29 tests fail against the previous parameter declarations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Write-Output -NoEnumerate handed the caller an array nested inside an array, so the tag name of every release was concatenated into one string and rejected as an invalid SemVer. The JSON conversion now lives in its own function that always yields a flat array, including when the gh command produced no output at all. 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 |
Validation against the upstream fix branch is done. The reference goes back to the pinned release so the branch carries no workaround; the Plan job stays red until the fix in PSModule/Process-PSModule#432 is released and the pin is bumped. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
End-to-end verification from a repository with zero releasesRecording this here because it is hard to produce from inside Process-PSModule itself — as #433 notes, the first-release path is structurally unreachable in a repository that already has hundreds of releases. PSModule/Lovdata is a brand-new module repository with zero releases and zero tags, and it is where the failure in #381 reproduces on the very first pull request. Pointing its workflow at a fix branch and running PSModule/Lovdata#3 produced a fully green pipeline:
What this does and does not proveBeing precise, because it matters for what you rely on this for: the run used So it proves that relaxing those bindings is sufficient to unblock a brand-new repository end to end, including the If a literal run of this branch against a zero-release repository would be useful before merging, say so and I will point a throwaway branch in |
Literal execution of this diff on a zero-release repository — greenFollowing up on my earlier comment, which was explicit that the run it described used This one is the real thing. PSModule/Lovdata still has zero releases and zero tags, and its workflow is now pinned to Run 30746077294 — 35 jobs, 31 success, 4 skipped ( What this exercises
What it does not exerciseThe One thing worth knowing before it expires: PSModule/Lovdata stops being a valid reproduction the moment PSModule/Lovdata#3 merges and publishes |
A module repository that has not published its first release no longer breaks. Previously the
Planjob failed on any repository with zero GitHub releases, which meant every brand-new module created from the template was blocked on its very first pull request — a chicken-and-egg problem where the framework could not run until a release existed, and a release could not be created until the framework ran.Fixed: Version resolution works before the first release exists
A repository with no GitHub releases, and a module that has never been published to the PowerShell Gallery, now resolve cleanly to a
0.0.0baseline. The first labelled pull request produces the expected first version —0.0.1for a patch,0.1.0for a minor,1.0.0for a major — instead of failing thePlanjob with:Because every downstream job depends on
Plan, that failure skipped the whole run and made the pull request unmergeable. Nothing needs to change in consuming repositories; bumping to the released version is enough.Technical details
Get-LatestGitHubVersion -Releases $nullandGet-LatestGitHubVersion -Releases @()failed.[Parameter(Mandatory)] [array]rejects an empty collection as well as$null, so normalising at the call site with@(Get-GitHubRelease)alone would have turned the null error into an "empty collection" error. The parameter declarations had to be relaxed too.Resolve-PSModuleVersion.Helpers.psm1:ReleasesonGet-LatestGitHubVersion,Get-NextPrereleaseNumber, andGet-NextModuleVersionis now optional with[AllowNull()],[AllowEmptyCollection()], and an@()default, so each function is individually robust rather than depending on a careful caller.ConvertFrom-GitHubReleaseJsonowns the normalisation of thegh release listoutput into a flat array, including the case where the command produced no output at all (the second reproduction in 🪲 Plan job fails: 'Cannot bind argument to parameter Releases because it is null' on some consumers (v6.1.4) #381, where a repository with five releases still yielded$null).Get-GitHubReleasedelegates to it andsrc/main.ps1normalises with$releases = @(Get-GitHubRelease).Get-LatestPublishedVersionaccepts null versions and filters empty candidates before sorting, warning and flooring to0.0.0when neither source has a version.Get-NextModuleVersionaccepts a nullLatestVersionand floors it to0.0.0..github/actions/Resolve-PSModuleVersion/tests/Resolve-PSModuleVersion.Helpers.Tests.ps1adds 36 Pester tests following the test specification. 21 of them fail against the previous parameter declarations. They cover a null releases list, an empty releases list, releases with none markedisLatest, prerelease-only repositories, the release-JSON normalisation, and the full brand-new-module chain for major, minor, and patch decisions..github/workflows/Test-Actions.ymlruns every.github/actions/*/testsfolder with Pester on pull requests that touch an action, so the repository now has a unit-test surface for its own actions..github/actions/Resolve-PSModuleVersion/src/**.github/linters/.powershell-psscriptanalyzer.psd1.github/actions/Resolve-PSModuleVersion/tests/**.github/workflows/Test-Actions.ymlRelevant issues (or links)