2019-08-15 17:16:59 +00:00
|
|
|
import * as core from '@actions/core';
|
2019-08-15 21:22:17 +00:00
|
|
|
import * as exec from '@actions/exec';
|
2019-08-15 18:12:08 +00:00
|
|
|
import * as rustup from './rustup';
|
|
|
|
import * as os from 'os';
|
2019-08-15 17:16:59 +00:00
|
|
|
|
|
|
|
async function run() {
|
|
|
|
try {
|
2019-08-15 18:12:08 +00:00
|
|
|
const version = core.getInput('rust-version');
|
2019-10-27 18:40:00 +00:00
|
|
|
|
2019-09-04 10:58:20 +00:00
|
|
|
const components = core.getInput('components')
|
|
|
|
.split(',')
|
|
|
|
.map((component) => component.trim())
|
|
|
|
.filter((component) => component.length > 0);
|
2019-10-27 18:40:00 +00:00
|
|
|
|
2019-09-18 15:08:24 +00:00
|
|
|
const targets = core.getInput('targets')
|
|
|
|
.split(',')
|
|
|
|
.map((target) => target.trim())
|
|
|
|
.filter((target) => target.length > 0);
|
2019-08-15 18:12:08 +00:00
|
|
|
|
2019-08-15 20:54:23 +00:00
|
|
|
if(version) {
|
2019-08-16 00:16:04 +00:00
|
|
|
await rustup.install();
|
2019-09-04 10:58:20 +00:00
|
|
|
|
2019-10-27 18:40:00 +00:00
|
|
|
await exec.exec(
|
|
|
|
'rustup',
|
|
|
|
['toolchain', 'install', version,
|
|
|
|
...(components.length > 0 ? ['-c', ...components] : []),
|
|
|
|
...(targets.length > 0 ? ['-t', ...targets] : []),
|
|
|
|
]
|
|
|
|
);
|
2019-09-18 15:08:24 +00:00
|
|
|
|
2019-10-27 18:40:00 +00:00
|
|
|
await exec.exec('rustup', ['default', version]);
|
2019-08-15 18:12:08 +00:00
|
|
|
}
|
2019-08-15 17:16:59 +00:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|