fix: drop sha support for now
This commit is contained in:
parent
6c20dbe6b5
commit
63edbc23b5
@ -15,10 +15,6 @@ export async function getDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.version && /^[0-9a-f]{40}$/i.test(options.version)) {
|
|
||||||
return await getShaDownloadMeta(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await getSemverDownloadMeta(options);
|
return await getSemverDownloadMeta(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,68 +23,6 @@ interface Run {
|
|||||||
head_sha: string;
|
head_sha: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Runs {
|
|
||||||
workflow_runs: Run[];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
|
|
||||||
let res: Runs;
|
|
||||||
let page = 1;
|
|
||||||
let run: Run | undefined;
|
|
||||||
while (
|
|
||||||
(res = (await (
|
|
||||||
await request(
|
|
||||||
`https://api.github.com/repos/oven-sh/bun/actions/workflows/ci.yml/runs?per_page=100&page=${page}`,
|
|
||||||
{
|
|
||||||
headers: options.token
|
|
||||||
? { "Authorization": `Bearer ${options.token}` }
|
|
||||||
: {},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
).json()) as Runs)
|
|
||||||
) {
|
|
||||||
if (res.workflow_runs.length === 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
run = res.workflow_runs.find((item) => item.head_sha === options.version);
|
|
||||||
if (run) break;
|
|
||||||
|
|
||||||
page++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!run) {
|
|
||||||
throw new Error(`Failed to find workflow run for SHA '${options.version}'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const artifacts = (await (
|
|
||||||
await request(
|
|
||||||
`https://api.github.com/repos/oven-sh/bun/actions/runs/${run.id}/artifacts`,
|
|
||||||
{
|
|
||||||
headers: options.token
|
|
||||||
? { "Authorization": `Bearer ${options.token}` }
|
|
||||||
: {},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
).json()) as { artifacts: { name: string; archive_download_url: string }[] };
|
|
||||||
|
|
||||||
const { os, arch, avx2, profile, token } = options;
|
|
||||||
|
|
||||||
const name = `bun-${os ?? getPlatform()}-${arch ?? getArchitecture()}${
|
|
||||||
avx2 === false ? "-baseline" : ""
|
|
||||||
}${profile ? "-profile" : ""}`;
|
|
||||||
|
|
||||||
const artifact = artifacts.artifacts.find((item) => item.name === name);
|
|
||||||
if (!artifact) {
|
|
||||||
throw new Error(`Failed to find artifact '${name}' in run '${run.id}'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: artifact.archive_download_url,
|
|
||||||
auth: token ? `Bearer ${token}` : undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
|
async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
|
||||||
const res = (await (
|
const res = (await (
|
||||||
await request("https://api.github.com/repos/oven-sh/bun/git/refs/tags", {
|
await request("https://api.github.com/repos/oven-sh/bun/git/refs/tags", {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user