Skip to content

Commit 474d094

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.
1 parent 6254d34 commit 474d094

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
@@ -623,12 +623,16 @@ function New-PSModulePublicationTag {
623623
}
624624
if ($null -eq $current.VersionTagSha) {
625625
$versionTag = Get-PSModulePublicationVersionTag -ModuleName $Claim.ModuleName -GalleryVersion $Claim.GalleryVersion
626+
$observedTagSha = $current.TagSha
626627
$reference = Invoke-PSModulePublicationApi -Endpoint "repos/$($Claim.Repository)/git/refs" `
627628
-Method POST -Field @{ ref = "refs/tags/$versionTag"; sha = $claimSha } -AllowConflict
628629
if ($reference.StatusCode -ne 201 -and $reference.Value.message -cne 'Reference already exists') {
629630
throw "Cannot atomically reserve module/version [$versionTag] (HTTP $($reference.StatusCode))."
630631
}
631632
$current = Get-PSModulePublicationState -ExpectedClaim $Claim -Reader $Reader
633+
if ($null -ne $observedTagSha -and $current.TagSha -cne $observedTagSha) {
634+
throw 'The existing publication tag changed or disappeared during the shared module/version claim. Refusing publication.'
635+
}
632636
if ($null -eq $current.VersionTagSha -or
633637
($reference.StatusCode -eq 201 -and $current.VersionTagSha -cne $claimSha)) {
634638
throw 'The module/version coordinate changed during its create-only claim. Refusing publication.'

0 commit comments

Comments
 (0)