Publishing to crates.io
Quick Start
First Time Setup
-
Get a crates.io API token
- Go to https://crates.io/me
- Generate a new API token
- Add it to GitHub Secrets as
CARGO_REGISTRY_TOKEN
-
Verify you have publish permissions
- You need to be an owner of both crates on crates.io
- For first publish, this happens automatically when you publish
Publishing a New Version
The easiest way is to use the release helper script:
# For a new version of both crates
./scripts/release.sh 0.2.0 both
# For protocol only
./scripts/release.sh 0.2.0 protocol
# For client only
./scripts/release.sh 0.2.0 clientThe script will:
- Update version numbers in Cargo.toml files
- Run tests, clippy, and formatting checks
- Verify the package can be published
- Give you instructions for the git commands
Then follow the instructions to commit, push, and tag the release.
Manual Process
If you prefer to do it manually:
-
Update version numbers
# Edit version in Cargo.toml files vim crates/scarab-nav-protocol/Cargo.toml vim crates/scarab-nav-client/Cargo.toml -
Run checks
cargo test --all-features --workspace cargo clippy --all-features --workspace -- -D warnings cargo fmt --all -- --check -
Verify package
cd crates/scarab-nav-protocol cargo publish --dry-run --allow-dirty -
Commit and tag
git add . git commit -m "chore: bump version to 0.2.0" git push origin main git tag v0.2.0 git push origin v0.2.0
GitHub Actions Workflow
The release workflow automatically:
-
Triggers on tag push: Any tag matching
v*.*.*,scarab-nav-protocol-v*.*.*, orscarab-nav-client-v*.*.* -
Runs tests: Full test suite on Ubuntu
-
Publishes to crates.io:
- For
v*.*.*tags: Publishes both crates (protocol first, then client after 30s delay) - For
scarab-nav-protocol-v*.*.*: Publishes protocol only - For
scarab-nav-client-v*.*.*: Publishes client only
- For
-
Creates GitHub Release: Automatically generates release notes
Tag Format Reference
| Tag Format | What Gets Published | Example |
|---|---|---|
v*.*.* | Both crates with same version | v0.2.0 |
scarab-nav-protocol-v*.*.* | Protocol only | scarab-nav-protocol-v0.2.0 |
scarab-nav-client-v*.*.* | Client only | scarab-nav-client-v0.2.1 |
Verification
After pushing a tag, you can monitor the release:
- GitHub Actions: https://github.com/raibid-labs/scarab-nav-protocol/actions
- crates.io:
- docs.rs:
Troubleshooting
”Not allowed to upload to crates.io”
You need to be added as an owner. For first publish, this isn’t needed. For subsequent publishes, an existing owner needs to run:
cargo owner --add github:yourusername scarab-nav-protocol
cargo owner --add github:yourusername scarab-nav-client“Version already published”
You cannot republish the same version. Bump the version number and try again.
”Client can’t find protocol version”
When publishing both crates, the protocol needs to be available on crates.io before the client can be published. The workflow handles this automatically with a 30-second delay. If publishing manually, wait a minute or two between publishing the protocol and client.
Workflow fails on tests
Fix the failing tests on main branch before creating a release tag. You can run tests locally:
cargo test --all-features --workspaceWorkflow fails on clippy or format
Run these locally and fix issues:
cargo clippy --all-features --workspace -- -D warnings
cargo fmt --allPre-releases
For alpha, beta, or release candidates:
./scripts/release.sh 0.2.0-alpha.1 bothThe GitHub Release will automatically be marked as a pre-release if the version contains alpha, beta, or rc.
Yanking a Release
If you need to remove a broken release from crates.io:
cargo yank --vers 0.2.0 scarab-nav-protocol
cargo yank --vers 0.2.0 scarab-nav-clientThis prevents new projects from using it but doesn’t break existing users.
To un-yank:
cargo yank --undo --vers 0.2.0 scarab-nav-protocolEmergency Manual Publish
If the GitHub Actions workflow is broken and you need to publish urgently:
# Login to crates.io
cargo login
# Publish protocol first
cd crates/scarab-nav-protocol
cargo publish
# Wait for it to be available (check crates.io)
sleep 60
# Publish client
cd ../scarab-nav-client
cargo publish