ci: publish crates to crates.io on release published#144
Merged
Conversation
Adds a workflow that runs on `release: published` (and on manual dispatch) and publishes the workspace crates in dependency order: `tari_ootle_publish_lib` first, then `tari-ootle-cli`. Authenticates via the `CARGO_REGISTRY_TOKEN` secret.
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
There was a problem hiding this comment.
Pull request overview
Adds an automated GitHub Actions workflow to publish the repository’s Rust workspace crates to crates.io when a GitHub Release is published (with a manual workflow_dispatch option for reruns), using a CARGO_REGISTRY_TOKEN secret for authentication.
Changes:
- Introduces
.github/workflows/publish-crates.ymltriggered onrelease: publishedandworkflow_dispatch. - Publishes workspace crates in dependency order (
tari_ootle_publish_libthentari-ootle-cli). - Sets up Rust tooling, caching, and required system dependencies for the publish environment.
Comments suppressed due to low confidence (2)
.github/workflows/publish-crates.yml:35
- Consider adding
--lockedto thecargo publishcommands so CI does not implicitly updateCargo.lock(which can cause publish failures due to a dirty working tree) and to ensure the published crate is built against the exact dependency set committed in the lockfile.
- name: Publish tari_ootle_publish_lib
run: cargo publish -p tari_ootle_publish_lib
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish tari-ootle-cli
run: cargo publish -p tari-ootle-cli
env:
.github/workflows/publish-crates.yml:36
CARGO_REGISTRY_TOKENis repeated in both publish steps. To reduce duplication and avoid accidentally publishing without the token in future edits, consider setting this env var once at the job (or workflow) level and letting both steps inherit it.
- name: Publish tari_ootle_publish_lib
run: cargo publish -p tari_ootle_publish_lib
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish tari-ootle-cli
run: cargo publish -p tari-ootle-cli
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot review feedback on #144: avoids duplicating the registry-token env across steps so future publish steps inherit it, and uses `cargo publish --locked` to pin published crates to the committed Cargo.lock and prevent dirty-tree publish failures.
Adds .github/scripts/publish-if-new.sh, which queries the crates.io API for the workspace version of the given crate and skips `cargo publish` if it's already published. Both workflow steps now go through this helper so a re-run after a partial failure (lib publishes ok, cli fails) succeeds instead of erroring on the already-published lib version.
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.
Summary
.github/workflows/publish-crates.yml, triggered byrelease: published(andworkflow_dispatchfor manual reruns).tari_ootle_publish_libfirst, thentari-ootle-cli.secrets.CARGO_REGISTRY_TOKEN.Prerequisite
CARGO_REGISTRY_TOKENrepository secret with a crates.io API token scoped to publish these crates. Without it the job will fail with an auth error on first run.Notes
cargo publish(Cargo 1.66+) waits for the new version to be queryable on the index before exiting, so the second step can resolve the just-published lib.libdbus-1-dev,pkg-config) as the PR-check workflow so the build environment matches.Test plan
CARGO_REGISTRY_TOKENsecret is set, trigger the workflow viaworkflow_dispatchagainst a pre-release tag (or wait for the next published release) and confirm both crates appear on crates.io.