Skip to content

Commit fd2c7d9

Browse files
Extract release tag derivation into a testable helper
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 688896d commit fd2c7d9

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
function Get-ReleaseTag {
2+
<#
3+
.SYNOPSIS
4+
Builds the git tag used for the GitHub release.
5+
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.
10+
11+
.OUTPUTS
12+
String with the release tag.
13+
14+
.EXAMPLE
15+
Get-ReleaseTag -ModuleVersion '1.1.10'
16+
17+
Returns '1.1.10'.
18+
19+
.EXAMPLE
20+
Get-ReleaseTag -ModuleVersion '1.1.10' -Prerelease 'mybranch001'
21+
22+
Returns '1.1.10-mybranch001'.
23+
#>
24+
[CmdletBinding()]
25+
[OutputType([string])]
26+
param(
27+
# The module version from the compiled manifest, in Major.Minor.Patch format.
28+
[Parameter(Mandatory)]
29+
[ValidateNotNullOrEmpty()]
30+
[string] $ModuleVersion,
31+
32+
# The prerelease label from the compiled manifest. Empty for a stable release.
33+
[Parameter()]
34+
[AllowEmptyString()]
35+
[AllowNull()]
36+
[string] $Prerelease
37+
)
38+
39+
if ([string]::IsNullOrWhiteSpace($Prerelease)) {
40+
return $ModuleVersion
41+
}
42+
43+
"$ModuleVersion-$($Prerelease.Trim())"
44+
}

.github/actions/Publish-PSModule/src/publish.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ param()
2828
$PSStyle.OutputRendering = 'Ansi'
2929

3030
Import-Module -Name 'PSModule' -Force
31+
Import-Module -Name "$PSScriptRoot/Publish-PSModule.Helpers.psm1" -Force
3132

3233
#region Load inputs
3334
LogGroup 'Load inputs' {
@@ -129,7 +130,7 @@ LogGroup 'Resolve version from manifest' {
129130
$createPrerelease = $true
130131
}
131132

132-
$releaseTag = if ($createPrerelease) { "$moduleVersion-$prerelease" } else { $moduleVersion }
133+
$releaseTag = Get-ReleaseTag -ModuleVersion $moduleVersion -Prerelease $prerelease
133134

134135
[PSCustomObject]@{
135136
ModuleVersion = $moduleVersion

0 commit comments

Comments
 (0)