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

Prepare release artifacts and inspect package contents.

Create a package tarball

Build the package as it would be published.

bashANYcargopackage
bash
cargo package
Notes

Validates and assembles the publishable package locally.

List packaged files

Show what files would go into the package.

bashANYcargopackagefiles
bash
cargo package --list
Notes

Useful for catching missing files or extra junk before publishing.

Validate publish without uploading

Run all publish checks without actually publishing.

bashANYcargopublishdry-run
bash
cargo publish --dry-run
Notes

A safer preflight step before a real crates.io publish.

Clean before a release build

Rebuild from a clean state for reproducibility.

bashANYcargoreleaseclean
bash
cargo clean && cargo build --release
Notes

Helps surface missing tracked files or stale artifacts before release.

Install binary crates

Install tools from crates.io, git, local paths, or locked dependencies.

Install a binary from crates.io

Install a published executable crate.

bashANYcargoinstallcrates-io
bash
cargo install ripgrep
Notes

`cargo install` manages Cargo's local set of installed binary crates.

Install a specific version

Pin the crate version during install.

bashANYcargoinstallversion
bash
cargo install ripgrep --version 14.1.0
Notes

Useful for reproducibility in local developer setups.

Honor the package lockfile

Use the package's lockfile when installing.

bashANYcargoinstalllocked
bash
cargo install --locked ripgrep
Notes

Common when you want installation to match the published lockfile.

Install from a local path

Build and install the current local crate.

bashANYcargoinstallpath
bash
cargo install --path .
Notes

Great for trying your CLI exactly as users would invoke it.

Install directly from git

Build and install a binary crate from a repository.

bashANYcargoinstallgit
bash
cargo install --git https://github.com/sharkdp/bat
Notes

Useful for unreleased versions or internal tools.

Remove an installed binary crate

Delete binaries installed by `cargo install`.

bashANYcargouninstall
bash
cargo uninstall ripgrep
Notes

Cleans up tools from Cargo's install root.

Publish to crates.io

Authentication, publishing, and registry-related tasks.

Save a crates.io API token

Authenticate Cargo for publishing.

bashANYcargologincrates-io
bash
cargo login <token>
Notes

Stores the token so Cargo can publish to the registry.

Manage crate owners

Add a user or team as a crate owner.

bashANYcargoownercrates-io
bash
cargo owner --add github:org:team mycrate
Notes

Useful for shared maintenance of published crates.

Publish the crate

Upload the local package to the configured registry.

bashANYcargopublish
bash
cargo publish
Notes

The default registry is crates.io unless another registry is specified.

Yank a published version

Prevent new dependency resolution to a release.

bashANYcargoyankcrates-io
bash
cargo yank --vers 1.2.3 mycrate
Notes

Yanking hides a release from new resolution without deleting it.

Release recipes

Practical release commands for Rust CLI apps.

Build an optimized release binary

Compile the release artifact for shipping.

bashANYcargoreleasebinary
bash
cargo build --release
Notes

The default production build path for many CLI apps.

Build a mostly static Linux binary

Compile against the musl target.

bashANYcargoreleasemusl
bash
cargo build --release --target x86_64-unknown-linux-musl
Notes

Common for distributing portable Linux executables.

Read current package version

Inspect the manifest version before tagging a release.

bashANYcargoreleaseversion
bash
cargo pkgid
Notes

Handy when scripting release steps, though tags are usually managed separately.

Recommended next

No recommendations yet.