2021-04-10 08:16:12 +08:00
|
|
|
const process = require("process");
|
|
|
|
const core = require("@actions/core");
|
|
|
|
|
2024-07-05 14:33:22 +08:00
|
|
|
const {
|
|
|
|
parseVersionRange,
|
|
|
|
getDenoVersionFromFile,
|
|
|
|
resolveVersion,
|
|
|
|
} = require("./src/version.js");
|
2021-04-10 08:16:12 +08:00
|
|
|
const { install } = require("./src/install.js");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} message
|
2021-05-19 05:34:43 +08:00
|
|
|
* @returns {never}
|
2021-04-10 08:16:12 +08:00
|
|
|
*/
|
|
|
|
function exit(message) {
|
|
|
|
core.setFailed(message);
|
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
try {
|
2024-07-05 14:33:22 +08:00
|
|
|
const denoVersionFile = core.getInput("deno-version-file");
|
|
|
|
const range = parseVersionRange(
|
|
|
|
denoVersionFile
|
|
|
|
? getDenoVersionFromFile(denoVersionFile)
|
|
|
|
: core.getInput("deno-version"),
|
|
|
|
);
|
|
|
|
|
2021-04-10 08:16:12 +08:00
|
|
|
if (range === null) {
|
|
|
|
exit("The passed version range is not valid.");
|
|
|
|
}
|
|
|
|
|
|
|
|
const version = await resolveVersion(range);
|
|
|
|
if (version === null) {
|
|
|
|
exit("Could not resolve a version for the given range.");
|
|
|
|
}
|
|
|
|
|
|
|
|
core.info(
|
|
|
|
`Going to install ${
|
|
|
|
version.isCanary ? "canary" : "stable"
|
|
|
|
} version ${version.version}.`,
|
|
|
|
);
|
|
|
|
|
|
|
|
await install(version);
|
|
|
|
|
2021-04-10 08:20:00 +08:00
|
|
|
core.setOutput("deno-version", version.version);
|
2021-04-10 08:16:12 +08:00
|
|
|
core.setOutput("is-canary", version.isCanary);
|
|
|
|
|
|
|
|
core.info("Installation complete.");
|
|
|
|
} catch (err) {
|
|
|
|
core.setFailed(err);
|
|
|
|
process.exit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main();
|