This commit is contained in:
Zanie Blue
2026-01-22 07:57:07 -06:00
parent 0a4c5102bd
commit 8bd9170ab9
9 changed files with 106 additions and 272 deletions

114
dist/setup/index.js generated vendored
View File

@@ -91627,36 +91627,32 @@ const fs = __importStar(__nccwpck_require__(3024));
const core = __importStar(__nccwpck_require__(7484));
const known_checksums_1 = __nccwpck_require__(2764);
async function validateChecksum(checkSum, downloadPath, arch, platform, version, ndjsonChecksum) {
let isValid;
let checksumUsed;
// Priority: user-provided checksum > KNOWN_CHECKSUMS > NDJSON fallback
const key = `${arch}-${platform}-${version}`;
let checksumToUse;
let source;
if (checkSum !== undefined && checkSum !== "") {
checksumUsed = checkSum;
core.debug("Using user-provided checksum.");
isValid = await validateFileCheckSum(downloadPath, checkSum);
checksumToUse = checkSum;
source = "user-provided";
}
else if (key in known_checksums_1.KNOWN_CHECKSUMS) {
checksumToUse = known_checksums_1.KNOWN_CHECKSUMS[key];
source = `known checksum for ${key}`;
}
else if (ndjsonChecksum !== undefined && ndjsonChecksum !== "") {
checksumToUse = ndjsonChecksum;
source = "NDJSON version data";
}
else {
const key = `${arch}-${platform}-${version}`;
if (key in known_checksums_1.KNOWN_CHECKSUMS) {
checksumUsed = known_checksums_1.KNOWN_CHECKSUMS[key];
core.debug(`Using known checksum for ${key}.`);
isValid = await validateFileCheckSum(downloadPath, checksumUsed);
}
else if (ndjsonChecksum !== undefined && ndjsonChecksum !== "") {
checksumUsed = ndjsonChecksum;
core.debug("Using checksum from NDJSON version data.");
isValid = await validateFileCheckSum(downloadPath, ndjsonChecksum);
}
else {
core.debug(`No checksum found for ${key}.`);
}
core.debug(`No checksum found for ${key}.`);
return;
}
if (isValid === false) {
throw new Error(`Checksum for ${downloadPath} did not match ${checksumUsed}.`);
}
if (isValid === true) {
core.debug(`Checksum for ${downloadPath} is valid.`);
core.debug(`Using ${source}.`);
const isValid = await validateFileCheckSum(downloadPath, checksumToUse);
if (!isValid) {
throw new Error(`Checksum for ${downloadPath} did not match ${checksumToUse}.`);
}
core.debug(`Checksum for ${downloadPath} is valid.`);
}
async function validateFileCheckSum(filePath, expected) {
return new Promise((resolve, reject) => {
@@ -95882,7 +95878,7 @@ var __importStar = (this && this.__importStar) || (function () {
})();
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.tryGetFromToolCache = tryGetFromToolCache;
exports.downloadVersionFromGithub = downloadVersionFromGithub;
exports.downloadVersionFromNdjson = downloadVersionFromNdjson;
exports.downloadVersionFromManifest = downloadVersionFromManifest;
exports.resolveVersion = resolveVersion;
const node_fs_1 = __nccwpck_require__(3024);
@@ -95906,17 +95902,11 @@ function tryGetFromToolCache(arch, version) {
const installedPath = tc.find(constants_1.TOOL_CACHE_NAME, resolvedVersion, arch);
return { installedPath, version: resolvedVersion };
}
async function downloadVersionFromGithub(platform, arch, version, checkSum, githubToken) {
async function downloadVersionFromNdjson(platform, arch, version, checkSum, githubToken) {
const artifact = `uv-${arch}-${platform}`;
const extension = getExtension(platform);
// Try to get artifact info from NDJSON (includes checksum)
let artifactInfo;
try {
artifactInfo = await (0, versions_client_1.getArtifact)(version, arch, platform);
}
catch (err) {
core.debug(`Failed to get artifact from NDJSON: ${err.message}`);
}
// Get artifact info from NDJSON (includes URL and checksum)
const artifactInfo = await (0, versions_client_1.getArtifact)(version, arch, platform);
const downloadUrl = artifactInfo?.url ??
`https://github.com/${constants_1.OWNER}/${constants_1.REPO}/releases/download/${version}/${artifact}${extension}`;
return await downloadVersion(downloadUrl, artifact, platform, arch, version, checkSum, githubToken, artifactInfo?.sha256);
@@ -95924,19 +95914,9 @@ async function downloadVersionFromGithub(platform, arch, version, checkSum, gith
async function downloadVersionFromManifest(manifestUrl, platform, arch, version, checkSum, githubToken) {
const downloadUrl = await (0, version_manifest_1.getDownloadUrl)(manifestUrl, version, arch, platform);
if (!downloadUrl) {
core.info(`manifest-file does not contain version ${version}, arch ${arch}, platform ${platform}. Falling back to GitHub releases.`);
return await downloadVersionFromGithub(platform, arch, version, checkSum, githubToken);
throw new Error(`manifest-file does not contain version ${version}, arch ${arch}, platform ${platform}.`);
}
// Try to get checksum from NDJSON for manifest downloads too
let ndjsonChecksum;
try {
const artifactInfo = await (0, versions_client_1.getArtifact)(version, arch, platform);
ndjsonChecksum = artifactInfo?.sha256;
}
catch (err) {
core.debug(`Failed to get artifact from NDJSON: ${err.message}`);
}
return await downloadVersion(downloadUrl, `uv-${arch}-${platform}`, platform, arch, version, checkSum, githubToken, ndjsonChecksum);
return await downloadVersion(downloadUrl, `uv-${arch}-${platform}`, platform, arch, version, checkSum, githubToken, undefined);
}
async function downloadVersion(downloadUrl, artifactName, platform, arch, version, checkSum, githubToken, ndjsonChecksum) {
core.info(`Downloading uv from "${downloadUrl}" ...`);
@@ -96205,42 +96185,19 @@ async function fetchVersionData() {
if (!response.ok) {
throw new Error(`Failed to fetch version data: ${response.status} ${response.statusText}`);
}
const body = await response.text();
const versions = [];
if (!response.body) {
throw new Error("Response body is null");
}
// Stream and parse NDJSON line by line
const decoder = new TextDecoder();
let buffer = "";
for await (const chunk of response.body) {
buffer += decoder.decode(chunk, { stream: true });
// Process complete lines
const lines = buffer.split("\n");
// Keep the last potentially incomplete line in buffer
buffer = lines.pop() ?? "";
for (const line of lines) {
const trimmed = line.trim();
if (trimmed === "") {
continue;
}
try {
const version = JSON.parse(trimmed);
versions.push(version);
}
catch {
core.debug(`Failed to parse NDJSON line: ${trimmed}`);
}
for (const line of body.split("\n")) {
const trimmed = line.trim();
if (trimmed === "") {
continue;
}
}
// Process any remaining content in buffer
const remaining = buffer.trim();
if (remaining !== "") {
try {
const version = JSON.parse(remaining);
const version = JSON.parse(trimmed);
versions.push(version);
}
catch {
core.debug(`Failed to parse NDJSON line: ${remaining}`);
core.debug(`Failed to parse NDJSON line: ${trimmed}`);
}
}
if (versions.length === 0) {
@@ -96513,7 +96470,10 @@ async function setupUv(platform, arch, checkSum, githubToken) {
version: toolCacheResult.version,
};
}
const downloadVersionResult = await (0, download_version_1.downloadVersionFromManifest)(inputs_1.manifestFile, platform, arch, resolvedVersion, checkSum, githubToken);
// Use the same source for download as we used for version resolution
const downloadVersionResult = inputs_1.manifestFile
? await (0, download_version_1.downloadVersionFromManifest)(inputs_1.manifestFile, platform, arch, resolvedVersion, checkSum, githubToken)
: await (0, download_version_1.downloadVersionFromNdjson)(platform, arch, resolvedVersion, checkSum, githubToken);
return {
uvDir: downloadVersionResult.cachedToolDir,
version: downloadVersionResult.version,