Skip to content

ci: publish to crates.io from the release workflow - #15

Merged
plusky merged 1 commit into
mainfrom
ci/publish-crates-on-release
Jul 27, 2026
Merged

ci: publish to crates.io from the release workflow#15
plusky merged 1 commit into
mainfrom
ci/publish-crates-on-release

Conversation

@plusky

@plusky plusky commented Jul 27, 2026

Copy link
Copy Markdown
Owner

What

Releases now publish to crates.io themselves. A publish job runs after the
GitHub 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-core is published before bugwarden: the binary crate resolves
    its dependency from the index and cannot even be packaged before core is
    there.
  • A crate whose version is already on crates.io is skipped, so re-running a
    release that failed halfway is harmless.
  • AGENTS.md gains a Releases section describing the whole flow.

Authentication

Trusted Publishing, exchanging the job's OIDC token for a short-lived
registry token — no CARGO_REGISTRY_TOKEN secret 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
:

field value
repository owner plusky
repository name bugwarden
workflow filename release.yml
environment (leave empty)

Without it the publish job fails to authenticate. If you would rather use a
long-lived token instead, the job only needs CARGO_REGISTRY_TOKEN in the
repository 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 skip
check was run against the live crates.io API for bugwarden-core 0.1.0
(already published → skip) and a nonexistent version (→ publish).

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.
@plusky
plusky merged commit 5f05bf0 into main Jul 27, 2026
10 checks passed
@plusky
plusky deleted the ci/publish-crates-on-release branch July 27, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant