conflicts

This commit is contained in:
Jozef Steinhübl 2026-01-04 22:21:13 +01:00
parent 296ba3d0ce
commit c3a0cc2e89
No known key found for this signature in database
GPG Key ID: 8D9A5E4549AA84FD
7 changed files with 43 additions and 27 deletions

View File

@ -54,6 +54,10 @@ jobs:
- latest - latest
- canary - canary
- "1.1.0" - "1.1.0"
- "1.x"
- "1"
- "> 1.0.0"
- "< 2"
# https://github.com/oven-sh/setup-bun/issues/37 # https://github.com/oven-sh/setup-bun/issues/37
# - "1.x" # - "1.x"
# - "1" # - "1"

View File

@ -39,6 +39,10 @@ inputs:
type: boolean type: boolean
default: false default: false
description: Disable caching of bun executable. description: Disable caching of bun executable.
token:
required: false
default: ${{ github.token }}
description: Personal access token (PAT) used to fetch tags from oven-sh/bun repository
outputs: outputs:
bun-version: bun-version:

View File

@ -11,6 +11,7 @@
"@actions/io": "^1.1.2", "@actions/io": "^1.1.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^2.2.5", "@iarna/toml": "^2.2.5",
"compare-versions": "^6.1.1",
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.1.13", "@types/bun": "^1.1.13",
@ -21,6 +22,9 @@
}, },
}, },
}, },
"patchedDependencies": {
"compare-versions@6.1.1": "patches/compare-versions@6.1.1.patch",
},
"packages": { "packages": {
"@actions/cache": ["@actions/cache@4.0.3", "", { "dependencies": { "@actions/core": "^1.11.1", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", "@actions/http-client": "^2.1.1", "@actions/io": "^1.0.1", "@azure/abort-controller": "^1.1.0", "@azure/ms-rest-js": "^2.6.0", "@azure/storage-blob": "^12.13.0", "@protobuf-ts/plugin": "^2.9.4", "semver": "^6.3.1" } }, "sha512-SvrqFtYJ7I48A/uXNkoJrnukx5weQv1fGquhs3+4nkByZThBH109KTIqj5x/cGV7JGNvb8dLPVywUOqX1fjiXg=="], "@actions/cache": ["@actions/cache@4.0.3", "", { "dependencies": { "@actions/core": "^1.11.1", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", "@actions/http-client": "^2.1.1", "@actions/io": "^1.0.1", "@azure/abort-controller": "^1.1.0", "@azure/ms-rest-js": "^2.6.0", "@azure/storage-blob": "^12.13.0", "@protobuf-ts/plugin": "^2.9.4", "semver": "^6.3.1" } }, "sha512-SvrqFtYJ7I48A/uXNkoJrnukx5weQv1fGquhs3+4nkByZThBH109KTIqj5x/cGV7JGNvb8dLPVywUOqX1fjiXg=="],
@ -144,6 +148,8 @@
"combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="], "combined-stream": ["combined-stream@1.0.8", "", { "dependencies": { "delayed-stream": "~1.0.0" } }, "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg=="],
"compare-versions": ["compare-versions@6.1.1", "", {}, "sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg=="],
"concat-map": ["concat-map@0.0.1", "", {}, "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="], "concat-map": ["concat-map@0.0.1", "", {}, "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="],
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="], "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],

View File

@ -28,7 +28,8 @@
"@actions/glob": "^0.4.0", "@actions/glob": "^0.4.0",
"@actions/io": "^1.1.2", "@actions/io": "^1.1.2",
"@actions/tool-cache": "^2.0.1", "@actions/tool-cache": "^2.0.1",
"@iarna/toml": "^2.2.5" "@iarna/toml": "^2.2.5",
"compare-versions": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {
"@types/bun": "^1.1.13", "@types/bun": "^1.1.13",
@ -36,5 +37,8 @@
"esbuild": "^0.19.2", "esbuild": "^0.19.2",
"prettier": "^3.4.2", "prettier": "^3.4.2",
"typescript": "^4.9.5" "typescript": "^4.9.5"
},
"patchedDependencies": {
"compare-versions@6.1.1": "patches/compare-versions@6.1.1.patch"
} }
} }

View File

