Skip to content

Commit 282de8a

Browse files
tablackburnclaude
andcommitted
ci(release): fail the PSGallery check on a query error instead of assuming not-published
Now that Publish is gated only on this check (recovery-gap fix #33), a Find-Module -ErrorAction SilentlyContinue returning $null was treated as 'not on gallery' for BOTH a genuine miss and a transient query failure — so a network/PSGallery hiccup could trigger a blind publish attempt. Capture -ErrorVariable: publish only on a clean miss (Find-Module records no error for a genuine not-found, verified for new-version and never-published cases); on a recorded error, throw so the run is visibly retryable. Surfaced by CodeRabbit/Copilot during the YouTubeMusicPS rollout review. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 090de78 commit 282de8a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.github/workflows/PublishModuleToPowerShellGallery.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,17 @@ jobs:
7474
VERSION: ${{ steps.version.outputs.version }}
7575
run: |
7676
$version = $env:VERSION
77-
$published = Find-Module -Name {{ModuleName}} -RequiredVersion $version -Repository PSGallery -ErrorAction SilentlyContinue
77+
$findError = $null
78+
$published = Find-Module -Name {{ModuleName}} -RequiredVersion $version -Repository PSGallery -ErrorAction SilentlyContinue -ErrorVariable findError
7879
if ($published) {
7980
Write-Host "PSGallery version $version already exists"
8081
"exists=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
82+
} elseif ($findError) {
83+
# Find-Module records no error when the version simply isn't on the gallery,
84+
# so a recorded error means the query itself failed (transient/network). Don't
85+
# treat that as "not published" (publishing is now gated only on this check) —
86+
# fail so the run is visibly retryable instead of attempting a blind publish.
87+
throw "PowerShell Gallery query failed for version ${version}: $($findError[0].Exception.Message)"
8188
} else {
8289
Write-Host "PSGallery version $version not found - will publish"
8390
"exists=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append

0 commit comments

Comments
 (0)