mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 12:38:24 +02:00
chore: base
This commit is contained in:
parent
b04d87b14c
commit
e187173d21
425 changed files with 1080881 additions and 5 deletions
34
src/utils/install.ts
Normal file
34
src/utils/install.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { Release } from './getGithubRelease.js';
|
||||
import { cacheDir, downloadTool, extractZip, find } from '@actions/tool-cache';
|
||||
import { addPath, info } from '@actions/core';
|
||||
import getAsset from './getAsset.js';
|
||||
import getHomeDir from './getHomeDir.js';
|
||||
import { join } from 'path';
|
||||
|
||||
export default async(release: 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);
|
||||
|
||||
const bunPath = join(getHomeDir(), ".bun", "bin");
|
||||
addPath(bunPath);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue