Day 40, and today we are looking at how to package and release your Rust CLI app. You have written the code, added argument parsing, handled the logic, and even written tests. Now it is time to get that shiny CLI tool into the hands of others.
This process will feel familiar if you have worked with .NET global tools. Rust’s cargo
makes it easy to build, release, and share your command-line apps.
Building Your CLI Tool
The first step is to build your project. By default, Cargo builds in debug mode, but you can create an optimized release build like this:
cargo build --release
This creates the binary in the target/release/
folder:
target/release/my_cli_app
The release build is smaller and faster because it includes optimizations.
Compare this to C#, where you would run:
dotnet build -c Release
Same idea. Build your project in release mode for production use.
Installing Locally with cargo install
If you want to install your CLI tool globally on your own machine, you can use:
cargo install --path .
This installs the binary into Cargo’s global binary directory, usually ~/.cargo/bin. Make sure that the folder is in your system PATH and you can run your CLI tool from anywhere.
Compare this to .NET’s global tools:
dotnet tool install --global MyTool
Both approaches let you install a local or published tool and make it available system-wide.
Sharing Your Binary with Others
Once you have your release binary built, you can share it directly. Just send the binary file to your users. On Linux and macOS, it is ready to go. On Windows, remember to share the .exe
.
If you want to automate building for multiple platforms, check out tools like cross
or GitHub Actions to build on CI pipelines.
You can also publish your CLI app to crates.io if it is a library or to GitHub Releases if you want to distribute prebuilt binaries.
Adding Metadata for Packaging
Make sure your Cargo.toml
includes helpful metadata like this:
[package] name = "my_cli_app" version = "0.1.0" authors = ["Your Name <you@example.com>"] edition = "2021"
[dependencies]
clap = { version = “4.0”, features = [“derive”] }
This information shows up when users run --version
or --help
if you set up your CLI with clap
correctly.
Example of –version Output
my_cli_app --version my_cli_app 0.1.0
Cargo uses this info from your Cargo.toml
. No extra wiring needed.
Why This Approach Feels Good
- Cargo handles building and installing out of the box
- Release builds are optimized and ready for production
- Local installs make testing and usage easy
- Packaging feels similar to .NET global tools
Wrapping It Up
Releasing a Rust CLI tool feels smooth and intentional. With Cargo, you build, optimize, and install easily. Whether you use direct distribution or automation tools, sharing binaries with others is straightforward.
Tomorrow, we will look at benchmarking and performance checking to see if Rust really flies. See you then!