@ -16,6 +16,7 @@ import { getExecOutput } from "@actions/exec";
import { writeBunfig, Registry } from "./bunfig"; import { writeBunfig, Registry } from "./bunfig";
import { saveState } from "@actions/core"; import { saveState } from "@actions/core";
import { addExtension, retry } from "./utils"; import { addExtension, retry } from "./utils";
import { DownloadMeta, getDownloadMeta } from "./download-url";
import { cwd } from "node:process"; import { cwd } from "node:process";
export type Input = { export type Input = {
@ -109,7 +110,10 @@ export default async (options: Input): Promise<Output> => {
if (!cacheHit) { if (!cacheHit) {
info(`Downloading a new version of Bun: ${url}`); info(`Downloading a new version of Bun: ${url}`);
// TODO: remove this, temporary fix for https://github.com/oven-sh/setup-bun/issues/73 // TODO: remove this, temporary fix for https://github.com/oven-sh/setup-bun/issues/73
revision = await retry(async () => await downloadBun(url, bunPath), 3); revision = await retry(
async () => await downloadBun(downloadMeta, bunPath),
3,
);
} }
} }
@ -163,7 +167,7 @@ function isVersionMatch(
} }
async function downloadBun( async function downloadBun(
url: string, downloadMeta: DownloadMeta,
bunPath: string, bunPath: string,
): Promise<string | undefined> { ): Promise<string | undefined> {
// Workaround for https://github.com/oven-sh/setup-bun/issues/79 and https://github.com/actions/toolkit/issues/1179 // Workaround for https://github.com/oven-sh/setup-bun/issues/79 and https://github.com/actions/toolkit/issues/1179
@ -171,9 +175,9 @@ async function downloadBun(
await downloadTool( await downloadTool(
downloadMeta.url, downloadMeta.url,
undefined, undefined,
downloadMeta.auth ?? undefined downloadMeta.auth ?? undefined,
), ),
".zip" ".zip",
); );
const extractedZipPath = await extractZip(zipPath); const extractedZipPath = await extractZip(zipPath);
const extractedBunPath = await extractBun(extractedZipPath); const extractedBunPath = await extractBun(extractedZipPath);
@ -202,24 +206,6 @@ function isCacheEnabled(options: Input): boolean {
return isFeatureAvailable(); return isFeatureAvailable();
} }
function getDownloadUrl(options: Input): string {
const { customUrl } = options;
if (customUrl) {
return customUrl;
}
const { version, os, arch, avx2, profile } = options;
const eversion = encodeURIComponent(version ?? "latest");
const eos = encodeURIComponent(os ?? process.platform);
const earch = encodeURIComponent(arch ?? process.arch);
const eavx2 = encodeURIComponent(avx2 ?? true);
const eprofile = encodeURIComponent(profile ?? false);
const { href } = new URL(
`${eversion}/${eos}/${earch}?avx2=${eavx2}&profile=${eprofile}`,
"https://bun.sh/download/",
);
return href;
}
async function extractBun(path: string): Promise<string> { async function extractBun(path: string): Promise<string> {
for (const entry of readdirSync(path, { withFileTypes: true })) { for (const entry of readdirSync(path, { withFileTypes: true })) {
const { name } = entry; const { name } = entry;

View File

@ -43,7 +43,7 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
headers: { headers: {
"Authorization": `Bearer ${options.token}`, "Authorization": `Bearer ${options.token}`,
}, },
} },
) )
).json()) as Runs) ).json()) as Runs)
) { ) {
@ -60,7 +60,7 @@ async function getShaDownloadMeta(options: Input): Promise<DownloadMeta> {
headers: { headers: {
"Authorization": `Bearer ${options.token}`, "Authorization": `Bearer ${options.token}`,
}, },
} },
) )
).json()) as { artifacts: { name: string; archive_download_url: string }[] }; ).json()) as { artifacts: { name: string; archive_download_url: string }[] };
@ -92,7 +92,7 @@ async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
let tags = res let tags = res
.filter( .filter(
(tag) => (tag) =>
tag.ref.startsWith("refs/tags/bun-v") || tag.ref === "refs/tags/canary" tag.ref.startsWith("refs/tags/bun-v") || tag.ref === "refs/tags/canary",
) )
.map((item) => item.ref.replace(/refs\/tags\/(bun-v)?/g, "")); .map((item) => item.ref.replace(/refs\/tags\/(bun-v)?/g, ""));
@ -116,7 +116,7 @@ async function getSemverDownloadMeta(options: Input): Promise<DownloadMeta> {
const { href } = new URL( const { href } = new URL(
`${eversion}/bun-${eos}-${earch}${eavx2}${eprofile}.zip`, `${eversion}/bun-${eos}-${earch}${eavx2}${eprofile}.zip`,
"https://github.com/oven-sh/bun/releases/download/" "https://github.com/oven-sh/bun/releases/download/",
); );
return { return {

View File

@ -15,6 +15,18 @@ export function retry<T>(
return new Promise((resolve) => setTimeout(resolve, timeout)).then(() => return new Promise((resolve) => setTimeout(resolve, timeout)).then(() =>
retry(fn, retries - 1, timeout), retry(fn, retries - 1, timeout),
); );
});
}
export async function request(
url: string,
init?: RequestInit,
): Promise<Response> {
const res = await fetch(url, init);
if (!res.ok) {
throw new Error(
`Failed to fetch url ${url}. (status code: ${res.status}, status text: ${res.statusText})\n${res}`,
);
} }
return res; return res;