2020-03-25 07:40:28 +02:00
|
|
|
import path from "path";
|
2019-09-14 23:55:34 +03:00
|
|
|
|
2020-03-25 07:40:28 +02:00
|
|
|
import * as core from "@actions/core";
|
2019-09-12 23:48:44 +03:00
|
|
|
|
2020-03-25 07:40:28 +02:00
|
|
|
import * as input from "./input";
|
|
|
|
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> {
|
2020-03-25 07:40:28 +02:00
|
|
|
const matchersPath = path.join(__dirname, ".matchers");
|
|
|
|
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) {
|
2020-06-06 12:16:01 +03:00
|
|
|
core.setFailed((<Error>error).message);
|
2019-09-12 23:48:44 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-06 12:16:01 +03:00
|
|
|
void main();
|