setup-bun/dist/index.js

34 lines
1.3 KiB
JavaScript
Raw Normal View History

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';
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');
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.');
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);
setOutput('bun-version', release.tag_name);
2022-07-11 09:45:23 +02:00
}
catch (e) {
exit(e);
}
};
main();