mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-29 21:40:01 +00:00
Add option to specify the toolchain config file
This commit is contained in:
parent
21cbaddcd4
commit
afaa4e3396
3 changed files with 21 additions and 9 deletions
|
@ -17,7 +17,7 @@ jobs:
|
||||||
|
|
||||||
This action will automatically install the appropriate toolchain with `rustup` by inspecting the
|
This action will automatically install the appropriate toolchain with `rustup` by inspecting the
|
||||||
`RUSTUP_TOOLCHAIN` environment variable or the `rust-toolchain.toml` (preferred) or `rust-toolchain`
|
`RUSTUP_TOOLCHAIN` environment variable or the `rust-toolchain.toml` (preferred) or `rust-toolchain`
|
||||||
configuration files. If no toolchain found, will default to `stable`.
|
configuration files. To specify the location of the toolchain configuration files you can use `rust-toolchain-file` option. If no toolchain found, will default to `stable`.
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# rust-toolchain.toml
|
# rust-toolchain.toml
|
||||||
|
|
|
@ -9,6 +9,8 @@ inputs:
|
||||||
cache:
|
cache:
|
||||||
description: 'Toggle caching of ~/.cargo/registry and /target/debug directories.'
|
description: 'Toggle caching of ~/.cargo/registry and /target/debug directories.'
|
||||||
default: true
|
default: true
|
||||||
|
rust-toolchain-file:
|
||||||
|
description: 'Path to a rust-toolchain file to install.'
|
||||||
channel:
|
channel:
|
||||||
description: 'Toolchain specification/channel to install.'
|
description: 'Toolchain specification/channel to install.'
|
||||||
components:
|
components:
|
||||||
|
|
10
src/rust.ts
10
src/rust.ts
|
@ -94,7 +94,16 @@ export function detectToolchain(): Toolchain {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
core.info('Loading rust-toolchain.toml or rust-toolchain file');
|
core.info('Loading rust-toolchain.toml or rust-toolchain file');
|
||||||
|
const toolchainFile = core.getInput('rust-toolchain-file');
|
||||||
|
|
||||||
|
if (toolchainFile) {
|
||||||
|
if (fs.existsSync(toolchainFile)) {
|
||||||
|
Object.assign(toolchain, parseConfig(toolchainFile));
|
||||||
|
} else {
|
||||||
|
core.setFailed('Not found toolchain config file');
|
||||||
|
throw new Error('Not found toolchain config file');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (const configName of ['rust-toolchain.toml', 'rust-toolchain']) {
|
for (const configName of ['rust-toolchain.toml', 'rust-toolchain']) {
|
||||||
const configPath = path.join(process.cwd(), configName);
|
const configPath = path.join(process.cwd(), configName);
|
||||||
|
|
||||||
|
@ -106,6 +115,7 @@ export function detectToolchain(): Toolchain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
core.info('Inheriting toolchain settings from inputs');
|
core.info('Inheriting toolchain settings from inputs');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue