mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-03-22 02:39:09 +00:00
Fetch uv from Astral's mirror by default (#809)
This PR tries fetching the uv artifact from `releases.astral.sh` by default, only in cases where the artifact would otherwise have come from `https://github.com/astral-sh/uv/releases/download/`. The checksums are supposed to be the same for the mirror, and can still come from `raw.githubusercontent.com/astral-sh/versions`. If the download fails, we fall back to the original URL. This avoids hitting GitHub's Releases API which is prone to rate limiting. As far as I can tell, together with https://github.com/astral-sh/setup-uv/pull/802 this PR makes a github token entirely unnecessary for this action. Towards https://github.com/astral-sh/uv/issues/18503.
This commit is contained in:
committed by
GitHub
parent
9f00d186ce
commit
37802adc94
47
dist/setup/index.cjs
generated
vendored
47
dist/setup/index.cjs
generated
vendored
@@ -91887,6 +91887,8 @@ var TOOL_CACHE_NAME = "uv";
|
||||
var STATE_UV_PATH = "uv-path";
|
||||
var STATE_UV_VERSION = "uv-version";
|
||||
var VERSIONS_NDJSON_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
|
||||
var GITHUB_RELEASES_PREFIX = "https://github.com/astral-sh/uv/releases/download/";
|
||||
var ASTRAL_MIRROR_PREFIX = "https://releases.astral.sh/github/uv/releases/download/";
|
||||
|
||||
// src/download/checksum/checksum.ts
|
||||
var crypto6 = __toESM(require("node:crypto"), 1);
|
||||
@@ -96658,15 +96660,42 @@ async function downloadVersionFromNdjson(platform2, arch3, version4, checkSum2,
|
||||
`Could not find artifact for version ${version4}, arch ${arch3}, platform ${platform2} in ${VERSIONS_NDJSON_URL} .`
|
||||
);
|
||||
}
|
||||
return await downloadVersion(
|
||||
artifact.url,
|
||||
`uv-${arch3}-${platform2}`,
|
||||
platform2,
|
||||
arch3,
|
||||
version4,
|
||||
checkSum2,
|
||||
githubToken2
|
||||
);
|
||||
const mirrorUrl = rewriteToMirror(artifact.url);
|
||||
const downloadUrl = mirrorUrl ?? artifact.url;
|
||||
const downloadToken = mirrorUrl !== void 0 ? void 0 : githubToken2;
|
||||
try {
|
||||
return await downloadVersion(
|
||||
downloadUrl,
|
||||
`uv-${arch3}-${platform2}`,
|
||||
platform2,
|
||||
arch3,
|
||||
version4,
|
||||
checkSum2,
|
||||
downloadToken
|
||||
);
|
||||
} catch (err) {
|
||||
if (mirrorUrl === void 0) {
|
||||
throw err;
|
||||
}
|
||||
warning(
|
||||
`Failed to download from mirror, falling back to GitHub Releases: ${err.message}`
|
||||
);
|
||||
return await downloadVersion(
|
||||
artifact.url,
|
||||
`uv-${arch3}-${platform2}`,
|
||||
platform2,
|
||||
arch3,
|
||||
version4,
|
||||
checkSum2,
|
||||
githubToken2
|
||||
);
|
||||
}
|
||||
}
|
||||
function rewriteToMirror(url2) {
|
||||
if (!url2.startsWith(GITHUB_RELEASES_PREFIX)) {
|
||||
return void 0;
|
||||
}
|
||||
return ASTRAL_MIRROR_PREFIX + url2.slice(GITHUB_RELEASES_PREFIX.length);
|
||||
}
|
||||
async function downloadVersionFromManifest(manifestUrl, platform2, arch3, version4, checkSum2, githubToken2) {
|
||||
const artifact = await getManifestArtifact(
|
||||
|
||||
Reference in New Issue
Block a user