mirror of
https://github.com/moonrepo/setup-rust.git
synced 2025-04-29 13:30:03 +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
|
||||
`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
|
||||
# rust-toolchain.toml
|
||||
|
|
|
@ -9,6 +9,8 @@ inputs:
|
|||
cache:
|
||||
description: 'Toggle caching of ~/.cargo/registry and /target/debug directories.'
|
||||
default: true
|
||||
rust-toolchain-file:
|
||||
description: 'Path to a rust-toolchain file to install.'
|
||||
channel:
|
||||
description: 'Toolchain specification/channel to install.'
|
||||
components:
|
||||
|
|
26
src/rust.ts
26
src/rust.ts
|
@ -94,17 +94,27 @@ export function detectToolchain(): Toolchain {
|
|||
});
|
||||
} else {
|
||||
core.info('Loading rust-toolchain.toml or rust-toolchain file');
|
||||
const toolchainFile = core.getInput('rust-toolchain-file');
|
||||
|
||||
for (const configName of ['rust-toolchain.toml', 'rust-toolchain']) {
|
||||
const configPath = path.join(process.cwd(), configName);
|
||||
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']) {
|
||||
const configPath = path.join(process.cwd(), configName);
|
||||
|
||||
if (fs.existsSync(configPath)) {
|
||||
core.debug(`Found ${configName}, parsing TOML`);
|
||||
if (fs.existsSync(configPath)) {
|
||||
core.debug(`Found ${configName}, parsing TOML`);
|
||||
|
||||
Object.assign(toolchain, parseConfig(configPath));
|
||||
break;
|
||||
}
|
||||
}
|
||||
Object.assign(toolchain, parseConfig(configPath));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.info('Inheriting toolchain settings from inputs');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue