Skip to content

Commit 942a856

Browse files
joshwilhelmiclaude
andcommitted
[gobby-cli-#465] fix: make gwiki release publish step idempotent
The publish job hard-failed when gobby-wiki's version was already on crates.io (e.g. after a token-based first publish), which blocked the release job and its macOS/Linux binary upload. Add a pre-check that queries crates.io for the package version and skips the auth + upload steps when it already exists, so re-pushing the tag attaches binaries without re-uploading the crate. New versions still publish normally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 62d23ff commit 942a856

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

.github/workflows/release-gwiki.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,27 @@ jobs:
215215
with:
216216
toolchain: stable
217217

218+
- name: Check whether this version is already on crates.io
219+
id: published
220+
run: |
221+
set -euo pipefail
222+
version="$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name == "gobby-wiki") | .version')"
223+
code="$(curl -sS -A 'gobby-cli release workflow' -o /dev/null -w '%{http_code}' "https://crates.io/api/v1/crates/gobby-wiki/${version}")"
224+
if [ "$code" = "200" ]; then
225+
echo "gobby-wiki ${version} is already on crates.io; skipping publish (binaries still attach)."
226+
echo "skip=true" >> "$GITHUB_OUTPUT"
227+
else
228+
echo "gobby-wiki ${version} not on crates.io (HTTP ${code}); will publish."
229+
echo "skip=false" >> "$GITHUB_OUTPUT"
230+
fi
231+
218232
- name: Authenticate to crates.io
219233
id: cargo-registry-auth
234+
if: steps.published.outputs.skip != 'true'
220235
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe
221236

222237
- name: Publish gobby-wiki to crates.io
238+
if: steps.published.outputs.skip != 'true'
223239
env:
224240
CARGO_REGISTRY_TOKEN: ${{ steps.cargo-registry-auth.outputs.token }}
225241
run: cargo publish -p gobby-wiki --locked

0 commit comments

Comments
 (0)