Skip to content

Packaging and Distribution

Build one set of release archives for each release. Then let each other channel use these archives or the tagged source. Examples of channels are .deb and .rpm packages, Homebrew, winget, Scoop, container images, installers, and distribution ports. This guide adds packaging jobs to the release workflow in Release automation. That guide already covers release-plz, Trusted Publishing, the build matrix, cargo-auditable, SBOMs, checksums, and attestations. Do not make a second release process.

Release archives are the hub

Most channels download a release archive or build from the tag. cargo-binstall, shell and PowerShell installers, Homebrew taps, winget portable manifests, Scoop buckets, and AUR -bin packages all download archives. Thus, the archive names are the most important packaging decision.

Archive names

Use the full Rust target triple in each archive name.

Platform Name pattern Example
Linux, macOS, BSD {bin}-{target}.tar.gz or {bin}-{version}-{target}.tar.gz my-tool-x86_64-unknown-linux-musl.tar.gz
Windows {bin}-{target}.zip or {bin}-{version}-{target}.zip my-tool-aarch64-pc-windows-msvc.zip
  • cargo-binstall tries {name}-{target}-v{version}, {name}-{version}-{target}, the underscore variants, and {name}-{target}. It looks under tag paths such as v{version}/. Here {name} is the crate name, not the binary name. If the archive names use the crate name and the full triple, Cargo.toml needs no [package.metadata.binstall] table. If the binary name is different from the crate name, for example crate ripgrep and binary rg, use the crate name in the archive names or set pkg-url in [package.metadata.binstall].
  • Put the binary at the top level of the archive or in a directory with the archive name. For other layouts, such as a bin/ directory, set bin-dir in [package.metadata.binstall].
  • Use .tar.gz, not .tar.xz, for the widest compatibility.
  • Do not use short names such as x86_64-linux. cargo-binstall cannot find these names without overrides.
  • Put the archives, SHA256SUMS, and the SBOMs on the draft release. Attest each file. Refer to Release files and verification.

Linux targets

Use a static x86_64-unknown-linux-musl and aarch64-unknown-linux-musl binary as the portable default. Rust 1.93 updated these targets to musl 1.2.5.

The musl allocator is slow for small allocations and multi-threaded work. In the musl-vs-glibc benchmark, a small malloc and free took 122.61 ns on musl and 10.78 ns on glibc.

  1. In a musl build, set mimalloc or jemalloc as the #[global_allocator].
  2. For jemalloc on aarch64, set JEMALLOC_SYS_WITH_LG_PAGE=16.
  3. Measure your own work load before you select musl or glibc. An allocator does not replace the optimized glibc string routines.

If you also publish glibc builds, set the glibc version floor explicitly. cargo-zigbuild accepts a version suffix, such as --target x86_64-unknown-linux-gnu.2.28. This is more accurate than a build on an earlier runner image, as in Target platforms and libraries.

A static binary does not get distribution fixes for C libraries. Use rustls, not OpenSSL, and scan the release lock file. Refer to cargo-audit.

GUI applications that link GTK, WebKitGTK, or Vulkan loaders cannot be fully static. Ship them as Flatpak, or as an AppImage that you build on the earliest supported distribution.

Windows and macOS targets

  • Build x86_64-pc-windows-msvc and aarch64-pc-windows-msvc with -C target-feature=+crt-static. Then the binary does not need the Visual C++ runtime DLL. winget validation fails a package that needs this DLL.
  • aarch64-pc-windows-msvc is a Tier 1 target since Rust 1.91.
  • Do not use the *-pc-windows-gnu targets for release binaries. Rust moved i686-pc-windows-gnu to Tier 2 and can demote more GNU targets.
  • aarch64-apple-darwin is Tier 1. x86_64-apple-darwin is Tier 2 with host tools. Refer to rustc platform support.

Install paths on top of the archives

Path Source Limits
cargo install --locked crates.io source Needs a full toolchain. Cannot install man pages, completions, or configuration files.
cargo binstall Release archives Falls back to a third-party host and then to a source build. Signature checks are opt-in (--only-signed).
curl | sh, irm | iex Release archives The security is HTTPS and trust in the host. A checksum from the same host gives almost no protection.

Next to each one-line installer command, give a manual procedure. Tell users to download the archive, run gh attestation verify, and then extract the binary.

Channel selection by application type

Use this table to select the first channels for a project.

