cargo-publish
Upload a package to a registry
TLDR
Publish to crates.io
SYNOPSIS
cargo publish [options]
DESCRIPTION
cargo publish uploads a package to crates.io or another registry. It creates a `.crate` archive, verifies that the archive builds successfully, and then uploads it to the registry. Authentication is required and is typically set up via `cargo login`.
Publishes are permanent and cannot be deleted or overwritten. Once a version is published, that exact version number can never be reused. The `cargo yank` command can mark a version as deprecated to prevent new projects from depending on it, but it remains available for existing users. Before publishing, ensure the version number in Cargo.toml has been incremented according to semver conventions.
PARAMETERS
--dry-run
Perform checks without uploading--no-verify
Skip build verification--allow-dirty
Allow uncommitted VCS changes--registry name
Target registry--index url
Registry index URL--token token
API token-p, --package spec
Package to publish--target triple
Build target for verification-j, --jobs n
Parallel jobs--features features
Enable features for verification--all-features
Enable all features
CONFIGURATION
~/.cargo/credentials.toml
Stores API tokens for crates.io and other registries. Created by `cargo login`.
PREPARATION
1. Create account on crates.io
2. Verify email address
3. Generate API token
4. Run cargo login
RELEASING NEW VERSIONS
1. Update version in Cargo.toml
2. Optionally run cargo package
3. Run cargo publish
CAVEATS
Publishes are permanent. Use cargo yank to mark versions as deprecated but not delete them. Follow semver for version changes.
SEE ALSO
cargo(1), cargo-package(1), cargo-yank(1)
