2019-09-25 10:08:33 +03:00
|
|
|
const path = require('path');
|
2019-09-14 23:55:34 +03:00
|
|
|
|
2019-09-12 23:48:44 +03:00
|
|
|
import * as core from '@actions/core';
|
|
|
|
|
|
|
|
import * as input from './input';
|
2019-09-25 10:08:33 +03:00
|
|
|
import {Cargo, Cross} from '@actions-rs/core';
|
2019-09-12 23:48:44 +03:00
|
|
|
|
2019-09-25 10:08:33 +03:00
|
|
|
export async function run(actionInput: input.Input): Promise<void> {
|
2019-09-12 23:48:44 +03:00
|
|
|
let program;
|
|
|
|
if (actionInput.useCross) {
|
2019-09-25 10:08:33 +03:00
|
|
|
program = await Cross.getOrInstall();
|
2019-09-12 23:48:44 +03:00
|
|
|
} else {
|
2019-09-25 10:08:33 +03:00
|
|
|
program = await Cargo.get();
|
2019-09-12 23:48:44 +03:00
|
|
|
}
|
|
|
|
|
2019-09-13 21:34:47 +03:00
|
|
|
let args: string[] = [];
|
2019-09-12 23:48:44 +03:00
|
|
|
if (actionInput.toolchain) {
|
|
|
|
args.push(`+${actionInput.toolchain}`);
|
|
|
|
}
|
2019-09-13 21:34:47 +03:00
|
|
|
args.push(actionInput.command);
|
2019-09-12 23:48:44 +03:00
|
|
|
args = args.concat(actionInput.args);
|
|
|
|
|
2019-09-25 10:08:33 +03:00
|
|
|
await program.call(args);
|
2019-09-15 09:15:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function main(): Promise<void> {
|
2019-09-25 10:08:33 +03:00
|
|
|
const matchersPath = path.join(__dirname, '.matchers');
|
2019-10-22 14:49:39 +03:00
|
|
|
console.log(`::add-matcher::${path.join(matchersPath, 'rust.json')}`);
|
2019-09-25 10:08:33 +03:00
|
|
|
|
|
|
|
const actionInput = input.get();
|
|
|
|
|
2019-09-12 23:48:44 +03:00
|
|
|
try {
|
2019-09-25 10:08:33 +03:00
|
|
|
await run(actionInput);
|
2019-09-12 23:48:44 +03:00
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-15 09:15:18 +03:00
|
|
|
main();
|