Packaging decision CLI tool GUI application Service or daemon
Ship first Triple-named archives, crates.io, SHA256SUMS, attestations Signed and notarized .dmg, signed per-user Inno Setup or NSIS EXE (or MSI), Flathub, AppImage Multi-architecture distroless :nonroot OCI image with provenance and SBOM. .deb and .rpm with a hardened systemd unit.
Add next .deb from cargo-deb, Homebrew tap (later homebrew-core), winget, Scoop Main, shell and PowerShell installers Homebrew cask, winget, Scoop Extras, .deb and .rpm from the bundler, MSIX in the Microsoft Store Signed apt or dnf repository, SELinux subpackage, AppArmor profile, Podman Quadlet unit, archives
Skip or leave to others MSI (unless enterprise users ask), Snap, Flatpak, AppImage, Chocolatey Snap, Chocolatey Homebrew, winget, Flatpak, Snap, AppImage
Confinement it carries None. Only an in-process sandbox goes with an archive. Flatpak permissions and portals. macOS hardened runtime. systemd hardening. Non-root user, read-only root file system, and default seccomp. MAC policy.

The format controls which security policy goes with the software. Archives, AppImages, and curl | sh carry no OS policy. For these formats, apply the sandbox in the binary. Refer to Sandboxing.

For the CLI and GUI stacks, refer to CLI and TUI applications, Desktop GUI applications, and Web APIs.

Format and operating system matrix

“Project” means that your release workflow builds the file. Other entries are built by a third party from your source or archives. A dash means that the format does not apply.

Format Linux macOS Windows BSDs Who builds it
.tar.gz archive musl, gnu aarch64, x86_64 – FreeBSD x86_64 (optional) Project
.zip archive – Notarization container only MSVC +crt-static – Project
cargo install, cargo binstall Yes Yes Yes cargo install only crates.io and archives
curl | sh, PowerShell installer Yes Yes PowerShell – Project
.deb Yes – – – Project or Debian and Ubuntu
.rpm Yes – – – Project or Fedora
Arch and AUR Yes – – – Arch maintainers, any person (AUR)
Alpine apk Yes – – – Alpine maintainers
Nix Yes Yes – – nixpkgs or project flake
Homebrew formula Yes Yes – – homebrew-core or project tap
Homebrew cask – Signed and notarized – – homebrew-cask
MacPorts – Yes – – MacPorts maintainers
.app, .dmg – Yes – – Project
.pkg – Yes – – Project
BSD ports – – – Yes Ports maintainers
OCI image amd64, arm64 – – – Project
Flatpak Yes – – – Project, built by Flathub
Snap Ubuntu mainly – – – Project, built by Snapcraft
AppImage Yes – – – Project
MSI – – Yes – Project
EXE installer – – Inno Setup, NSIS – Project
MSIX and Microsoft Store – – Yes – Project, signed by Microsoft
winget – – Yes – Project pull request
Scoop – – Yes – Bucket maintainers
Chocolatey – – Yes – Usually community

Linux native packages

Build .deb and .rpm files in your release workflow. Also make your source easy for distributions to package.

Package build tools

Tool Formats Notes
cargo-deb .deb Needs no debian/ directory. Supports systemd-units, musl variants, and --target.
cargo-generate-rpm .rpm Needs no rpmbuild. Supports file caps and --signing_key. Does not strip binaries.
nfpm .deb, .rpm, .apk, Arch One YAML file for all formats. Signs packages.

Do not use cargo-aur or cargo-rpm. These tools are not maintained.

This cargo-deb example installs the binary, a man page, completions, and a systemd unit. cargo-deb adds the systemd scripts only when you also set maintainer-scripts. Put the unit file in that directory with the name <unit-name>.service, for example debian/my-service.service. If the unit is in a different directory, set unit-scripts to that directory. Refer to the cargo-deb systemd documentation.

[package.metadata.deb]maintainer-scripts = "debian/"assets = [  ["target/release/my-service", "usr/bin/", "755"],  ["target/assets/my-service.1", "usr/share/man/man1/", "644"],  ["target/assets/my-service.bash", "usr/share/bash-completion/completions/my-service", "644"],  ["README.md", "usr/share/doc/my-service/", "644"],]
[package.metadata.deb.systemd-units]unit-name = "my-service"enable = truestart = false

In the release workflow, use cargo deb --no-build --target "$TARGET". The package then contains the binary that the build matrix made.

Signed apt and dnf repositories

A standalone .deb gets no automatic updates. If users need updates, publish a signed repository. Follow the Debian third-party repository rules.

  1. Sign the repository InRelease file with a dedicated signing subkey that expires.
  2. Ship the public key in binary .pgp format in /usr/share/keyrings/. Use a <project>-archive-keyring package.
  3. Do not use apt-key or /etc/apt/trusted.gpg.d/.
  4. Give users a deb822 .sources file. Set Signed-By to the key file, not to a fingerprint.
  5. Pin the repository origin at priority 100 or lower.
  6. Upload pool/ before the index files. Then no index names a file that is not available.
/etc/apt/sources.list.d/my-tool.sources
Types: debURIs: https://example.github.io/aptSuites: stableComponents: mainSigned-By: /usr/share/keyrings/my-tool-archive-keyring.pgp
/etc/apt/preferences.d/my-tool
Package: *Pin: origin example.github.ioPin-Priority: 100

reprepro is sufficient for one project. GitHub Pages does not keep the repository between runs. Thus, each publication must first download the current repository. kubecolor is a good reference. It runs reprepro, pushes to a Pages branch, and ships a deb822 .sources file in the package.

For dnf, sign each RPM, run createrepo_c, and sign repomd.xml. Then publish a .repo file with gpgcheck=1. k6 shows these steps.

Caution. Package scripts operate as root. A repository signature identifies the publisher. It does not protect users from a malicious package. Keep the signing key in the protected release environment.

Distribution policies

Each distribution has its own policy for Rust dependencies.

Distribution Policy
Debian One source package for each crate (librust-*-dev). No vendored crates. No network during the build. Uses debcargo.
Fedora Packages “SHOULD NOT use bundled crate dependencies”. Vendored packages declare Provides: bundled(crate(...)). Use the rust2rpm output. BuildSystem: cargo is optional.
Ubuntu Main archive vendors crates and records them in XS-Vendored-Sources-Rust.
Arch The developer manual runs cargo fetch --locked, then cargo build --frozen. AUR packages from prebuilt binaries use the -bin suffix.
Alpine The APKBUILD Rust template builds with cargo auditable build --frozen.
openSUSE Vendors all crates with obs-service-cargo and scans them against RustSec.
Nix buildRustPackage with cargoHash or cargoLock.lockFile. For a flake, pin crane to a tag.

Distribution builds use their own compiler flags, not your [profile.release] settings. Debian stable and Ubuntu LTS can be some major versions behind. For a tool that changes quickly, tell these users to use the upstream archives or Homebrew.

Do these steps to make the source easy to package:

  1. Publish each crate to crates.io.
  2. Commit Cargo.lock.
  3. Do not use git dependencies.
  4. Keep the license field correct in each crate.
  5. Generate man pages and completions at build time.
  6. Make the tests pass offline with --frozen.
  7. Put a self-updater behind a feature that is not a default feature.

Package contents

Native packages are the only Linux formats that can carry OS confinement. Put these items in each package.

Item Location Notes
Binary /usr/bin/ Use the release binary.
man page /usr/share/man/man1/ Generate with clap_mangen.
Completions /usr/share/bash-completion/completions/ and the Zsh and Fish directories Generate with clap_complete.
systemd unit /usr/lib/systemd/system/ Services only. Harden the unit.
Configuration /etc/my-service/ cargo-deb marks files in /etc as conffiles. Use config = "noreplace" in cargo-generate-rpm.
MAC policy <pkg>-selinux subpackage, /etc/apparmor.d/ Refer to the list after this table.

Harden each systemd unit. This example is a start point. The [Install] section is necessary. Without it, enable = true cannot enable the unit at boot.

[Unit]Description=My service
[Service]ExecStart=/usr/bin/my-serviceDynamicUser=yesNoNewPrivileges=yesProtectSystem=strictProtectHome=yesPrivateTmp=yesPrivateDevices=yesCapabilityBoundingSet=SystemCallFilter=@system-serviceStateDirectory=my-service
[Install]WantedBy=multi-user.target

Check the unit in CI. The job fails if the exposure score is more than the threshold. The threshold uses a scale from 0 to 100, so --threshold=30 is a limit of 3.0 in the command output.

Terminal window
systemd-analyze security --offline=yes --threshold=30 debian/my-service.service

For a command that a user starts and that needs one privilege, set a file capability with the caps field in cargo-generate-rpm. Do not use setuid. A file capability has no effect in a unit with NoNewPrivileges=yes or an empty CapabilityBoundingSet=. For a service, set the capability in the unit with AmbientCapabilities= and add the same capability to CapabilityBoundingSet=. Refer to systemd.exec(5).

For mandatory access control (MAC) policy, use these patterns:

  • Fedora and RHEL. Ship a noarch <pkg>-selinux subpackage. Install the module with %selinux_modules_install at priority 200. Refer to SELinux/IndependentPolicy. The Fedora Packaging Committee did not approve this draft, but packages use it.
  • openSUSE. Tumbleweed, Leap 16.0, and SLES 16.0 use SELinux by default. Ship an SELinux module, not an AppArmor profile.
  • Debian and Ubuntu. Install the profile with dh_apparmor. cargo-deb has no AppArmor support. Add the profile as an asset under /etc/apparmor.d/. Copy the Debian postinst and postrm fragments into your scripts above #DEBHELPER#. In both fragments, replace #PROFILE# with the profile file name. cargo-deb replaces only #DEBHELPER#.

