mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-18 04:28:28 +02:00
chore: base
This commit is contained in:
parent
b04d87b14c
commit
e187173d21
425 changed files with 1080881 additions and 5 deletions
29
src/utils/getGithubRelease.ts
Normal file
29
src/utils/getGithubRelease.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { fetch } from 'undici';
|
||||
|
||||
export interface Asset {
|
||||
name: string;
|
||||
browser_download_url: string;
|
||||
}
|
||||
|
||||
export interface Release {
|
||||
html_url: string;
|
||||
tag_name: string;
|
||||
message?: string;
|
||||
assets: Asset[]
|
||||
}
|
||||
|
||||
export default async(version: string, token: string): Promise<Release> => {
|
||||
let url;
|
||||
if (version === 'latest') url = 'https://api.github.com/repos/oven-sh/bun/releases/latest';
|
||||
else url = `https://api.github.com/repos/oven-sh/bun/releases/tags/bun-v${version}`;
|
||||
|
||||
const release: any = await (await fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'setup-bun-github-action',
|
||||
'Authorization': token
|
||||
}
|
||||
})).json();
|
||||
|
||||
return release;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue