Skip to content

ci: fail the crates.io job when publishing actually fails - #30

Merged
d-v-b merged 1 commit into
mainfrom
ci/crates-io-fail-loudly
Aug 13, 2026
Merged

d-v-b merged 1 commit into
mainfrom
ci/crates-io-fail-loudly

Conversation

@d-v-b

@d-v-b d-v-b commented Aug 13, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

The crates.io publish step in .github/workflows/cd.yml carried continue-on-error: true, so a failed publish was reported as a green job. On the v0.4.1 tag it failed with

error: crate zarr-cast-value@0.4.0 already exists on crates.io index
##[error]Process completed with exit code 101

and the job still showed success. Only the PyPI job surfaced the same underlying problem. An authentication failure or a packaging error would be swallowed exactly the same way, which is the more dangerous case — a release could silently never happen.

cargo publish has no --skip-existing, so the version check is done explicitly: query the crates.io API for the version being released, skip the publish when it is already on the index, and let every other failure fail the job. Re-running a tag build stays idempotent without blanket-ignoring the exit code.

An unexpected HTTP status from the API fails the step rather than being assumed to mean "not published" — the failure direction there is a loud publish error, not a silent skip.

Authentication is now gated on the same condition, so a skipped run no longer mints an unused trusted-publishing token.

Testing

Not directly exercisable without cutting a tag, so the pieces were verified individually against the live API:

0.4.0 -> 200   (already published; step skips)
0.4.1 -> 404   (not published; step publishes)

cargo metadata --format-version 1 --no-deps | jq -er ... returns the version from core/Cargo.toml as expected. YAML parses, and zizmor reports no findings on the modified workflow.

Note this PR deliberately does not bump the version — that is #33. Merged alone, this change makes the next tag build fail loudly instead of quietly; merged together with #33, the release succeeds.

The publish step carried continue-on-error: true, so `cargo publish`
exiting 101 was reported as a green job. On the v0.4.1 tag it failed with
"crate zarr-cast-value@0.4.0 already exists on crates.io index" and
nothing surfaced it; an auth or packaging failure would be hidden the
same way.

Query the crates.io API for the version being released and skip the
publish explicitly when it is already on the index, so re-running a tag
build stays idempotent while every other failure fails the job. An
unexpected HTTP status from the API is also treated as a failure rather
than assumed to mean "not published".

Authentication now runs only when there is something to publish, so a
skipped run no longer mints an unused trusted-publishing token.

Assisted-by: ClaudeCode:claude-opus-5
@github-actions github-actions Bot added the ci label Aug 13, 2026
@codspeed

codspeed Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 51 untouched benchmarks
⏩ 21 skipped benchmarks1


Comparing ci/crates-io-fail-loudly (374e549) with main (a2f3ba4)

Open in CodSpeed

Footnotes

  1. 21 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@d-v-b
d-v-b merged commit 0027966 into main Aug 13, 2026
9 checks passed
@d-v-b
d-v-b deleted the ci/crates-io-fail-loudly branch August 13, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant