diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 044c008..0a889d2 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,7 +2,7 @@ name: CI
on:
push:
- branches: [master]
+ branches: [main]
pull_request:
workflow_dispatch:
schedule: [cron: "40 1 * * *"]
@@ -25,8 +25,13 @@ jobs:
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
+ - name: Create toolchain file
+ run: |
+ echo "[toolchain]" >> rust-toolchain.toml
+ echo "channel = \"${{matrix.rust}}\"" >> rust-toolchain.toml
+ cat rust-toolchain.toml
- uses: ./
- name: Run dtolnay/rust-toolchain${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}}
+ name: Run dsherret/rust-toolchain-file${{contains(matrix.rust, ' ') && ' for ' || '@'}}${{matrix.rust}}
id: toolchain
with:
toolchain: ${{matrix.rust}}
diff --git a/README.md b/README.md
index 86f4262..69b5e4f 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,19 @@
-# Install Rust Toolchain
+# Install Rust Toolchain via rust-toolchain.toml
-This GitHub Action installs a Rust toolchain using rustup. It is designed for
-one-line concise usage and good defaults.
-
-
+Fork of https://github.com/dtolnay/rust-toolchain that supports and makes it mandatory to use a rust-toolchain.toml file.
## Example workflow
+Create a [`rust-toolchain.toml`](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) file:
+
+```toml
+[toolchain]
+channel = "1.68"
+components = [ "rustfmt", "clippy" ]
+```
+
+Then add an entry to this action in your github actions:
+
```yaml
name: test suite
on: [push, pull_request]
@@ -17,45 +24,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- - uses: dtolnay/rust-toolchain@stable
+ - uses: dsherret/rust-toolchain-file@1
- 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 selection of Rust toolchain is made based on the rust-toolchain.toml file.
## Inputs
-All inputs are optional.
-
-
-
- Name |
- Description |
-
-
- toolchain |
-
- Rustup toolchain specifier e.g. stable , nightly , 1.42.0 , nightly-2022-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.
- |
-
-
- targets |
- Comma-separated string of additional targets to install e.g. wasm32-unknown-unknown |
-
-
- components |
- Comma-separated string of additional components to install e.g. clippy, rustfmt |
-
-
-
-
+None. You must define everything in the rust-toolchain.toml file.
## Outputs
@@ -74,31 +51,6 @@ All inputs are optional.
-
-
-## Toolchain expressions
-
-The following forms are available for projects that use a sliding window of
-compiler support.
-
-```yaml
- # Installs the most recent stable toolchain as of the specified time
- # offset, which may be written in years, months, weeks, or days.
- - uses: dtolnay/rust-toolchain@master
- with:
- toolchain: stable 18 months ago
-```
-
-```yaml
- # Installs the stable toolchain which preceded the most recent one by
- # the specified number of minor versions.
- - uses: dtolnay/rust-toolchain@master
- with:
- toolchain: stable minus 8 releases
-```
-
-
-
## License
The scripts and documentation in this project are released under the [MIT
diff --git a/action.yml b/action.yml
index 63b7096..0880917 100644
--- a/action.yml
+++ b/action.yml
@@ -1,24 +1,10 @@
-name: rustup toolchain install
-author: David Tolnay
-description: Install the Rust toolchain
+name: rust-toolchain.toml setup
+author: David Tolnay, David Sherret
+description: Install the Rust toolchain via a rust-toolchain.toml file
branding:
icon: activity
color: purple
-inputs:
- toolchain:
- description: Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification
- required: true
- targets:
- description: Comma-separated list of target triples to install for this toolchain
- required: false
- target:
- description: Alias for `targets`
- required: false
- components:
- description: Comma-separated list of components to be additionally installed
- required: false
-
outputs:
cachekey:
description: A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"
@@ -30,22 +16,17 @@ outputs:
runs:
using: composite
steps:
- - id: parse
+ - id: ensure-toolchain-file
run: |
- : parse toolchain version
- if [[ $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
- echo "toolchain=1.$((($(date --date "${toolchain#stable }" +%s)/60/60/24-16569)/7/6))" >> $GITHUB_OUTPUT
- 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
+ if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]]
+ then
+ echo "found toolchain"
else
- echo "toolchain=$toolchain" >> $GITHUB_OUTPUT
+ echo "No rust-toolchain or rust-toolchain.toml file found in repo."
+ echo "Please ensure the repo is checked out first or add this file."
+ echo "If you don't want this file, then please use https://github.com/dtolnay/rust-toolchain"
+ exit 1
fi
- env:
- toolchain: ${{inputs.toolchain}}
shell: bash
- id: flags
@@ -68,18 +49,15 @@ runs:
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}}
+ - name: rustup toolchain install
+ run: rustup toolchain install --no-self-update
shell: bash
- id: rustc-version
run: |
: create cachekey
- DATE=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
- HASH=$(rustc +${{steps.parse.outputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
+ DATE=$(rustc --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
+ HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p')
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
shell: bash
@@ -102,7 +80,7 @@ runs:
# except on 1.66 and 1.67, on which it is unstable
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" -o -f "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol ]; then
touch "${{runner.temp}}"/.implicit_cargo_registries_crates_io_protocol || true
- if rustc +${{steps.parse.outputs.toolchain}} --version --verbose | (! grep -q '^release: 1\.6[67]\.'); then
+ if rustc --version --verbose | (! grep -q '^release: 1\.6[67]\.'); then
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
else
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=git >> $GITHUB_ENV
@@ -110,5 +88,5 @@ runs:
fi
shell: bash
- - run: rustc +${{steps.parse.outputs.toolchain}} --version --verbose
+ - run: rustc --version --verbose
shell: bash
diff --git a/scripts/update-revs.sh b/scripts/update-revs.sh
deleted file mode 100755
index 99f778d..0000000
--- a/scripts/update-revs.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/bin/bash
-
-cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
-
-if ! git diff-index --quiet HEAD; then
- echo "Not running update-revs.sh because git working directory is dirty" >&2
- exit 1
-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
-)
-
-releases() {
- printf "%s\n" 1.{0..70}.0 ${patch_releases[@]} | sort -V
-}
-
-base=$(git rev-parse HEAD)
-push=()
-
-declare -A minor
-for rev in `releases`; do
- minor[${rev%.*}]=$rev
-done
-
-for rev in `releases` stable beta nightly; do
- echo "Updating $rev branch"
- git checkout --quiet "$base"
- git branch --quiet --delete --force $rev &>/dev/null || true
- sed -i "s/required: true/required: false\n default: $rev/" action.yml
- git add action.yml
- git commit --quiet --message "toolchain: $rev"
- git checkout --quiet -b $rev
- push+=("$rev:refs/heads/$rev")
- if [ "${minor[${rev%.*}]}" == $rev ]; then
- push+=("$rev:refs/heads/${rev%.*}")
- fi
-done
-
-for tool in clippy miri; do
- echo "Updating $tool branch"
- git checkout --quiet --detach nightly
- git branch --quiet --delete --force $tool &>/dev/null || true
- if [ $tool == miri ]; then
- default="miri, rust-src"
- echo -e " - uses: dtolnay/install@xargo\n with:\n bin: xargo-check" >> action.yml
- else
- default=$tool
- fi
- sed -i "/required: false/{N;s/\n$/\n default: $default\n/}" action.yml
- git add action.yml
- git commit --quiet --message "components: $tool"
- git checkout --quiet -b $tool
- push+=("$tool:refs/heads/$tool")
-done
-
-git checkout --quiet "$base"
-
-echo "git push origin --force-with-lease ${push[@]}"