On Ubuntu, a binary that makes user namespaces needs an AppArmor profile with the userns, rule. Only a package that root installs can supply this profile. A tarball or an AppImage cannot. For policy contents, refer to Sandboxing.

Flatpak, Snap, and AppImage

These formats are for GUI applications. Do not use them for a plain CLI tool.

Flatpak and Flathub

Flathub is the main Linux GUI channel. Flathub requires a build from source with no network access.

  1. Generate cargo-sources.json from Cargo.lock with flatpak-cargo-generator.py. Commit the file with the manifest.
  2. Build with the rust-stable SDK extension. Its branch must match the runtime version.
  3. Select a current runtime. Use org.freedesktop.Platform//26.08 for iced, egui, and wgpu applications. Use a current GNOME runtime for GTK, libadwaita, and Tauri applications.
  4. Use an io.github.<user>.<repo> application ID for a project on GitHub.
  5. Keep static permissions to a minimum. Use portals where a portal is available. Refer to Sandboxing.

Caution. The 26.08 rust-stable extension supplies Rust 1.98.0, which is older than the current stable release. Updates on the 26.08 branch need a manual merge by a Flathub maintainer. Make sure that your MSRV is not more than the extension version. Refer to Minimum supported Rust version.

Caution. Flathub states that “Flathub manifests must not contain AI-generated or AI-assisted content”. A person must write the Flathub manifest.

Snap

The Snapcraft rust plugin builds Rust snaps. Use base: core24 or core26. A developer tool that touches arbitrary paths needs classic confinement, which removes the sandbox and needs manual store approval. Use Snap only as a secondary channel.

AppImage

  1. Use appimagetool with the static type2 runtime. This runtime does not need libfuse2.
  2. Pin a tagged release, or record the SHA-256 of the continuous download.
  3. Build on the earliest distribution that you support, such as Ubuntu 22.04.
  4. Sign the AppImage with appimagetool -s. Add zsync update information.

AppImage has no reviewed store and no OS confinement.

macOS

Homebrew 7 rules

Homebrew is the main macOS channel for CLI tools. Apply these rules.

  1. homebrew-core needs a known project. A third-party submission needs 75 stars (or 30 forks or watchers). A self-submission needs 225 stars (or 90 forks or watchers). Refer to the acceptance policy.
  2. homebrew-core builds from source. BrewTestBot updates core formulae every 3 hours. You do no release work for a formula in core.
  3. Use a tap until core accepts the project. dist and GoReleaser generate tap formulae. In GoReleaser, use homebrew_casks. The brews pipe is deprecated.
  4. Users must trust a tap. Homebrew 6.0.0 added tap trust. In README.md, give brew install owner/tap/my-tool. This command trusts only that item.
  5. Every cask must pass Gatekeeper. Homebrew disabled 627 casks for fails_gatekeeper_check in September and October 2026. The audit also examines suite folders, artifact items, and installer scripts. Sign and notarize each Mach-O file in a cask.
  6. Users cannot skip quarantine. Homebrew 6.0.0 removed --no-quarantine. Homebrew quarantines all cask downloads.
  7. Intel Macs are Tier 3. Homebrew 7.0.0 moved Intel macOS to Tier 3. Support stops on 2027-09-01. Bottles need macOS 15 or later. If you support Intel Macs, publish your own x86_64 or universal binaries. Refer to the Homebrew 7.0.0 notes.

A native .app is not a formula. Submit a GUI application to homebrew-cask and point the cask to the notarized .dmg.

MacPorts

MacPorts builds Rust ports with PortGroup cargo 1.0 and a crate list from cargo2port. The +universal variant is easy to add. Let community maintainers keep the port. Refer to the MacPorts Guide.

Signing and notarization

Outside the Mac App Store, Gatekeeper needs a signed and notarized program. An Apple Developer Program membership costs US$99 each year. Sign with a Developer ID certificate, the hardened runtime, and a secure timestamp. Submit with notarytool, not altool.

Use the correct identity for each container. Refer to Packaging Mac software for distribution.

Container Signing identity Staple a ticket
.app and Mach-O binaries Developer ID Application .app: yes. Standalone binary: no.
.dmg (read-only UDZO) Developer ID Application Yes
.pkg Developer ID Installer Yes
.zip Not signed No

Sign nested code first. Notarize only the outermost container. Without a stapled ticket, a Mac with no network can block the program.

A bare CLI binary gets a stapled ticket only in a .pkg or a .dmg. This example makes a signed and notarized .pkg on a macOS runner.

