ci: publish to crates.io from the release workflow - #15
Merged
Conversation
Cutting a release meant tagging, waiting for the artifacts, then running two cargo publish commands by hand in the right order — easy to forget and easy to get wrong, since bugwarden-core has to reach the index before the binary crate can even be packaged. Add a publish job that runs after the GitHub release exists, so crates.io only sees a version whose platforms all built. It authenticates with Trusted Publishing over the job's OIDC token rather than a stored registry token, and skips any crate whose version is already up, making a re-run of a partially failed release harmless.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Releases now publish to crates.io themselves. A
publishjob runs after theGitHub release exists, so the registry only ever sees a version whose
platforms all built — and crates.io versions can be yanked but never
replaced, which makes "last" the right position for it.
bugwarden-coreis published beforebugwarden: the binary crate resolvesits dependency from the index and cannot even be packaged before core is
there.
release that failed halfway is harmless.
Authentication
Trusted Publishing, exchanging the job's OIDC token for a short-lived
registry token — no
CARGO_REGISTRY_TOKENsecret is stored in the repo.This needs one-time setup on crates.io before the next tag, for both
crates, under the crate's Settings → Trusted Publishing → Add GitHub
publisher:
pluskybugwardenrelease.ymlWithout it the publish job fails to authenticate. If you would rather use a
long-lived token instead, the job only needs
CARGO_REGISTRY_TOKENin therepository secrets and the auth step dropped.
Verification
The job cannot be exercised without pushing a tag, so 0.1.0 was published by
hand and this automates what those commands did, in the same order. The
workflow parses and the job graph is
build → release → publish; the skipcheck was run against the live crates.io API for
bugwarden-core0.1.0(already published → skip) and a nonexistent version (→ publish).