- Prepare Your Project
Ensure your Cargo.toml has all required fields:
[package]
name = "crate-name"
version = "0.1.0"
edition = "2021"
description = "Brief description"
authors = ["Your Name <email@example.com>"]
license = "MIT" # or SPDX identifier
repository = "https://github.com/user/repo"
keywords = ["keyword1", "keyword2"]
categories = ["category1", "category2"]
readme = "README.md"- Create crates.io Account
- Go to https://crates.io/
- Sign up / log in
- Go to Account Settings → API Tokens
- Click "New Token"
- Give it a name and select "Public API"
- Copy the token
- Login to crates.io
cargo login
# Paste your API token when prompted- Verify Package Metadata
cargo package --allow-dirty
cargo publish --dry-runCheck for warnings about:
- Missing documentation
- Build warnings
- Dependency issues
- Publish
cargo publish- Verify Visit https://crates.io/crates/your-crate-name to verify it's published. Common Issues
- Name already taken: Choose a different name
- Missing docs: Add //! module-level docs
- License not SPDX: Use valid SPDX identifier (e.g., MIT, Apache-2.0)
- Version conflict: Must increment version (0.1.0 → 0.1.1 or 0.2.0) Versioning (SemVer)
0.1.0→0.1.1(bug fixes, compatible)0.1.0→0.2.0(new features, compatible)0.1.0→1.0.0(breaking changes) Yanking a Version If you publish with issues:
cargo yank --vers 0.1.0
cargo unyank --vers 0.1.0