🚀 [Feature]: Version input accepts NuGet version ranges (#98)
The Version input now accepts a NuGet version range in addition to an exact version, so a workflow can pin a compatible window (for example [1.2.0, 2.0.0)) instead of a single build. Pinning an exact version keeps working exactly as before, and a version that is already installed and satisfies the request is no longer reinstalled on every run.
- Fixes #97
New: NuGet version ranges for the Version input
Version accepts the same syntax as Install-PSResource:
Version example |
Meaning |
|---|---|
1.2.3 |
Exactly 1.2.3 |
[1.2.3] |
Exactly 1.2.3 |
[1.2.0, ] |
1.2.0 or newer |
(, 2.0.0) |
Any version lower than 2.0.0 |
[1.2.0, 2.0.0) |
1.2.0 up to but not including 2.0.0 |
A bare version is treated as an exact version (not a minimum), so existing pins are unaffected. PSResourceGet resolves a range to the lowest satisfying version.
Fixed: a satisfying version is reused instead of reinstalled
Previously, supplying anything other than an exact version caused the module to be reinstalled on every run: the already-installed check compared the raw input to installed versions with exact string equality, which never matches a range. The check now honors ranges, so an already-installed version that satisfies the request is reused.
Technical Details
src/init.ps1: the already-installed lookup now passes the value toGet-InstalledPSResource -Name $Name -Version $Versioninstead of piping toWhere-Object Version -EQ. The redundantWhere-Object Prerelease -EQfilter was removed — prerelease handling is governed by the-Prereleaseswitch passed toInstall-PSResource. The retry loop (5 attempts, 10s delay) aroundInstall-PSResourceis unchanged.action.yml/README.md: theVersioninput is documented as accepting an exact version or a NuGet version range, with an examples table and a note that a bare version is exact.- Tests (
.github/workflows/TestWorkflow.yml): addedVersion [Exact],Version [Bounded range],Version [Minimum range], andVersion [Already installed]jobs (Linux; version resolution is OS-independent). Written test-first — the already-installed job failed on the unfixed code (two installed versions) and passes after the fix. Because these jobs usePrerelease: ${{ inputs.Prerelease }}, they also exercise the prerelease + range combination when run viaAction-Test-Prerelease.yml. - Implementation plan progress: all tasks in #97 are complete.
Backward compatibility: exact-version pins resolve identically; only the unnecessary-reinstall behavior changes.