|
4 | 4 | Builds the git tag used for the GitHub release. |
5 | 5 |
|
6 | 6 | .DESCRIPTION |
7 | | - Composes the release tag from the module version and, when present, the prerelease label. |
8 | | - The version comes from the compiled manifest, which is the artifact that is published, so the |
9 | | - tag always names the exact bytes that were tested and pushed to the PowerShell Gallery. |
| 7 | + Composes the release tag from the configured version prefix, the module version, and the |
| 8 | + prerelease label when there is one. The version comes from the compiled manifest, which is the |
| 9 | + artifact that is published, so the tag always names the exact bytes that were tested and pushed |
| 10 | + to the PowerShell Gallery. The manifest's ModuleVersion is Major.Minor.Patch by definition and |
| 11 | + cannot carry the prefix, so the prefix is supplied from the resolved settings |
| 12 | + (Publish.Module.VersionPrefix) instead. An empty prefix produces an unprefixed tag. |
10 | 13 |
|
11 | 14 | .OUTPUTS |
12 | 15 | String with the release tag. |
13 | 16 |
|
14 | 17 | .EXAMPLE |
15 | | - Get-ReleaseTag -ModuleVersion '1.1.10' |
| 18 | + Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' |
16 | 19 |
|
17 | | - Returns '1.1.10'. |
| 20 | + Returns 'v1.1.10'. |
18 | 21 |
|
19 | 22 | .EXAMPLE |
20 | | - Get-ReleaseTag -ModuleVersion '1.1.10' -Prerelease 'mybranch001' |
| 23 | + Get-ReleaseTag -VersionPrefix 'v' -ModuleVersion '1.1.10' -Prerelease 'mybranch001' |
| 24 | +
|
| 25 | + Returns 'v1.1.10-mybranch001'. |
21 | 26 |
|
22 | | - Returns '1.1.10-mybranch001'. |
| 27 | + .EXAMPLE |
| 28 | + Get-ReleaseTag -VersionPrefix '' -ModuleVersion '1.1.10' |
| 29 | +
|
| 30 | + Returns '1.1.10'. |
23 | 31 | #> |
24 | 32 | [CmdletBinding()] |
25 | 33 | [OutputType([string])] |
|
29 | 37 | [ValidateNotNullOrEmpty()] |
30 | 38 | [string] $ModuleVersion, |
31 | 39 |
|
| 40 | + # The prefix put in front of the version, for example 'v'. Empty for an unprefixed repository. |
| 41 | + [Parameter()] |
| 42 | + [AllowEmptyString()] |
| 43 | + [AllowNull()] |
| 44 | + [string] $VersionPrefix, |
| 45 | + |
32 | 46 | # The prerelease label from the compiled manifest. Empty for a stable release. |
33 | 47 | [Parameter()] |
34 | 48 | [AllowEmptyString()] |
35 | 49 | [AllowNull()] |
36 | 50 | [string] $Prerelease |
37 | 51 | ) |
38 | 52 |
|
| 53 | + $tag = "$($VersionPrefix.Trim())$ModuleVersion" |
| 54 | + |
39 | 55 | if ([string]::IsNullOrWhiteSpace($Prerelease)) { |
40 | | - return $ModuleVersion |
| 56 | + return $tag |
41 | 57 | } |
42 | 58 |
|
43 | | - "$ModuleVersion-$($Prerelease.Trim())" |
| 59 | + "$tag-$($Prerelease.Trim())" |
44 | 60 | } |
0 commit comments