2022-07-12 18:53:38 +02:00
|
|
|
import { getInput, info, setFailed, setOutput, warning } from '@actions/core';
|
2022-07-11 09:45:23 +02:00
|
|
|
import getGithubRelease from './utils/getGithubRelease.js';
|
|
|
|
import install from './utils/install.js';
|
2022-07-12 19:53:24 +02:00
|
|
|
export const exit = (error, miscTestBuilds) => {
|
2022-07-12 18:53:38 +02:00
|
|
|
if (miscTestBuilds) {
|
|
|
|
warning(error);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setFailed(error);
|
|
|
|
process.exit();
|
|
|
|
}
|
2022-07-11 09:45:23 +02:00
|
|
|
};
|
|
|
|
const main = async () => {
|
|
|
|
try {
|
|
|
|
const version = getInput('bun-version');
|
|
|
|
const token = getInput('github-token');
|
2022-07-28 07:50:56 +02:00
|
|
|
const repository = getInput('repository');
|
|
|
|
const miscTestBuilds = (getInput('misc-test-builds') === 'true') || (repository.includes('oven-sh/misc-test-builds'));
|
|
|
|
const customDownloadUrl = getInput('custom-download-url') || null;
|
2022-07-11 09:45:23 +02:00
|
|
|
if (!version)
|
|
|
|
return exit('Invalid bun version.');
|
2022-07-28 07:50:56 +02:00
|
|
|
const release = await getGithubRelease(version, token, repository, customDownloadUrl, miscTestBuilds);
|
2022-07-11 09:57:02 +02:00
|
|
|
if ((release === null || release === void 0 ? void 0 : release.message) === 'Not Found')
|
2022-07-12 18:53:38 +02:00
|
|
|
return exit('Invalid bun version.', miscTestBuilds);
|
2022-07-12 08:40:58 +02:00
|
|
|
info(`Going to install release ${release.version}`);
|
2022-07-12 19:56:32 +02:00
|
|
|
await install(release);
|
2022-07-11 13:51:39 -07:00
|
|
|
setOutput('bun-version', release.tag_name);
|
2022-07-11 09:45:23 +02:00
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
exit(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
main();
|