Terminal window
codesign --force --options runtime --timestamp \  --sign "Developer ID Application: Example Ltd (TEAMID)" stage/my-toolpkgbuild --root stage --install-location /usr/local/bin \  --identifier com.example.my-tool --version "$VERSION" \  --sign "Developer ID Installer: Example Ltd (TEAMID)" --timestamp \  my-tool.pkgxcrun notarytool submit my-tool.pkg \  --key AuthKey.p8 --key-id "$ASC_KEY_ID" --issuer "$ASC_ISSUER_ID" --waitxcrun stapler staple my-tool.pkg

To sign and notarize from a Linux runner, use rcodesign from apple-codesign. Use an App Store Connect API key.

Terminal window
rcodesign sign --p12-file developer-id.p12 --p12-password-file p12-password.txt \  --for-notarization MyApp.apprcodesign notary-submit --api-key-file asc-key.json --staple MyApp.app

This example notarizes and staples the signed .app. To ship a .dmg, make the .dmg from the stapled .app, sign it, and then submit the .dmg.

The last rcodesign release is from November 2024. Pin it, and keep a macOS runner with codesign and notarytool as a fallback.

Caution. Notarization can take a long time. Set timeout-minutes on the job.

Keep the certificates and API keys in the protected release environment. Refer to Secure development lifecycle.

When a CLI needs notarization

Gatekeeper examines only files with the com.apple.quarantine attribute. Safari and Homebrew casks set this attribute. curl and Homebrew formula bottles do not. Thus, users of curl | sh, formulae, and cargo install do not start Gatekeeper. Notarize each .pkg, .dmg, and cask download.

Universal binaries

Cargo cannot build a universal binary. Build aarch64-apple-darwin and x86_64-apple-darwin. Then combine the two binaries with lipo.

Terminal window
lipo -create -output stage/my-tool \  target/aarch64-apple-darwin/release/my-tool \  target/x86_64-apple-darwin/release/my-tool

Run lipo before you sign, because lipo makes signatures invalid. Tauri uses --target universal-apple-darwin. dist cannot build universal binaries.

Hardened runtime entitlements

The hardened runtime decreases the risk of exploits. It is not a resource sandbox. A typical Rust CLI or server needs no runtime exceptions.

Entitlement Use it when Notes
com.apple.security.cs.allow-jit The program embeds a JIT compiler. Permits MAP_JIT memory.
com.apple.security.cs.disable-library-validation The program loads plug-ins signed by a different team. Gatekeeper does more checks.
com.apple.security.cs.allow-unsigned-executable-memory Do not use. Apple states that it “exposes your app to common vulnerabilities”.

Put entitlements only on executables. Do not write an entitlement with the value false. Leave it out. The Mac App Store needs App Sandbox entitlements. Refer to Sandboxing.

Services with launchd

  • A launchd job is a plist with Label and ProgramArguments in /Library/LaunchDaemons. The program must not daemonize itself.
  • For an application on macOS 13 or later, put the plist in the bundle and register it with SMAppService. An administrator must approve a daemon in System Settings.
  • For a CLI daemon from Homebrew, add a service do block to the formula. Users then start it with brew services. Refer to Service files.

Windows

Format selection

Format Use it for Notes
.zip CLI tools One static MSVC .exe for each target. winget and Scoop install it as a portable package.
Inno Setup EXE GUI applications Per-user install with PrivilegesRequired=lowest and no UAC prompt. Refer to Zed.
NSIS EXE GUI applications Tauri uses NSIS. No fee.
MSI Enterprise deployment with Group Policy or Intune Keep the UpgradeCode stable.
MSIX Microsoft Store Microsoft signs the package. No SmartScreen warning.

The Microsoft Store is free for individual developers. Microsoft re-signs each MSIX package after certification. Make the package with the winapp CLI (public preview). Do the first Store submission manually in Partner Center.

MSI with WiX

WiX v7 uses the Open Source Maintenance Fee EULA. The fee of US$10 to US$60 each month applies to revenue work with annual gross revenue of US$10,000 or more. Each WiX v7 command fails until you accept wix7.

Tool WiX version ARM64
cargo-wix 0.3.9 (released) v3.14.1 only No. Fails with CNDL0264.
cargo-wix from git main with --toolset modern v4 to v7 Yes
dist, Tauri bundler v3.14.1 No

WiX v3 has no upstream support. For a new MSI, use cargo-wix from git with --toolset modern. bottom (WiX 4) and PWAsForFirefox (WiX 7.0.1) build ARM64 MSIs this way.

Terminal window
dotnet tool install --global wix --version 7.0.1wix eula accept wix7cargo install --locked --git https://github.com/volks73/cargo-wix --rev FULL_COMMIT_SHA cargo-wixcargo wix --toolset modern --no-build --target x86_64-pc-windows-msvc

