Add override input parameter that controls the `rustup override` behavior

This commit is contained in:
Jonas Bushart 2024-09-22 16:04:02 +02:00
parent b31b1317f2
commit 4d1965c914
3 changed files with 11 additions and 1 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane) * Add new parameter `cache-key` that is propagated to `Swatinem/rust-cache` as `key` (#41 by @iainlane)
* 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 * 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
* Allow installing multiple Rust toolchains by specifying multiple versions in the `toolchain` input parameter. * Allow installing multiple Rust toolchains by specifying multiple versions in the `toolchain` input parameter.
* Configure the `rustup override` behavior via the new `override` input. (#38)
## [1.9.0] - 2024-06-08 ## [1.9.0] - 2024-06-08

View File

@ -60,6 +60,7 @@ Afterward, the `components` and `target` specified via inputs are installed in a
| `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | | | `cache-key` | Propagates the value to [`Swatinem/rust-cache`] as `key` | |
| `matcher` | Enable problem matcher to surface build messages and formatting issues | true | | `matcher` | Enable problem matcher to surface build messages and formatting issues | true |
| `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" | | `rustflags` | Set the value of `RUSTFLAGS` (set to empty string to avoid overwriting existing flags) | "-D warnings" |
| `override` | Setup the last installed toolchain as the default via `rustup override` | true |
[`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache [`Swatinem/rust-cache`]: https://github.com/Swatinem/rust-cache

View File

@ -46,6 +46,10 @@ inputs:
description: "set RUSTFLAGS environment variable, set to empty string to avoid overwriting build.rustflags" description: "set RUSTFLAGS environment variable, set to empty string to avoid overwriting build.rustflags"
required: false required: false
default: "-D warnings" default: "-D warnings"
override:
description: "Setup the last installed toolchain as the default via `rustup override`"
required: false
default: "true"
outputs: outputs:
rustc-version: rustc-version:
@ -132,6 +136,7 @@ runs:
toolchain: ${{inputs.toolchain}} toolchain: ${{inputs.toolchain}}
targets: ${{inputs.target}} targets: ${{inputs.target}}
components: ${{inputs.components}} components: ${{inputs.components}}
override: ${{inputs.override}}
shell: bash shell: bash
run: | run: |
if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]] if [[ -z "$toolchain" && ( -f "rust-toolchain" || -f "rust-toolchain.toml" ) ]]
@ -154,8 +159,11 @@ runs:
fi fi
rustup toolchain install ${toolchain//,/ } ${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update rustup toolchain install ${toolchain//,/ } ${{steps.flags.outputs.targets}}${{steps.flags.outputs.components}} --profile minimal${{steps.flags.outputs.downgrade}} --no-self-update
# Take the last element from the list # Take the last element from the list
if [[ "$override" == "true" ]]
then
rustup override set ${toolchain//*,/ } rustup override set ${toolchain//*,/ }
fi fi
fi
- id: versions - id: versions
name: Print installed versions name: Print installed versions