Skip to content

Commit b980b70

Browse files
Reject array-valued release tags before publication writes
(cherry picked from commit 03c37ea)
1 parent fcd0247 commit b980b70

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎.github/actions/Publish-PSModule/src/Publish-PSModule.Helpers.psm1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ function Get-PSModulePublicationState {
518518
if ($release.draft -isnot [bool] -or $release.draft -ne $false) {
519519
throw 'The existing release has no verified boolean draft:false status. Refusing publication or an incomplete release.'
520520
}
521-
if ($release.tag_name -cne $expected.ReleaseTag -or
521+
if ($release.tag_name -isnot [string] -or $release.tag_name -cne $expected.ReleaseTag -or
522522
[string]::IsNullOrWhiteSpace($release.html_url) -or
523523
$release.prerelease -isnot [bool] -or
524524
$release.prerelease -ne ($expected.ReleaseType -ceq 'Prerelease') -or

‎.github/actions/Publish-PSModule/tests/Publish-PSModule.Preflight.Tests.ps1‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,27 @@ Describe 'Publish-PSModule source-bound preflight' {
261261
@(& $reader.GetTagList).Count | Should -Be 0
262262
}
263263

264+
It 'rejects an array-valued release tag before <Controller> writes' -ForEach @(
265+
@{ Controller = 'publisher' }
266+
@{ Controller = 'release' }
267+
) {
268+
Set-PSModuleFixtureClaim -State $script:state -Claim $script:state.ExpectedClaim
269+
$script:state.Release = [pscustomobject]@{
270+
id = 10; tag_name = @('v1.2.4'); html_url = 'https://github.com/PSModule/TestModule/releases/tag/v1.2.4'
271+
prerelease = $false; draft = $false; body = 'Direct release notes.'; assets = @()
272+
}
273+
$controllerPath = $script:publishScriptPath
274+
if ($Controller -ceq 'release') { $controllerPath = $script:releaseScriptPath }
275+
$failure = $null
276+
277+
try { & $controllerPath 1>$null 6>$null } catch { $failure = $_ }
278+
279+
$script:state.GalleryWrites | Should -Be 0
280+
$script:state.GitHubWrites | Should -Be 0
281+
$failure | Should -Not -BeNullOrEmpty
282+
$failure.Exception.Message | Should -Match 'existing release context'
283+
}
284+
264285
It 'rejects a Gallery-only package with no source and artifact proof' {
265286
$script:state.Package = [pscustomobject]@{ Name = 'TestModule'; Version = '1.2.4' }
266287

0 commit comments

Comments
 (0)