Pin cargo-wix to a full commit hash and pin the wix tool version. To use WiX without the fee terms, pin WiX v5 or earlier.

winget, Scoop, and Chocolatey

Manager How it gets updates Your work
winget Manifest pull request to microsoft/winget-pkgs Do the first submission. Then automate updates with Komac.
Scoop Bucket checkver and autoupdate Submit once to Main (CLI) or Extras (GUI).
Chocolatey A person reviews each new version Usually let a community maintainer do it.

winget validation checks the hash, the installer domain, a silent install and uninstall, Visual C++ runtime dependencies, and antivirus scans. Use GitHub release URLs. Do not use URL redirectors. winget does not require a code signature. Komac needs a classic personal access token with the public_repo scope. A fine-grained token cannot open the pull request.

winget and Scoop installs usually avoid the Mark-of-the-Web prompt. Smart App Control still blocks unsigned executables that have no reputation.

Code signing

Microsoft states that the EV certificate SmartScreen bypass “was removed in 2024”. Do not buy an EV certificate only for SmartScreen.

Option Cost Publisher name Notes
Azure Artifact Signing US$9.99 each month (Basic, 5,000 signatures) Your validated legal name Needs a paid Azure subscription. Organizations in the USA, Canada, EU, UK, and some other countries. Individuals in the USA or Canada only. Keys stay in an HSM.
SignPath Foundation Free for eligible open-source projects “SignPath Foundation” OSI license, no proprietary parts, MFA for all members, and manual approval of each release. Shared OV certificate. All jobs before the signing request must use GitHub-hosted runners.
OV certificate About US$150 to US$300 each year Your name Key must be in an HSM. Maximum validity is 460 days.
MSIX in the Store Free Your Store name Microsoft signs the package.
  • A SignPath project shares SmartScreen reputation with all other SignPath projects. Add a manual approval gate before the SignPath signing job.
  • SmartScreen reputation increases over “several weeks and hundreds of clean installs”.
  • osslsigncode signs Authenticode files from a Linux runner.
  • Sign the .exe before you put it in the .zip. Sign each installer and uninstaller.

Signing identifies the publisher. It does not confine the program. For Windows process mitigation policies, refer to Sandboxing.

Windows services

  1. Implement the Service Control Manager entry point with windows-service. Microsoft also publishes the smaller windows-services crate.
  2. Register the service in the MSI with the WiX ServiceInstall and ServiceControl elements. Windows Installer then does repair and uninstall.
  3. Write a custom main.wxs. The default cargo-wix template has no service elements. Firezone is an example.

If a binary has no SCM support, use WinSW or shawl. Do not use NSSM.

BSD ports

FreeBSD, OpenBSD, and NetBSD users usually install from ports. Each port system downloads each crate as a distfile with a checksum and builds offline.

System Framework Crate list command
FreeBSD USES=cargo make cargo-crates
OpenBSD MODULES=devel/cargo make modcargo-gen-crates
NetBSD pkgsrc lang/rust/cargo.mk make print-cargo-depends

FreeBSD and NetBSD x86_64 are Tier 2 targets. OpenBSD is Tier 3, so an OpenBSD binary needs a native build. Git dependencies are difficult in all three systems.

  1. Follow the source rules in Distribution policies.
  2. Do a build and test on FreeBSD each week or before each release. Use vmactions/freebsd-vm in GitHub Actions.
  3. Optionally, attach a FreeBSD x86_64 archive to the release.
  4. Let ports maintainers make and update the ports.

Cirrus CI stopped operation on 1 June 2026. Add the FreeBSD job to the scheduled checks in CI/CD pipeline.

Container images

Ship a service as a multi-architecture OCI image. Use a minimal base image and a non-root user. For application settings, refer to Container packaging and deployment.

Binary Base image Compressed size (amd64)
glibc gcr.io/distroless/cc-debian13:nonroot About 10.7 MB
Static musl gcr.io/distroless/static-debian13:nonroot About 0.9 MB
Static musl scratch 0 MB. Has no CA certificates or /etc/passwd. Copy a CA bundle into the image if the binary makes outbound TLS connections.

debian:trixie-slim is about 30 MB and gives scanners more advisories to triage.

