Rust CLI Package, Install, Publish, and Release

Package local crates, install binaries, publish to crates.io, and prepare Rust CLI releases.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Local packaging
Create a package tarball
cargo package

# Build the package as it would be published.

List packaged files
cargo package --list

# Show what files would go into the package.

Validate publish without uploading
cargo publish --dry-run

# Run all publish checks without actually publishing.

Clean before a release build
cargo clean && cargo build --release

# Rebuild from a clean state for reproducibility.

## Install binary crates
Install a binary from crates.io
cargo install ripgrep

# Install a published executable crate.

Install a specific version
cargo install ripgrep --version 14.1.0

# Pin the crate version during install.

Honor the package lockfile
cargo install --locked ripgrep

# Use the package's lockfile when installing.

Install from a local path
cargo install --path .

# Build and install the current local crate.

Install directly from git
cargo install --git https://github.com/sharkdp/bat

# Build and install a binary crate from a repository.

Remove an installed binary crate
cargo uninstall ripgrep

# Delete binaries installed by `cargo install`.

## Publish to crates.io
Save a crates.io API token
cargo login <token>

# Authenticate Cargo for publishing.

Manage crate owners
cargo owner --add github:org:team mycrate

# Add a user or team as a crate owner.

Publish the crate
cargo publish

# Upload the local package to the configured registry.

Yank a published version
cargo yank --vers 1.2.3 mycrate

# Prevent new dependency resolution to a release.

## Release recipes
Build an optimized release binary
cargo build --release

# Compile the release artifact for shipping.

Build a mostly static Linux binary
cargo build --release --target x86_64-unknown-linux-musl

# Compile against the musl target.

Read current package version
cargo pkgid

# Inspect the manifest version before tagging a release.

Recommended next

No recommendations yet.