Commit 688896d
🪲 [Fix]: Version resolution no longer fails on repositories without releases (#432)
A module repository that has not published its first release no longer
breaks. Previously the `Plan` job 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.0`
baseline. The first labelled pull request produces the expected first
version — `0.0.1` for a patch, `0.1.0` for a minor, `1.0.0` for a major
— instead of failing the `Plan` job with:
```text
Cannot bind argument to parameter 'Releases' because it is null.
```
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.
---
<details>
<summary>Technical details</summary>
- Verified the reported diagnosis before changing anything. Both
`Get-LatestGitHubVersion -Releases $null` **and**
`Get-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`: `Releases` on
`Get-LatestGitHubVersion`, `Get-NextPrereleaseNumber`, and
`Get-NextModuleVersion` is now optional with `[AllowNull()]`,
`[AllowEmptyCollection()]`, and an `@()` default, so each function is
individually robust rather than depending on a careful caller.
- New `ConvertFrom-GitHubReleaseJson` owns the normalisation of the `gh
release list` output into a flat array, including the case where the
command produced no output at all (the second reproduction in #381,
where a repository with five releases still yielded `$null`).
`Get-GitHubRelease` delegates to it and `src/main.ps1` normalises with
`$releases = @(Get-GitHubRelease)`.
- `Get-LatestPublishedVersion` accepts null versions and filters empty
candidates before sorting, warning and flooring to `0.0.0` when neither
source has a version. `Get-NextModuleVersion` accepts a null
`LatestVersion` and floors it to `0.0.0`.
- The downstream fallback logic was already correct — only parameter
binding, null handling, and the array shape changed. Version resolution
was not redesigned.
- Tests:
`.github/actions/Resolve-PSModuleVersion/tests/Resolve-PSModuleVersion.Helpers.Tests.ps1`
adds 36 Pester tests following the [test
specification](https://psmodule.io/docs/Modules/Test-Specification/). 21
of them fail against the previous parameter declarations. They cover a
null releases list, an empty releases list, releases with none marked
`isLatest`, prerelease-only repositories, the release-JSON
normalisation, and the full brand-new-module chain for major, minor, and
patch decisions.
- CI: `.github/workflows/Test-Actions.yml` runs every
`.github/actions/*/tests` folder with Pester on pull requests that touch
an action, so the repository now has a unit-test surface for its own
actions.
- Standards and framework alignment:
| Changed surface | Standards checked | Framework docs checked | Result
|
| --- | --- | --- | --- |
| `.github/actions/Resolve-PSModuleVersion/src/**` | PSScriptAnalyzer
via `.github/linters/.powershell-psscriptanalyzer.psd1` | PSModule
function/parameter conventions | Aligned |
| `.github/actions/Resolve-PSModuleVersion/tests/**` | PSScriptAnalyzer
| [Test
Specification](https://psmodule.io/docs/Modules/Test-Specification/) |
Aligned |
| `.github/workflows/Test-Actions.yml` | Pinned action SHAs,
least-privilege permissions | Reusable workflow contract | Aligned —
repository-internal workflow, not consumer-facing |
</details>
<details>
<summary>Relevant issues (or links)</summary>
- Fixes #381
- #433 — follow-up for end-to-end coverage of a
repository with zero releases
- Reproduction: PSModule/Lovdata#1 — [failing run
30743884958](https://github.com/PSModule/Lovdata/actions/runs/30743884958/job/91486012154)
</details>
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent b11b310 commit 688896d
4 files changed
Lines changed: 599 additions & 22 deletions
File tree
- .github
- actions/Resolve-PSModuleVersion
- src
- tests
- workflows
Lines changed: 90 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
280 | 312 | | |
281 | 313 | | |
282 | 314 | | |
283 | 315 | | |
284 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
285 | 321 | | |
286 | | - | |
| 322 | + | |
287 | 323 | | |
288 | 324 | | |
289 | | - | |
| 325 | + | |
290 | 326 | | |
291 | 327 | | |
292 | 328 | | |
| |||
298 | 334 | | |
299 | 335 | | |
300 | 336 | | |
301 | | - | |
| 337 | + | |
302 | 338 | | |
303 | 339 | | |
| 340 | + | |
304 | 341 | | |
305 | 342 | | |
306 | 343 | | |
| |||
314 | 351 | | |
315 | 352 | | |
316 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
317 | 359 | | |
318 | 360 | | |
319 | 361 | | |
| |||
325 | 367 | | |
326 | 368 | | |
327 | 369 | | |
328 | | - | |
329 | | - | |
330 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
331 | 375 | | |
332 | 376 | | |
333 | 377 | | |
| |||
409 | 453 | | |
410 | 454 | | |
411 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
412 | 461 | | |
413 | 462 | | |
414 | 463 | | |
| |||
420 | 469 | | |
421 | 470 | | |
422 | 471 | | |
423 | | - | |
424 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
425 | 475 | | |
426 | 476 | | |
427 | | - | |
428 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
429 | 480 | | |
430 | 481 | | |
431 | 482 | | |
432 | 483 | | |
433 | | - | |
434 | | - | |
435 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
436 | 493 | | |
437 | 494 | | |
438 | 495 | | |
| |||
472 | 529 | | |
473 | 530 | | |
474 | 531 | | |
475 | | - | |
476 | | - | |
477 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
478 | 537 | | |
479 | 538 | | |
480 | 539 | | |
| |||
532 | 591 | | |
533 | 592 | | |
534 | 593 | | |
535 | | - | |
536 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
537 | 597 | | |
538 | 598 | | |
539 | 599 | | |
| |||
550 | 610 | | |
551 | 611 | | |
552 | 612 | | |
553 | | - | |
554 | | - | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
555 | 618 | | |
556 | 619 | | |
557 | 620 | | |
558 | | - | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
559 | 628 | | |
560 | 629 | | |
561 | 630 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
0 commit comments