Respect the mirror setting when selecting the version manifest (#1164)

Select the manifest source from the action inputs and keep version
resolution separate from archive downloads. Fetch the built-in manifest
directly from GitHub when the Astral mirror is disabled.

Fixes: #1140

Based on the work of @Rudra-G-23 in
https://github.com/astral-sh/setup-uv/pull/1152

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Kevin StillhammerandAmp authored and GitHub committed 2026-12-02 11:40:15 +01:00
1 parent 521745f16c
commit 36300bab3f
19 files changed
+1637 -1647

No files matched your search

Generated Vendored
+21 -8
View File
@@ -66230,6 +66230,19 @@ function getConfigValueFromTomlContent(filePath, fileContent, key) {
__name(getConfigValueFromTomlContent, "getConfigValueFromTomlContent");
// src/utils/inputs.ts
var VERSIONS_MANIFEST_URL = "https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
var GITHUB_VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
var ASTRAL_MANIFEST = {
custom: false,
fallbackUrl: GITHUB_VERSIONS_MANIFEST_URL,
newestFirst: true,
url: VERSIONS_MANIFEST_URL
};
var GITHUB_MANIFEST = {
custom: false,
newestFirst: true,
url: GITHUB_VERSIONS_MANIFEST_URL
};
function loadInputs() {
const workingDirectory = getInput("working-directory");
const version3 = getInput("version");
@@ -66261,8 +66274,8 @@ function loadInputs() {
const toolDir = getToolDir(workingDirectory);
const pythonDir = getUvPythonDir();
const githubToken = getInput("github-token");
const manifestFile = getManifestFile();
const downloadFromAstralMirror = getInput("download-from-astral-mirror") === "true";
const manifestSource = getManifestSource(downloadFromAstralMirror);
const addProblemMatchers = getInput("add-problem-matchers") === "true";
const quiet2 = getInput("quiet") === "true";
const resolutionStrategy = getResolutionStrategy();
@@ -66280,7 +66293,7 @@ function loadInputs() {
githubToken,
ignoreEmptyWorkdir,
ignoreNothingToCache,
manifestFile,
manifestSource,
noProject,
pruneCache: pruneCache2,
pythonArch,
@@ -66528,14 +66541,14 @@ function resolveRelativePath(workingDirectory, inputPath) {
return hasNegation ? `!${resolvedPath}` : resolvedPath;
}
__name(resolveRelativePath, "resolveRelativePath");
function getManifestFile() {
const manifestFileInput = getInput("manifest-file");
if (manifestFileInput !== "") {
return manifestFileInput;
function getManifestSource(useAstralMirror) {
const manifestFile = getInput("manifest-file");
if (manifestFile !== "") {
return { custom: true, newestFirst: false, url: manifestFile };
}
return void 0;
return useAstralMirror ? ASTRAL_MANIFEST : GITHUB_MANIFEST;
}
__name(getManifestFile, "getManifestFile");
__name(getManifestSource, "getManifestSource");
function getResolutionStrategy() {
const resolutionStrategyInput = getInput("resolution-strategy");
if (resolutionStrategyInput === "lowest") {
Generated Vendored
+1124 -1115
View File
File diff suppressed because it is too large. Load diff
+101 -63
View File
@@ -963,7 +963,7 @@ var require_util = __commonJS({
var net = require("node:net");
var { Blob: Blob2 } = require("node:buffer");
var nodeUtil = require("node:util");
var { stringify } = require("node:querystring");
var { stringify: stringify2 } = require("node:querystring");
var { EventEmitter: EE } = require("node:events");
var { InvalidArgumentError } = require_errors();
var { headerNameLowerCasedRecord } = require_constants();
@@ -1023,7 +1023,7 @@ var require_util = __commonJS({
if (url.includes("?") || url.includes("#")) {
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
}
const stringified = stringify(queryParams);
const stringified = stringify2(queryParams);
if (stringified) {
url += "?" + stringified;
}
@@ -3425,7 +3425,7 @@ var require_data_url = __commonJS({
const buffer = Buffer.from(data, "base64");
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
}
function collectAnHTTPQuotedString(input, position, extractValue) {
function collectAnHTTPQuotedString(input, position, extractValue2) {
const positionStart = position.position;
let value = "";
assert(input[position.position] === '"');
@@ -3453,7 +3453,7 @@ var require_data_url = __commonJS({
break;
}
}
if (extractValue) {
if (extractValue2) {
return value;
}
return input.slice(positionStart, position.position);
@@ -15920,7 +15920,7 @@ var require_util6 = __commonJS({
throw new Error("Invalid cookie max-age");
}
}
function stringify(cookie) {
function stringify2(cookie) {
if (cookie.name.length === 0) {
return null;
}
@@ -15974,7 +15974,7 @@ var require_util6 = __commonJS({
validateCookiePath,
validateCookieValue,
toIMFDate,
stringify
stringify: stringify2
};
}
});
@@ -16124,7 +16124,7 @@ var require_cookies = __commonJS({
"node_modules/@actions/http-client/node_modules/undici/lib/web/cookies/index.js"(exports2, module2) {
"use strict";
var { parseSetCookie } = require_parse();
var { stringify } = require_util6();
var { stringify: stringify2 } = require_util6();
var { webidl } = require_webidl();
var { Headers: Headers2 } = require_headers();
function getCookies(headers) {
@@ -16167,7 +16167,7 @@ var require_cookies = __commonJS({
webidl.argumentLengthCheck(arguments, 2, "setCookie");
webidl.brandCheck(headers, Headers2, { strict: false });
cookie = webidl.converters.Cookie(cookie);
const str = stringify(cookie);
const str = stringify2(cookie);
if (str) {
headers.append("Set-Cookie", str);
}
@@ -18724,8 +18724,8 @@ var require_semver = __commonJS({
}
}
var i;
exports2.parse = parse;
function parse(version, options) {
exports2.parse = parse2;
function parse2(version, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
@@ -18753,12 +18753,12 @@ var require_semver = __commonJS({
}
exports2.valid = valid;
function valid(version, options) {
var v = parse(version, options);
var v = parse2(version, options);
return v ? v.version : null;
}
exports2.clean = clean;
function clean(version, options) {
var s = parse(version.trim().replace(/^[=v]+/, ""), options);
var s = parse2(version.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
}
exports2.SemVer = SemVer;
@@ -18994,8 +18994,8 @@ var require_semver = __commonJS({
if (eq(version1, version2)) {
return null;
} else {
var v1 = parse(version1);
var v2 = parse(version2);
var v1 = parse2(version1);
var v2 = parse2(version2);
var prefix = "";
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
@@ -19701,7 +19701,7 @@ var require_semver = __commonJS({
}
exports2.prerelease = prerelease;
function prerelease(version, options) {
var parsed = parse(version, options);
var parsed = parse2(version, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
exports2.intersects = intersects;
@@ -19738,7 +19738,7 @@ var require_semver = __commonJS({
if (match === null) {
return null;
}
return parse(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options);
return parse2(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options);
}
}
});
@@ -20751,7 +20751,7 @@ var require_util9 = __commonJS({
var { IncomingMessage } = require("node:http");
var stream = require("node:stream");
var net = require("node:net");
var { stringify } = require("node:querystring");
var { stringify: stringify2 } = require("node:querystring");
var { EventEmitter: EE, addAbortListener: addAbortListenerNative } = require("node:events");
var timers = require_timers2();
var { InvalidArgumentError, ConnectTimeoutError } = require_errors2();
@@ -20807,7 +20807,7 @@ var require_util9 = __commonJS({
if (pathHasQueryOrFragment(url)) {
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
}
const stringified = stringify(queryParams);
const stringified = stringify2(queryParams);
if (stringified) {
url += "?" + stringified;
}
@@ -23887,7 +23887,7 @@ var require_data_url2 = __commonJS({
}
return mimeType;
}
function collectAnHTTPQuotedString(input, position, extractValue = false) {
function collectAnHTTPQuotedString(input, position, extractValue2 = false) {
const positionStart = position.position;
let value = "";
assert(input[position.position] === '"');
@@ -23915,7 +23915,7 @@ var require_data_url2 = __commonJS({
break;
}
}
if (extractValue) {
if (extractValue2) {
return value;
}
return input.slice(positionStart, position.position);
@@ -43997,7 +43997,7 @@ var require_util12 = __commonJS({
throw new Error("Invalid cookie max-age");
}
}
function stringify(cookie) {
function stringify2(cookie) {
if (cookie.name.length === 0) {
return null;
}
@@ -44055,7 +44055,7 @@ var require_util12 = __commonJS({
validateCookiePath,
validateCookieValue,
toIMFDate,
stringify
stringify: stringify2
};
}
});
@@ -44206,7 +44206,7 @@ var require_cookies2 = __commonJS({
"node_modules/undici/lib/web/cookies/index.js"(exports2, module2) {
"use strict";
var { parseSetCookie } = require_parse2();
var { stringify } = require_util12();
var { stringify: stringify2 } = require_util12();
var { webidl } = require_webidl2();
var globalHeadersBrandCheck = (arg) => webidl.brandCheck(arg, webidl.util.MakeTypeAssertion(globalThis.Headers));
var undiciHeadersBrandCheck = (arg) => webidl.brandCheck(arg, webidl.is.Headers);
@@ -44262,7 +44262,7 @@ var require_cookies2 = __commonJS({
webidl.argumentLengthCheck(arguments, 2, "setCookie");
brandCheckHeaders(headers);
cookie = webidl.converters.Cookie(cookie);
const str = stringify(cookie);
const str = stringify2(cookie);
if (str) {
headers.append("set-cookie", str, true);
}
@@ -53733,10 +53733,6 @@ async function updateChecksums(filePath, checksumEntries) {
var import_node_readline = require("node:readline");
var import_node_stream = require("node:stream");
// src/utils/constants.ts
var VERSIONS_MANIFEST_URL = "https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
var GITHUB_VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
// src/utils/fetch.ts
var import_undici2 = __toESM(require_undici2(), 1);
var fetch = async (url, opts) => {
@@ -53765,18 +53761,18 @@ function info2(msg) {
}
// src/download/manifest.ts
var cachedManifestData = /* @__PURE__ */ new Map();
var cachedManifestData = /* @__PURE__ */ new WeakMap();
var MANIFEST_FETCH_ATTEMPTS = 3;
async function fetchManifest(manifestUrl = VERSIONS_MANIFEST_URL) {
const cachedManifest = cachedManifestData.get(manifestUrl);
async function fetchManifest(source) {
const cachedManifest = cachedManifestData.get(source);
if (cachedManifest?.complete === true) {
debug(`Using cached manifest data from ${manifestUrl}`);
debug(`Using cached manifest data from ${source.url}`);
return cachedManifest.versions;
}
const response = await fetchManifestResponse(manifestUrl);
const response = await fetchManifestResponse(source);
const body = await response.text();
const versions = parseManifest(body, manifestUrl);
cachedManifestData.set(manifestUrl, { complete: true, versions });
const versions = parseManifest(body, source.url);
cachedManifestData.set(source, { complete: true, versions });
return versions;
}
function parseManifest(data, sourceDescription) {
@@ -53798,25 +53794,24 @@ function parseManifest(data, sourceDescription) {
}
return versions;
}
async function getLatestVersion(manifestUrl = VERSIONS_MANIFEST_URL) {
const latestVersion = manifestUrl === VERSIONS_MANIFEST_URL ? (await findManifestVersion(() => true))?.version : (await fetchManifest(manifestUrl))[0]?.version;
if (latestVersion === void 0) {
async function getFirstVersion(source) {
const version = (await findManifestVersion(source, () => true))?.version;
if (version === void 0) {
throw new Error("No versions found in manifest data");
}
debug(`Latest version from manifest: ${latestVersion}`);
return latestVersion;
return version;
}
async function fetchManifestResponse(manifestUrl) {
async function fetchManifestResponse(source) {
try {
return await fetchManifestResponseFromUrl(manifestUrl);
return await fetchManifestResponseFromUrl(source.url);
} catch (error2) {
if (manifestUrl !== VERSIONS_MANIFEST_URL) {
if (source.fallbackUrl === void 0) {
throw error2;
}
info2(
`Failed to fetch manifest from Astral mirror, falling back to GitHub: ${error2.message}`
`Failed to fetch manifest from ${source.url}, falling back to ${source.fallbackUrl}: ${error2.message}`
);
return await fetchManifestResponseFromUrl(GITHUB_VERSIONS_MANIFEST_URL);
return await fetchManifestResponseFromUrl(source.fallbackUrl);
}
}
async function fetchManifestResponseFromUrl(manifestUrl) {
@@ -53845,19 +53840,19 @@ async function fetchManifestResponseFromUrl(manifestUrl) {
}
return response;
}
async function findManifestVersion(predicate) {
const cachedManifest = cachedManifestData.get(VERSIONS_MANIFEST_URL);
async function findManifestVersion(source, predicate) {
if (!source.newestFirst) {
return (await fetchManifest(source)).find(predicate);
}
const cachedManifest = cachedManifestData.get(source);
const cachedVersion = cachedManifest?.versions.find(predicate);
if (cachedVersion !== void 0 || cachedManifest?.complete === true) {
return cachedVersion;
}
const response = await fetchManifestResponse(VERSIONS_MANIFEST_URL);
const response = await fetchManifestResponse(source);
if (response.body === null) {
const versions2 = parseManifest(
await response.text(),
VERSIONS_MANIFEST_URL
);
cachedManifestData.set(VERSIONS_MANIFEST_URL, {
const versions2 = parseManifest(await response.text(), source.url);
cachedManifestData.set(source, {
complete: true,
versions: versions2
});
@@ -53877,13 +53872,9 @@ async function findManifestVersion(predicate) {
continue;
}
if (versions.length === 0) {
rejectLegacyManifest(record, VERSIONS_MANIFEST_URL);
rejectLegacyManifest(record, source.url);
}
const versionData = parseManifestRecord(
record,
VERSIONS_MANIFEST_URL,
lineNumber
);
const versionData = parseManifestRecord(record, source.url, lineNumber);
versions.push(versionData);
if (predicate(versionData)) {
matchedVersion = versionData;
@@ -53898,9 +53889,9 @@ async function findManifestVersion(predicate) {
}
}
if (versions.length === 0) {
throw new Error(`Manifest at ${VERSIONS_MANIFEST_URL} is empty.`);
throw new Error(`Manifest at ${source.url} is empty.`);
}
cachedManifestData.set(VERSIONS_MANIFEST_URL, { complete, versions });
cachedManifestData.set(source, { complete, versions });
return matchedVersion;
}
function parseManifestRecord(record, sourceDescription, lineNumber) {
@@ -53946,6 +53937,16 @@ function isRecord(value) {
return typeof value === "object" && value !== null;
}
// src/utils/inputs.ts
var VERSIONS_MANIFEST_URL = "https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
var GITHUB_VERSIONS_MANIFEST_URL = "https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
var ASTRAL_MANIFEST = {
custom: false,
fallbackUrl: GITHUB_VERSIONS_MANIFEST_URL,
newestFirst: true,
url: VERSIONS_MANIFEST_URL
};
// src/update-known-checksums.ts
async function run() {
const checksumFilePath = process.argv.slice(2)[0];
@@ -53954,7 +53955,7 @@ async function run() {
"Missing checksum file path. Usage: node dist/update-known-checksums/index.cjs <checksum-file-path>"
);
}
const latestVersion = await getLatestVersion();
const latestVersion = await getFirstVersion(ASTRAL_MANIFEST);
const latestKnownVersion = getLatestKnownVersion();
if (semver2.lte(latestVersion, latestKnownVersion)) {
info2(
@@ -53962,7 +53963,7 @@ async function run() {
);
return;
}
const versions = await fetchManifest();
const versions = await fetchManifest(ASTRAL_MANIFEST);
const checksumEntries = extractChecksumsFromManifest(versions);
await updateChecksums(checksumFilePath, checksumEntries);
setOutput("latest-version", latestVersion);
@@ -53989,4 +53990,41 @@ undici/lib/web/fetch/body.js:
undici/lib/web/websocket/frame.js:
undici/lib/web/websocket/frame.js:
(*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> *)
smol-toml/dist/date.js:
smol-toml/dist/error.js:
smol-toml/dist/util.js:
smol-toml/dist/primitive.js:
smol-toml/dist/extract.js:
smol-toml/dist/struct.js:
smol-toml/dist/parse.js:
smol-toml/dist/stringify.js:
smol-toml/dist/index.js:
(*!
* Copyright (c) Squirrel Chat et al., All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
*/