Skip to content

Commit ff6bf3f

Browse files
Reject observed tag changes during shared module version reservation
Recheck the immediately preceding tag SHA after create-only reservation, including a tag first observed after preflight. Retain valid partial-claim completion without recreating a disappeared or replaced observed tag. (cherry picked from commit 474d094)
1 parent 61f81ff commit ff6bf3f

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎.github/actions/Publish-PSModule/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Publishes a pre-versioned, tested PowerShell module artifact to the PowerShell G
44

55
The publisher verifies the original source, exact resolved tag/version, producing repository/PR or direct-release context, and tested bytes before an external versioned-artifact mutation. An absent Gallery module/version is reserved at `PSModule-Publication/<lowercase-module>/<lowercase-version>`, independently of the configured release-tag prefix. The shared coordinate and release tag reference the same immutable annotated source/context/file-tree/ZIP claim. Existing tags are never updated or deleted; the package ownership coordinate is retained for immutable Gallery proof.
66

7+
An observed release tag must remain unchanged through shared coordinate creation. If it disappears or is replaced during that reservation, the attempt fails instead of recreating it. A valid partial shared claim can still create an absent release tag that has never been observed in the attempt.
8+
79
An existing Gallery package is retained only when its raw nupkg payload matches that proof and the tested artifact. Package code is never imported to establish ownership. Unknown legacy proof, foreign tags/releases/assets, changed claims, authentication errors, and API failures stop publication explicitly.
810

911
## Inputs

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,16 @@ function New-PSModulePublicationTag {
626626
}
627627
if ($null -eq $current.VersionTagSha) {
628628
$versionTag = Get-PSModulePublicationVersionTag -ModuleName $Claim.ModuleName -GalleryVersion $Claim.GalleryVersion
629+
$observedTagSha = $current.TagSha
629630
$reference = Invoke-PSModulePublicationApi -Endpoint "repos/$($Claim.Repository)/git/refs" `
630631
-Method POST -Field @{ ref = "refs/tags/$versionTag"; sha = $claimSha } -AllowConflict
631632
if ($reference.StatusCode -ne 201 -and $reference.Value.message -cne 'Reference already exists') {
632633
throw "Cannot atomically reserve module/version [$versionTag] (HTTP $($reference.StatusCode))."
633634
}
634635
$current = Get-PSModulePublicationState -ExpectedClaim $Claim -Reader $Reader
636+
if ($null -ne $observedTagSha -and $current.TagSha -cne $observedTagSha) {
637+
throw 'The existing publication tag changed or disappeared during the shared module/version claim. Refusing publication.'
638+
}
635639
if ($null -eq $current.VersionTagSha -or
636640
($reference.StatusCode -eq 201 -and $current.VersionTagSha -cne $claimSha)) {
637641
throw 'The module/version coordinate changed during its create-only claim. Refusing publication.'

0 commit comments

Comments
 (0)