setup-bun/dist/utils/install.js
2022-07-11 10:06:29 +02:00

23 lines
849 B
JavaScript

import { cacheDir, downloadTool, extractZip, find } from '@actions/tool-cache';
import { addPath, info } from '@actions/core';
import getAsset from './getAsset.js';
import { join } from 'path';
export default async (release) => {
const cache = find('bun', release.tag_name);
if (cache) {
info(`Using cached Bun installation from ${cache}.`);
addPath(cache);
return;
}
const asset = getAsset(release.assets);
info(`Downloading Bun from ${asset.browser_download_url}.`);
const zipPath = await downloadTool(asset.browser_download_url);
const extracted = await extractZip(zipPath);
const newCache = await cacheDir(extracted, 'bun', release.tag_name);
info(`Cached Bun to ${newCache}.`);
addPath(newCache);
info(extracted);
const bunPath = join(extracted);
addPath(bunPath);
};