name: Setup Rust description: Install the Rust toolchain (+ optional targets) and restore the build cache. inputs: target: description: Comma-separated extra target triples to install required: false default: '' save-cache: description: Whether to save the Rust cache required: false default: 'false' restore-cache: description: Whether to restore the Rust cache required: false default: 'true' cache-namespace: description: > Cache namespace. Workflows that compile with different profile settings MUST use different namespaces - cargo fingerprints every dependency by its profile, so sharing one would mean each workflow evicts artifacts the other cannot use. required: false default: release-cache runs: using: composite steps: - name: Install Rust (stable) uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable branch @ 2026-07-16 with: toolchain: stable targets: ${{ inputs.target }} components: cargo, clippy, rustc, rustfmt - name: Cache Rust if: ${{ inputs.restore-cache == 'true' }} uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 with: key: ${{ inputs.target }} save-if: ${{ inputs.save-cache }} shared-key: ${{ inputs.cache-namespace }} # Release builds are long and can fail late (signing, notarization, # upload). Without this the whole compile is thrown away on those runs. cache-on-failure: true