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-09-04 10:58:20 +00:00
|
|
|
const components = core.getInput('components')
|
|
|
|
.split(',')
|
|
|
|
.map((component) => component.trim())
|
|
|
|
.filter((component) => component.length > 0);
|
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-08-15 21:32:28 +00:00
|
|
|
await exec.exec('rustup', ['default', version]);
|
|
|
|
await exec.exec('rustup', ['update', version]);
|
2019-09-04 10:58:20 +00:00
|
|
|
|
|
|
|
for(let component of components) {
|
|
|
|
await exec.exec('rustup', ['component', 'add', component]);
|
|
|
|
}
|
2019-09-18 15:08:24 +00:00
|
|
|
|
|
|
|
for(let target of targets) {
|
|
|
|
await exec.exec('rustup', ['target', 'add', target]);
|
|
|
|
}
|
2019-08-15 18:12:08 +00:00
|
|
|
}
|
2019-08-15 17:16:59 +00:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|