2019-09-12 23:48:44 +03:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
import * as exec from '@actions/exec';
|
|
|
|
import * as io from '@actions/io';
|
|
|
|
|
|
|
|
import * as input from './input';
|
|
|
|
|
|
|
|
async function getCross(): Promise<string> {
|
|
|
|
try {
|
|
|
|
return await io.which('cross', true);
|
|
|
|
} catch (error) {
|
|
|
|
core.warning('Unable to find cross, installing it now');
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2019-09-13 10:29:54 +03:00
|
|
|
// Latest `cross` (0.1.15) is kinda broken right now,
|
|
|
|
// using hardcoded version till the fix lands
|
|
|
|
// https://github.com/rust-embedded/cross/issues/306
|
|
|
|
await exec.exec('cargo', ['install', '--version', '0.1.14', 'cross']);
|
2019-09-12 23:48:44 +03:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'cross';
|
|
|
|
}
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
const actionInput = input.parse();
|
|
|
|
|
|
|
|
let program;
|
|
|
|
if (actionInput.useCross) {
|
|
|
|
program = await getCross();
|
|
|
|
} else {
|
|
|
|
program = 'cargo';
|
|
|
|
}
|
|
|
|
|
2019-09-13 00:13:57 +03:00
|
|
|
let args: string[] = [actionInput.command];
|
2019-09-12 23:48:44 +03:00
|
|
|
if (actionInput.toolchain) {
|
|
|
|
args.push(`+${actionInput.toolchain}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
args = args.concat(actionInput.args);
|
2019-09-13 00:13:57 +03:00
|
|
|
console.log(program, args);
|
2019-09-12 23:48:44 +03:00
|
|
|
|
|
|
|
try {
|
|
|
|
await exec.exec(program, args);
|
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run();
|