a6aa0c4ae8
- Updated Rust toolchain checks to use a prefix-aware grep pattern when validating installed components. - Simplified the Zig installer action to extract into ~/.local and add the archive directory directly to PATH. - Adjusted runner checks to parse sccache and gh version output via positional shell fields for stability.
60 lines
2.2 KiB
YAML
60 lines
2.2 KiB
YAML
name: "ensure rust toolchain"
|
|
description: >
|
|
Ensure a pinned rustup toolchain, optional components, and an optional target
|
|
are present, then prepend the real toolchain bin dir to PATH.
|
|
|
|
inputs:
|
|
toolchain:
|
|
required: true
|
|
description: Rust toolchain name (for example nightly-2026-04-29)
|
|
components:
|
|
required: false
|
|
default: ""
|
|
description: Optional comma-separated rustup components
|
|
target:
|
|
required: false
|
|
default: ""
|
|
description: Optional rustup target triple
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- shell: bash
|
|
env:
|
|
TOOLCHAIN: ${{ inputs.toolchain }}
|
|
COMPONENTS: ${{ inputs.components }}
|
|
TARGET: ${{ inputs.target }}
|
|
run: |
|
|
set -euo pipefail
|
|
if ! command -v rustup >/dev/null 2>&1; then
|
|
curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs \
|
|
| sh -s -- -y --default-toolchain "$TOOLCHAIN" --profile minimal
|
|
fi
|
|
|
|
if ! rustc +"$TOOLCHAIN" --version >/dev/null 2>&1; then
|
|
rustup toolchain install "$TOOLCHAIN" --profile minimal --no-self-update
|
|
fi
|
|
rustup default "$TOOLCHAIN"
|
|
|
|
missing_components=()
|
|
if [ -n "$COMPONENTS" ]; then
|
|
IFS=',' read -r -a wanted_components <<< "$COMPONENTS"
|
|
for component in "${wanted_components[@]}"; do
|
|
[ -z "$component" ] && continue
|
|
if ! rustup component list --toolchain "$TOOLCHAIN" --installed | grep -qE "^${component}(-|$)"; then
|
|
missing_components+=("$component")
|
|
fi
|
|
done
|
|
fi
|
|
if [ ${#missing_components[@]} -gt 0 ]; then
|
|
rustup component add --toolchain "$TOOLCHAIN" "${missing_components[@]}"
|
|
fi
|
|
|
|
if [ -n "$TARGET" ] && ! rustup target list --toolchain "$TOOLCHAIN" --installed | grep -qx "$TARGET"; then
|
|
rustup target add --toolchain "$TOOLCHAIN" "$TARGET"
|
|
fi
|
|
|
|
toolchain_bin="$(dirname "$(rustup which cargo --toolchain "$TOOLCHAIN")")"
|
|
echo "$toolchain_bin" >> "$GITHUB_PATH"
|
|
echo "Using Rust toolchain: $(rustc +"$TOOLCHAIN" --version)"
|