How to distribute Rust binaries

I am building a CLI application which I'd like to distribute as a cross platform binary file, installable on windows, Mac and Linux Operating System.

I found the trust crate, but I don't seem to be able to configure it right.

Are there options to distribute Rust Binaries other than Cargo and the trust crate?

1 Like

For Debian/Ubuntu, I use cargo-deb. For distro-agnostic executables it's possible to make static executables using MUSL target.

For macOS and Windows I compile natively on each platform and just zip them up.


That might work, but I'm using Ubuntu as development machine alone

For Windows you can install the MinGW toolchain on your Linux system and then compile for the x86_64-pc-windows-gnu target. You likely only need to set the mingw linker as linker to be used by rustc. As for macOS I don't think you can cross-compile to it. You need the macOS import libraries (.tbd) one way or another and I am not sure if you are allowed to use those on non-macOS systems.



For that I'll have to upload the binaries, is it not possible to have a build script (via GitHub actions or something) that the user can trigger to download the binaries that corresponds to their OS

For open source projects that don't need an installer I use GitHub Actions. A 118 line example is available here.

(The instructions in the README are getting updated as I write this.)


This seems very promising and close to what I'm looking for, just to be sure, I can do something like
curl --location

and I'll have the binary file built, downloaded and installed, right?

That configuration builds on all git push. The artifacts end up on the releases page. The curl command just downloads an artifact from the releases page.

A better approach is to build on merge-to-main or on push-tag. That gives better control over what is built and when.

I went with build-on-push as a matter of expediency. If the project becomes "sticky" I'll change it to something else.

Ooh. I think I crossed paths with a GitHub Actions bug. It's actually configured to build on push-to-master. It was configured to build on push-to-master. There is no master branch. And it builds on all pushes.

The install is by-hand. You'll have to copy the binary to a location on the PATH, modify the PATH, or run it from the current working directory. The latter is the example in that version of the README file.

There is always the "script" option.
You could maybe make a polyglot script that.

1 calls to install toolchain.
2 curls your sources.
3 from inside your source dir run "cargo install --path ."
4 call rustup to remove toolchain, but make sure not to delete the path to your installed binary.

Silly, yes.
But will, I believe get around "signatures" and app permissions type stuff. Mac os libraries, etc.

Sounds interesting could you give an example

I read a lot. Have never made one. Wikipedia has some examples.

Good luck and I hope I did not nerd snipe.

1 Like

To an extent this works, could you share a guide on writing GitHub actions/ workflows

Not really. I use GitHub's documentation, Stack Overflow, Stack Exchange, Reddit, via Google Search to find what I need. I've not found a one-stop guide.

If you have specific questions I may be able to help.

1 Like

is an example of a polyglot rustc and bash file. When executed as bash script it compiles itself using an existing rustc installation and then runs the compiled executable.


WebAssembly :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.