diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39b7cef..a453f37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,19 +12,19 @@ permissions: jobs: install: - name: Rust ${{matrix.rust}} on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}} - runs-on: ${{matrix.os}}-latest + name: Rust ${{matrix.rust}} on ${{matrix.os}} + runs-on: ${{matrix.os}} strategy: fail-fast: false matrix: - os: [ubuntu, macos, windows] + os: [ubuntu-latest, macos-latest, windows-latest, windows-11-arm, ubuntu-22.04-arm] rust: [nightly, beta, stable, 1.62.0, stable 18 months ago, stable minus 8 releases] include: - - os: ubuntu + - os: ubuntu-latest rust: 1.0.0 timeout-minutes: 45 steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: ./ name: Run dtolnay/rust-toolchain${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}} id: toolchain diff --git a/README.md b/README.md index 2ea5437..fc44f15 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,15 @@ jobs: name: cargo test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: dtolnay/rust-toolchain@stable - run: cargo test --all-features ``` The selection of Rust toolchain is made based on the particular @rev of this Action being requested. For example "dtolnay/rust-toolchain@nightly" pulls in -the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.42.0" pulls in -1.42.0. +the nightly Rust toolchain, while "dtolnay/rust-toolchain@1.89.0" pulls in +1.89.0.
@@ -40,7 +40,7 @@ All inputs are optional. toolchain - Rustup toolchain specifier e.g. stable, nightly, 1.42.0, nightly-2022-01-01. + Rustup toolchain specifier e.g. stable, nightly, 1.89.0, nightly-2025-01-01. Important: the default is to match the @rev as described above. When passing an explicit toolchain as an input instead of @rev, you'll want to use "dtolnay/rust-toolchain@master" as the revision of the action. @@ -66,7 +66,7 @@ All inputs are optional. cachekey - A short hash of the installed rustc version, appropriate for use as a cache key. "20220627a831" + A short hash of the installed rustc version, appropriate for use as a cache key. "20250627a831" name @@ -99,6 +99,18 @@ compiler support.
+## Choice of full-length commit SHA + +In a workflow that [pins the action][pin] using a full-length commit SHA (as +opposed to something like @nightly or @1.89.0) it is required that you pick a +SHA that is within the history of the master branch. Any commit that is not +within the history of master will eventually get garbage-collected and your +workflows will fail. + +[pin]: https://docs.github.com/en/actions/reference/security/secure-use#using-third-party-actions + +
+ ## License The scripts and documentation in this project are released under the [MIT diff --git a/action.yml b/action.yml index 3e127bb..bea2792 100644 --- a/action.yml +++ b/action.yml @@ -30,7 +30,11 @@ runs: - id: parse run: | : parse toolchain version - if [[ $toolchain =~ ^stable' '[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then + if [[ -z $toolchain ]]; then + # GitHub does not enforce `required: true` inputs itself. https://github.com/actions/runner/issues/1070 + echo "'toolchain' is a required input" >&2 + exit 1 + elif [[ $toolchain =~ ^stable' '[0-9]+' '(year|month|week|day)s?' 'ago$ ]]; then if [[ ${{runner.os}} == macOS ]]; then echo "toolchain=1.$((($(date -v-$(sed 's/stable \([0-9]*\) \(.\).*/\1\2/' <<< $toolchain) +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT else @@ -38,11 +42,13 @@ runs: fi elif [[ $toolchain =~ ^stable' 'minus' '[0-9]+' 'releases?$ ]]; then echo "toolchain=1.$((($(date +%s)/60/60/24-16569)/7/6-${toolchain//[^0-9]/}))" >> $GITHUB_OUTPUT + elif [[ $toolchain =~ ^1\.[0-9]+$ ]]; then + echo "toolchain=1.$((i=${toolchain#1.}, c=($(date +%s)/60/60/24-16569)/7/6, i+9*i*(10*i<=c)+90*i*(100*i<=c)))" >> $GITHUB_OUTPUT else echo "toolchain=$toolchain" >> $GITHUB_OUTPUT fi env: - toolchain: 1.90.0 + toolchain: 1.91.0 shell: bash - id: flags @@ -58,24 +64,35 @@ runs: - run: | : set $CARGO_HOME - echo CARGO_HOME=${CARGO_HOME:-${{runner.os == 'Windows' && '$USERPROFILE' || '$HOME'}}/.cargo} >> $GITHUB_ENV + echo CARGO_HOME=${CARGO_HOME:-"${{runner.os == 'Windows' && '$USERPROFILE\.cargo' || '$HOME/.cargo'}}"} >> $GITHUB_ENV shell: bash - run: | : install rustup if needed if ! command -v rustup &>/dev/null; then - curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y + curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail https://sh.rustup.rs | sh -s -- --default-toolchain none -y echo "$CARGO_HOME/bin" >> $GITHUB_PATH fi if: runner.os != 'Windows' shell: bash + - run: | + : install rustup if needed on windows + if ! command -v rustup &>/dev/null; then + curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused --location --silent --show-error --fail https://win.rustup.rs/${{runner.arch == 'ARM64' && 'aarch64' || 'x86_64'}} --output '${{runner.temp}}\rustup-init.exe' + '${{runner.temp}}\rustup-init.exe' --default-toolchain none --no-modify-path -y + echo "$CARGO_HOME\bin" >> $GITHUB_PATH + fi + if: runner.os == 'Windows' + shell: bash + - name: rustup toolchain install ${{steps.parse.outputs.toolchain}} run: rustup toolchain install ${{steps.parse.outputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update shell: bash - run: rustup default ${{steps.parse.outputs.toolchain}} shell: bash + continue-on-error: true # https://github.com/dtolnay/rust-toolchain/issues/127 - id: rustc-version run: | diff --git a/scripts/update-revs.sh b/scripts/update-revs.sh index c5c7841..1d5006e 100755 --- a/scripts/update-revs.sh +++ b/scripts/update-revs.sh @@ -10,11 +10,12 @@ fi patch_releases=( 1.12.1 1.15.1 1.22.1 1.24.1 1.26.1 1.26.2 1.27.1 1.27.2 1.29.1 1.29.2 1.30.1 1.31.1 1.34.1 1.34.2 1.41.1 1.43.1 1.44.1 1.45.1 1.45.2 1.52.1 1.56.1 1.58.1 - 1.62.1 1.66.1 1.67.1 1.68.1 1.68.2 1.71.1 1.72.1 1.74.1 1.77.1 1.77.2 + 1.62.1 1.66.1 1.67.1 1.68.1 1.68.2 1.71.1 1.72.1 1.74.1 1.77.1 1.77.2 1.80.1 + 1.84.1 1.85.1 ) releases() { - printf "%s\n" 1.{0..90}.0 ${patch_releases[@]} | sort -V + printf "%s\n" 1.{0..100}.0 ${patch_releases[@]} | sort -V } base=$(git rev-parse HEAD) @@ -32,7 +33,7 @@ for rev in `releases` stable beta nightly; do if [[ $rev == 1* ]]; then sed -i "/^ toolchain:/,+2d; s/\${{inputs\.toolchain}}/$rev/" action.yml else - sed -i "s/required: true/required: false\n default: $rev/" action.yml + sed -i "s/^ required: true$/ required: false\n default: $rev/" action.yml fi git add action.yml git commit --quiet --message "toolchain: $rev"