Skip to main content

rust-toolchain

Install Rust and cache cargo in one action

Reads the rust-toolchain.toml you already committed, installs it with rustup, and restores and saves the cargo cache in layers — no second action required.

rust-toolchain.toml by default

The channel, targets, components and profile come from the file already in your repository. Action inputs override it — scalars are replaced, lists merge deduped with your inputs leading.

Layered cargo cache

The registry and target directories are keyed separately, so a compiler bump no longer re-downloads the crates it never touched. The build key folds in the resolved toolchain and the CARGO_/RUST* environment.

Saves what is worth saving

An exact hit is never re-saved, a layer over cache-budget is skipped with a warning, and every layer's real outcome is reported in the job summary rather than behind one cache-hit boolean.

RUSTUP_TOOLCHAIN wins later steps

rustup default alone loses to a workspace rust-toolchain.toml. The resolved channel is exported so it applies to every later step, with set-rustup-toolchain false for monorepos that pin per crate.

Typed outputs with provenance

Every resolved value is published, lists as JSON arrays, plus a json output carrying all of them natively typed alongside inputs and toml blocks saying where each value came from.

A drop-in superset

The cachekey output matches dtolnay/rust-toolchain byte for byte, and cache-workspaces takes the same syntax as Swatinem/rust-cache, so an existing value transfers unchanged.