name: 'Setup Rust'
description: 'Install Rust toolchain with caching'
inputs:
toolchain:
description: 'Rust toolchain version'
required: false
default: 'stable'
components:
description: 'Additional components (comma-separated)'
required: false
default: ''
target:
description: 'Target triple for cross-compilation'
required: false
default: ''
runs:
using: 'composite'
steps:
- name: Install Rust toolchain
shell: bash
run: |
rustup toolchain install ${{ inputs.toolchain }} --profile minimal
rustup default ${{ inputs.toolchain }}
- name: Install components
if: inputs.components != ''
shell: bash
run: |
IFS=',' read -ra COMPONENTS <<< "${{ inputs.components }}"
for component in "${COMPONENTS[@]}"; do
rustup component add "$component"
done
- name: Add target
if: inputs.target != ''
shell: bash
run: rustup target add ${{ inputs.target }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ inputs.target || 'default' }}
- name: Show toolchain info
shell: bash
run: |
rustc --version
cargo --version