diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd95f13..b035fae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,13 +56,13 @@ jobs: throw "Requested version '$requested' does not match project version '$projectVersion'." } - git ls-remote --exit-code --tags origin "refs/tags/v$requested" *> $null - if ($LASTEXITCODE -eq 0) { - throw "Tag 'v$requested' already exists. Versions and tags are immutable." - } - if ($LASTEXITCODE -ne 2) { + $existingTag = git ls-remote --tags origin "refs/tags/v$requested" + if ($LASTEXITCODE -ne 0) { throw "Could not verify whether tag 'v$requested' exists (git exit code $LASTEXITCODE)." } + if (-not [string]::IsNullOrWhiteSpace(($existingTag -join ""))) { + throw "Tag 'v$requested' already exists. Versions and tags are immutable." + } $published = Invoke-RestMethod ` -Uri "https://api.nuget.org/v3-flatcontainer/sharedmemorystore/index.json" `