Commit 8083ec1
authored
🚀 [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`](https://learn.microsoft.com/powershell/module/microsoft.powershell.psresourceget/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 to
`Get-InstalledPSResource -Name $Name -Version $Version` instead of
piping to `Where-Object Version -EQ`. The redundant `Where-Object
Prerelease -EQ` filter was removed — prerelease handling is governed by
the `-Prerelease` switch passed to `Install-PSResource`. The retry loop
(5 attempts, 10s delay) around `Install-PSResource` is unchanged.
- `action.yml` / `README.md`: the `Version` input 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`): added `Version [Exact]`,
`Version [Bounded range]`, `Version [Minimum range]`, and `Version
[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 use `Prerelease: ${{ inputs.Prerelease }}`, they also exercise the
prerelease + range combination when run via
`Action-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.1 parent 918892d commit 8083ec1
4 files changed
Lines changed: 135 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
76 | 190 | | |
77 | 191 | | |
78 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
31 | 42 | | |
32 | 43 | | |
33 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
| 31 | + | |
| 32 | + | |
28 | 33 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
0 commit comments