# syntax=docker/dockerfile:1FROM rust:1-slim-trixie@sha256:BUILDER_DIGEST AS buildWORKDIR /srcRUN cargo install --locked cargo-auditableCOPY . .RUN --mount=type=cache,target=/usr/local/cargo/registry \    --mount=type=cache,target=/src/target \    cargo auditable build --release --locked \    && cp target/release/my-service /my-service
FROM gcr.io/distroless/cc-debian13:nonroot@sha256:RUNTIME_DIGESTCOPY --from=build /my-service /usr/local/bin/my-serviceUSER 65532:65532ENTRYPOINT ["/usr/local/bin/my-service"]
  1. Pin each base image by digest.
  2. Build with cargo auditable. Without it, an SBOM scan of a minimal image finds no Rust crates.
  3. Cache dependencies with BuildKit cache mounts or cargo-chef layers.
  4. Do not compile under QEMU emulation. Build each platform on a native runner (ubuntu-24.04 and ubuntu-24.04-arm) and merge the manifests. Or build on $BUILDPLATFORM and cross-compile with cargo-zigbuild. Refer to Multi-platform builds.
  5. Push to GitHub Container Registry.
  6. In docker/build-push-action, set provenance: mode=max, sbom: true, and push: true. Refer to Docker attestations.
  7. Attest the image digest with actions/attest and subject-digest. Users verify it with gh attestation verify oci://….
  8. Optionally, sign the image with keyless Cosign v3.

At run time, the image must meet the Kubernetes restricted Pod Security Standard. Set runAsNonRoot, the RuntimeDefault seccomp profile, no privilege escalation, drop: ["ALL"] capabilities, and readOnlyRootFilesystem. An image must never need --privileged or seccomp=unconfined.

For a single host, supply a Podman Quadlet .container unit. Set ReadOnly=true, NoNewPrivileges=true, DropCapability=all, UserNS=auto, and a non-root User=. Do not set SeccompProfile=. Then the default profile applies. Refer to Sandboxing.

For Kubernetes charts, use Helm 4. Helm 3 security fixes stopped on 2026-11-11.

Tool selection

No one tool makes all formats. Many large projects use their own workflows.

Tool Makes Use it for Cautions
dist Archives, shell and PowerShell installers, Homebrew tap, MSI (WiX v3), checksums, attestations CLI installers Community-maintained by one person since Axo closed (maintainer). No .deb, .rpm, .pkg, or notarization.
GoReleaser Archives, nfpm packages, Homebrew, Scoop, winget, AUR, Docker Projects that already use GoReleaser Rust support is alpha. Weak workspace support. Defaults to x86_64-pc-windows-gnu. DMG, MSI, and notarization need Pro.
Tauri bundler .app, .dmg, MSI, NSIS, .deb, .rpm, AppImage Tauri applications Signs and notarizes. MSI uses WiX v3.
cargo-packager Same as Tauri, with a signed updater egui, iced, and Slint applications No crates.io release since November 2025.
dx bundle (Dioxus) Desktop and mobile bundles Dioxus applications Uses its own copy of the Tauri bundler since 0.7.4.
cargo-bundle .app, .dmg, .deb, .rpm, MSI Simple GUI applications Early alpha. Signs but does not notarize.
taiki-e/upload-rust-binary-action Archives and checksums Small CLI projects No packages.
cargo-zigbuild Cross builds glibc version floor, musl Does not target the BSDs.
cross Cross builds in containers Targets that cargo-zigbuild does not support No release since February 2023. Pin a git revision.

Extend the release workflow

Release automation already makes the tag, the draft release, the binaries, the SBOMs, and the attestations. Add packaging jobs to this workflow. Do not replace it with a different release tool.

Job needs Adds Signing and attestation
release-pr, release (current) – Version, changelog, crates.io, tag, draft release Trusted Publishing, release environment
build-binaries (extend) release musl targets, +crt-static MSVC, x86_64-apple-darwin Windows and macOS signatures before the archive step
package-linux (new) build-binaries .deb, .rpm, man pages, completions, systemd unit RPM signatures, systemd-analyze security gate
package-gui (new, GUI only) build-binaries .dmg, EXE or MSI, AppImage Notarization, stapled ticket, Authenticode
container (services) release Multi-architecture image on GHCR BuildKit provenance and SBOM, actions/attest
SBOM and checksum step (extend) All packaging jobs Add .deb, .rpm, .msi, .exe, .dmg, .AppImage to SHA256SUMS and to subject-path One attestation set for each file
publish-release (current) Each job that uploads Removes the draft flag gh release verify
distribute (new) publish-release winget, Homebrew tap, apt and dnf repositories, AUR -bin Repository signing subkey from the release environment

Obey these rules when you add jobs:

  1. Upload all files before publication. Add each packaging job to the needs list of publish-release. Refer to Build provenance attestations and immutable releases.
  2. Sign first, then calculate checksums, then attest. A signature changes the file.
  3. Start distribution jobs with needs, not with on: release. publish-release uses the default GITHUB_TOKEN, which does not start on: release workflows. Refer to GitHub App token for the release workflow.
  4. Use the GitHub release URLs in winget and Scoop manifests.

