Skip to content

Commit 379d2bf

Browse files
committed
Add support for toolchain files
A toolchain file in the repository root will always take priority. Closes #1
1 parent c17331e commit 379d2bf

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.2.0] - 2022-07-21
11+
12+
### Added
13+
14+
* Prefer toolchain definitions in `rust-toolchain` or `rust-toolchain.toml` files ([Toolchain File](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file)).
15+
Other input values are ignored if either file is found.
16+
1017
## [1.1.0] - 2022-07-19
1118

1219
### Added

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
## Inputs
3030
3131
All inputs are optional.
32+
If a [toolchain file](https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file) (i.e., `rust-toolchain` or `rust-toolchain.toml`) is found in the root of the repository, it takes precedence.
33+
All input values are ignored if a toolchain file exists.
3234

3335
| Name | Description | Default |
3436
| ------------ | --------------------------------------------------------------------------------- | ------- |

action.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,29 @@ runs:
6060
shell: bash
6161
- name: rustup toolchain install ${{inputs.toolchain}}
6262
run: |
63-
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
64-
rustup default ${{inputs.toolchain}}
63+
if [[ -f "rust-toolchain" || -f "rust-toolchain.toml" ]]
64+
then
65+
# Install the toolchain as specified in the file
66+
# Might break at some point: https://github.com/rust-lang/rustup/issues/1397
67+
rustup show
68+
else
69+
rustup toolchain install ${{inputs.toolchain}}${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
70+
rustup default ${{inputs.toolchain}}
71+
fi
6572
shell: bash
6673

6774
- name: Print installed versions
6875
id: versions
6976
run: |
70-
echo "::set-output name=rustc-version::$(rustc +${{inputs.toolchain}} --version)"
71-
rustc +${{inputs.toolchain}} --version --verbose
72-
echo "::set-output name=cargo-version::$(cargo +${{inputs.toolchain}} --version)"
73-
cargo +${{inputs.toolchain}} --version --verbose
74-
echo "::set-output name=rustup-version::$(rustup +${{inputs.toolchain}} --version)"
75-
rustup +${{inputs.toolchain}} --version
77+
echo "::set-output name=rustc-version::$(rustc --version)"
78+
rustc --version --verbose
79+
echo "::set-output name=cargo-version::$(cargo --version)"
80+
cargo --version --verbose
81+
echo "::set-output name=rustup-version::$(rustup --version)"
82+
rustup --version
7683
77-
DATE=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-date: \(20[0-9][0-9]\)-\([01][0-9]\)-\([0-3][0-9]\)$/\1\2\3/p')
78-
HASH=$(rustc +${{inputs.toolchain}} --version --verbose | sed -ne 's/^commit-hash: //p')
84+
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')
85+
HASH=$(rustc --version --verbose | sed -ne 's/^commit-hash: //p')
7986
echo "::set-output name=cachekey::$(echo $DATE$HASH | head -c12)"
8087
shell: bash
8188

0 commit comments

Comments
 (0)