Skip to content

Commit b31b131

Browse files
committed
Allow installing multiple Rust toolchains at once.
1 parent 9f99923 commit b31b131

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
* Add new parameter `cache-directories` that is propagated to `Swatinem/rust-cache` (#44 by @pranc1ngpegasus)
1111
* Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane)
1212
* Make rustup toolchain installation more robust in light of planned changes https://github.com/rust-lang/rustup/issues/3635 and https://github.com/rust-lang/rustup/pull/3985
13+
* Allow installing multiple Rust toolchains by specifying multiple versions in the `toolchain` input parameter.
1314

1415
## [1.9.0] - 2024-06-08
1516

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ If no `toolchain` value or toolchain file is present, it will default to `stable
4848
First, all items specified in the toolchain file are installed.
4949
Afterward, the `components` and `target` specified via inputs are installed in addition to the items from the toolchain file.
5050

51-
| Name | Description | Default |
52-
| ------------------- | -------------------------------------------------------------------------------------- | ------------- |
53-
| `toolchain` | Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. | stable |
54-
| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | |
55-
| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | |
56-
| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true |
57-
| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | |
58-
| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | |
59-
| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true |
60-
| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | |
61-
| `matcher` | Enable problem matcher to surface build messages and formatting issues | true |
62-
| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" |
51+
| Name | Description | Default |
52+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------- |
53+
| `toolchain` | Comma-separated list of Rustup toolchain specifier e.g. `stable`, `nightly`, `1.42.0`. The last version is the default. | stable |
54+
| `target` | Additional target support to install e.g. `wasm32-unknown-unknown` | |
55+
| `components` | Comma-separated string of additional components to install e.g. `clippy, rustfmt` | |
56+
| `cache` | Automatically configure Rust cache (using [`Swatinem/rust-cache`]) | true |
57+
| `cache-directories` | Propagates the value to [`Swatinem/rust-cache`] | |
58+
| `cache-workspaces` | Propagates the value to [`Swatinem/rust-cache`] | |
59+
| `cache-on-failure` | Propagates the value to [`Swatinem/rust-cache`] | true |
60+
| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | |
61+
| `matcher` | Enable problem matcher to surface build messages and formatting issues | true |
62+
| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" |
6363

6464
[`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache
6565

action.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ branding:
1313
# The action is heavily inspired by https://github.com/dtolnay/rust-toolchain
1414
inputs:
1515
toolchain:
16-
description: "Rust toolchain specification -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification"
16+
description: "Comma-separated list of Rust toolchain specifications. Last version becomes the default. -- see https://rust-lang.github.io/rustup/concepts/toolchains.html#toolchain-specification"
1717
required: false
1818
target:
1919
description: "Target triple to install for this toolchain"
@@ -80,7 +80,7 @@ runs:
8080
: construct rustup command line
8181
echo "targets=$(for t in ${targets//,/ }; do echo -n ' --target' $t; done)" >> $GITHUB_OUTPUT
8282
echo "components=$(for c in ${components//,/ }; do echo -n ' --component' $c; done)" >> $GITHUB_OUTPUT
83-
echo "downgrade=${{inputs.toolchain == 'nightly' && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
83+
echo "downgrade=${{contains(inputs.toolchain, 'nightly') && inputs.components && ' --allow-downgrade' || ''}}" >> $GITHUB_OUTPUT
8484
8585
# The environment variables always need to be set before the caching action
8686
- name: Setting Environment Variables
@@ -152,8 +152,9 @@ runs:
152152
then
153153
toolchain=stable
154154
fi
155-
rustup toolchain install $toolchain${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
156-
rustup override set $toolchain
155+
rustup toolchain install ${toolchain//,/ } ${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
156+
# Take the last element from the list
157+
rustup override set ${toolchain//*,/ }
157158
fi
158159
159160
- id: versions

0 commit comments

Comments
 (0)