Example distribute job for winget

This job sends the winget update after publication. Keep the classic token in the release environment. Do not put the token on the command line.

  distribute-winget:    needs: [release, publish-release]    if: ${{ needs.release.outputs.releases_created == 'true' }}    runs-on: ubuntu-latest    environment: release    permissions: {}    steps:      - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master        with:          toolchain: stable      - name: Install Komac        run: cargo install --locked komac --version 2.17.2      - name: Submit winget update        env:          # Classic PAT with the public_repo scope. Komac reads GITHUB_TOKEN.          GITHUB_TOKEN: ${{ secrets.WINGET_TOKEN }}          RELEASES: ${{ needs.release.outputs.releases }}          BASE: https://github.com/${{ github.repository }}/releases/download        run: |          # Select the entry for this package. A workspace release can contain          # entries for other packages.          entry=$(jq -ec '.[] | select(.package_name == "my-tool")' <<< "$RELEASES") || exit 0          version=$(jq -er '.version' <<< "$entry")          tag=$(jq -er '.tag' <<< "$entry")          komac update Example.MyTool --version "$version" --submit \            --urls "$BASE/$tag/my-tool-x86_64-pc-windows-msvc.zip" \                   "$BASE/$tag/my-tool-aarch64-pc-windows-msvc.zip"

If the release does not contain my-tool, the step stops without a submission. The URLs use the {bin}-{target}.zip archive names. If you put the version in the archive name, change the URLs to agree. Do the first winget submission manually.

dist installers with release-plz drafts

Add dist only for its shell and PowerShell installers or its Homebrew tap. With create-release = false, dist uploads its files to the release-plz draft and then removes the draft flag. Refer to the create-release setting.

dist-workspace.toml
[workspace]members = ["cargo:."]
[dist]cargo-dist-version = "0.34.0"ci = "github"create-release = falsecargo-auditable = trueinstallers = ["shell", "powershell"]github-attestations = truegithub-attestations-phase = "host"github-release = "host"targets = ["aarch64-apple-darwin", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"]

Quantinuum/hugr uses this configuration with git_release_draft = true in release-plz.toml.

  1. Make the dist tag pattern agree with git_tag_name in release-plz.toml. For a prefixed tag, set tag-namespace.
  2. Push the tag with a GitHub App token or a personal access token. A tag from the default GITHUB_TOKEN does not start the dist workflow. The release job in The release workflow already uses an App token.
  3. Use one publication step. The dist workflow starts from the tag, so it runs separately from the release-plz workflow. A needs list in one workflow cannot wait for a job in the other. Remove publish-release from the release-plz workflow, and let dist remove the draft flag.
  4. Move the SBOMs, checksums, attestations, and packaging jobs into the dist workflow as custom jobs. Use global-artifacts-jobs for jobs that use the archives that dist builds. These jobs start after the local builds, and the dist host job waits for them before it publishes. Do not put uploads in host-jobs. These jobs run at the same time as the host job, which can publish before they finish. dist starts all global-artifacts-jobs at the same time. Thus, put the packaging, signing, checksum, and attestation steps in one reusable workflow, in that order. If they are separate jobs, the checksum job can finish before the packages exist. These jobs also run at the same time as the dist job that builds the shell and PowerShell installers, so they cannot see the installers. Make your checksum file and attestations cover only the files that your job makes. dist makes its own checksums for the archives and installers, and github-attestations = true with github-attestations-phase = "host" attests them. The default phase runs before dist builds the installers, so it attests only the archives. The host phase needs github-release = "host". release-plz pushes the tag before it creates the draft release. If the dist host job starts before the draft exists, the upload fails. Run the dist workflow again after the draft exists. cargo-auditable = true makes dist embed the dependency list in each binary. A later job cannot add it to a binary that is already built.
  5. Run the distribute jobs, such as winget, as post-announce-jobs. These jobs are reusable workflows. They get the dist plan as the plan input, not the release-plz outputs. Read the tag and version from the plan, for example jq -r '.announcement_tag' <<< "$PLAN". Remove the needs list and the if condition of the example distribute job, because the release job outputs do not exist in the dist workflow. A post-announce-jobs job runs only after dist publishes a release. To skip releases that do not contain my-tool, select from the plan, for example jq -e '.releases[] | select(.app_name == "my-tool")' <<< "$PLAN".
  6. The dist workflow runs on the tag, not on main. If the release environment allows only main, add a deployment rule for the release tag pattern, such as v*. Keep the required reviewers on the environment.

Caution. If a job in one workflow uploads files while a job in the other workflow publishes the release, the uploads can fail because a published release is immutable. If you cannot put all uploads in one workflow, do not use dist.

Further reading