mirror of
https://github.com/astral-sh/setup-uv.git
synced 2025-07-15 10:31:20 +00:00
Add input manifest-file (#454)
Adds capability to maintain custom uv builds or to override the default sources
This commit is contained in:
committed by
GitHub
parent
7bbb36f434
commit
60cc2b4585
208
dist/setup/index.js
generated
vendored
208
dist/setup/index.js
generated
vendored
@ -124676,7 +124676,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.tryGetFromToolCache = tryGetFromToolCache;
|
||||
exports.downloadVersion = downloadVersion;
|
||||
exports.downloadVersionFromGithub = downloadVersionFromGithub;
|
||||
exports.downloadVersionFromManifest = downloadVersionFromManifest;
|
||||
exports.resolveVersion = resolveVersion;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const tc = __importStar(__nccwpck_require__(33472));
|
||||
@ -124686,6 +124687,7 @@ const node_fs_1 = __nccwpck_require__(73024);
|
||||
const constants_1 = __nccwpck_require__(56156);
|
||||
const checksum_1 = __nccwpck_require__(95391);
|
||||
const octokit_1 = __nccwpck_require__(73352);
|
||||
const version_manifest_1 = __nccwpck_require__(54000);
|
||||
function tryGetFromToolCache(arch, version) {
|
||||
core.debug(`Trying to get uv from tool cache for ${version}...`);
|
||||
const cachedVersions = tc.findAllVersions(constants_1.TOOL_CACHE_NAME, arch);
|
||||
@ -124697,18 +124699,26 @@ function tryGetFromToolCache(arch, version) {
|
||||
const installedPath = tc.find(constants_1.TOOL_CACHE_NAME, resolvedVersion, arch);
|
||||
return { version: resolvedVersion, installedPath };
|
||||
}
|
||||
async function downloadVersion(serverUrl, platform, arch, version, checkSum, githubToken) {
|
||||
const resolvedVersion = await resolveVersion(version, githubToken);
|
||||
async function downloadVersionFromGithub(serverUrl, platform, arch, version, checkSum, githubToken) {
|
||||
const artifact = `uv-${arch}-${platform}`;
|
||||
let extension = ".tar.gz";
|
||||
if (platform === "pc-windows-msvc") {
|
||||
extension = ".zip";
|
||||
const extension = getExtension(platform);
|
||||
const downloadUrl = `${serverUrl}/${constants_1.OWNER}/${constants_1.REPO}/releases/download/${version}/${artifact}${extension}`;
|
||||
return await downloadVersion(downloadUrl, artifact, platform, arch, version, checkSum, githubToken);
|
||||
}
|
||||
async function downloadVersionFromManifest(manifestUrl, platform, arch, version, checkSum, githubToken) {
|
||||
const downloadUrl = await (0, version_manifest_1.getDownloadUrl)(manifestUrl, version, arch, platform);
|
||||
if (!downloadUrl) {
|
||||
core.warning(`manifest-file does not contain version ${version}, arch ${arch}, platform ${platform}. Falling back to GitHub releases.`);
|
||||
return await downloadVersionFromGithub("https://github.com", platform, arch, version, checkSum, githubToken);
|
||||
}
|
||||
const downloadUrl = `${serverUrl}/${constants_1.OWNER}/${constants_1.REPO}/releases/download/${resolvedVersion}/${artifact}${extension}`;
|
||||
return await downloadVersion(downloadUrl, `uv-${arch}-${platform}`, platform, arch, version, checkSum, githubToken);
|
||||
}
|
||||
async function downloadVersion(downloadUrl, artifactName, platform, arch, version, checkSum, githubToken) {
|
||||
core.info(`Downloading uv from "${downloadUrl}" ...`);
|
||||
const downloadPath = await tc.downloadTool(downloadUrl, undefined, githubToken);
|
||||
await (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, resolvedVersion);
|
||||
await (0, checksum_1.validateChecksum)(checkSum, downloadPath, arch, platform, version);
|
||||
let uvDir;
|
||||
const extension = getExtension(platform);
|
||||
if (platform === "pc-windows-msvc") {
|
||||
const fullPathWithExtension = `${downloadPath}${extension}`;
|
||||
await node_fs_1.promises.copyFile(downloadPath, fullPathWithExtension);
|
||||
@ -124717,10 +124727,13 @@ async function downloadVersion(serverUrl, platform, arch, version, checkSum, git
|
||||
}
|
||||
else {
|
||||
const extractedDir = await tc.extractTar(downloadPath);
|
||||
uvDir = path.join(extractedDir, artifact);
|
||||
uvDir = path.join(extractedDir, artifactName);
|
||||
}
|
||||
const cachedToolDir = await tc.cacheDir(uvDir, constants_1.TOOL_CACHE_NAME, resolvedVersion, arch);
|
||||
return { version: resolvedVersion, cachedToolDir };
|
||||
const cachedToolDir = await tc.cacheDir(uvDir, constants_1.TOOL_CACHE_NAME, version, arch);
|
||||
return { version: version, cachedToolDir };
|
||||
}
|
||||
function getExtension(platform) {
|
||||
return platform === "pc-windows-msvc" ? ".zip" : ".tar.gz";
|
||||
}
|
||||
async function resolveVersion(versionInput, githubToken) {
|
||||
core.debug(`Resolving version: ${versionInput}`);
|
||||
@ -124807,6 +124820,108 @@ function maxSatisfying(versions, version) {
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 54000:
|
||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.getLatestKnownVersion = getLatestKnownVersion;
|
||||
exports.getDownloadUrl = getDownloadUrl;
|
||||
exports.updateVersionManifest = updateVersionManifest;
|
||||
const node_fs_1 = __nccwpck_require__(73024);
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const semver = __importStar(__nccwpck_require__(39318));
|
||||
const fetch_1 = __nccwpck_require__(3385);
|
||||
async function getLatestKnownVersion(manifestUrl) {
|
||||
const manifestEntries = await getManifestEntries(manifestUrl);
|
||||
return manifestEntries.reduce((a, b) => semver.gt(a.version, b.version) ? a : b).version;
|
||||
}
|
||||
async function getDownloadUrl(manifestUrl, version, arch, platform) {
|
||||
const manifestEntries = await getManifestEntries(manifestUrl);
|
||||
const entry = manifestEntries.find((entry) => entry.version === version &&
|
||||
entry.arch === arch &&
|
||||
entry.platform === platform);
|
||||
return entry ? entry.downloadUrl : undefined;
|
||||
}
|
||||
async function getManifestEntries(manifestUrl) {
|
||||
let data;
|
||||
if (manifestUrl !== undefined) {
|
||||
core.info(`Fetching manifest-file from: ${manifestUrl}`);
|
||||
const response = await (0, fetch_1.fetch)(manifestUrl, {});
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch manifest-file: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
data = await response.text();
|
||||
}
|
||||
else {
|
||||
core.info("manifest-file not provided, reading from local file.");
|
||||
const fileContent = await node_fs_1.promises.readFile("version-manifest.json");
|
||||
data = fileContent.toString();
|
||||
}
|
||||
return JSON.parse(data);
|
||||
}
|
||||
async function updateVersionManifest(manifestUrl, downloadUrls) {
|
||||
const manifest = [];
|
||||
for (const downloadUrl of downloadUrls) {
|
||||
const urlParts = downloadUrl.split("/");
|
||||
const version = urlParts[urlParts.length - 2];
|
||||
const artifactName = urlParts[urlParts.length - 1];
|
||||
if (!artifactName.startsWith("uv-")) {
|
||||
continue;
|
||||
}
|
||||
if (artifactName.startsWith("uv-installer")) {
|
||||
continue;
|
||||
}
|
||||
const artifactParts = artifactName.split(".")[0].split("-");
|
||||
manifest.push({
|
||||
version: version,
|
||||
artifactName: artifactName,
|
||||
arch: artifactParts[1],
|
||||
platform: artifactName.split(`uv-${artifactParts[1]}-`)[1].split(".")[0],
|
||||
downloadUrl: downloadUrl,
|
||||
});
|
||||
}
|
||||
core.debug(`Updating manifest-file: ${JSON.stringify(manifest)}`);
|
||||
await node_fs_1.promises.writeFile(manifestUrl, JSON.stringify(manifest));
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 99660:
|
||||
@ -124997,7 +125112,14 @@ async function setupUv(platform, arch, checkSum, githubToken) {
|
||||
version: toolCacheResult.version,
|
||||
};
|
||||
}
|
||||
const downloadVersionResult = await (0, download_version_1.downloadVersion)(inputs_1.serverUrl, platform, arch, resolvedVersion, checkSum, githubToken);
|
||||
let downloadVersionResult;
|
||||
if (inputs_1.serverUrl !== "https://github.com") {
|
||||
core.warning("The input server-url is deprecated. Please use manifest-file instead.");
|
||||
downloadVersionResult = await (0, download_version_1.downloadVersionFromGithub)(inputs_1.serverUrl, platform, arch, resolvedVersion, checkSum, githubToken);
|
||||
}
|
||||
else {
|
||||
downloadVersionResult = await (0, download_version_1.downloadVersionFromManifest)(inputs_1.manifestFile, platform, arch, resolvedVersion, checkSum, githubToken);
|
||||
}
|
||||
return {
|
||||
uvDir: downloadVersionResult.cachedToolDir,
|
||||
version: downloadVersionResult.version,
|
||||
@ -125174,6 +125296,35 @@ exports.OWNER = "astral-sh";
|
||||
exports.TOOL_CACHE_NAME = "uv";
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3385:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.fetch = void 0;
|
||||
exports.getProxyAgent = getProxyAgent;
|
||||
const undici_1 = __nccwpck_require__(46752);
|
||||
function getProxyAgent() {
|
||||
const httpProxy = process.env.HTTP_PROXY || process.env.http_proxy;
|
||||
if (httpProxy) {
|
||||
return new undici_1.ProxyAgent(httpProxy);
|
||||
}
|
||||
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||
if (httpsProxy) {
|
||||
return new undici_1.ProxyAgent(httpsProxy);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const fetch = async (url, opts) => await (0, undici_1.fetch)(url, {
|
||||
dispatcher: getProxyAgent(),
|
||||
...opts,
|
||||
});
|
||||
exports.fetch = fetch;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9612:
|
||||
@ -125218,7 +125369,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.githubToken = exports.serverUrl = exports.toolDir = exports.toolBinDir = exports.ignoreEmptyWorkdir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.workingDirectory = exports.activateEnvironment = exports.pythonVersion = exports.version = void 0;
|
||||
exports.manifestFile = exports.githubToken = exports.serverUrl = exports.toolDir = exports.toolBinDir = exports.ignoreEmptyWorkdir = exports.ignoreNothingToCache = exports.pruneCache = exports.cacheDependencyGlob = exports.cacheLocalPath = exports.cacheSuffix = exports.enableCache = exports.checkSum = exports.workingDirectory = exports.activateEnvironment = exports.pythonVersion = exports.version = void 0;
|
||||
const core = __importStar(__nccwpck_require__(37484));
|
||||
const node_path_1 = __importDefault(__nccwpck_require__(76760));
|
||||
exports.version = core.getInput("version");
|
||||
@ -125237,6 +125388,7 @@ exports.toolBinDir = getToolBinDir();
|
||||
exports.toolDir = getToolDir();
|
||||
exports.serverUrl = core.getInput("server-url");
|
||||
exports.githubToken = core.getInput("github-token");
|
||||
exports.manifestFile = getManifestFile();
|
||||
function getEnableCache() {
|
||||
const enableCacheInput = core.getInput("enable-cache");
|
||||
if (enableCacheInput === "auto") {
|
||||
@ -125292,6 +125444,13 @@ function expandTilde(input) {
|
||||
}
|
||||
return input;
|
||||
}
|
||||
function getManifestFile() {
|
||||
const manifestFileInput = core.getInput("manifest-file");
|
||||
if (manifestFileInput !== "") {
|
||||
return manifestFileInput;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -125302,38 +125461,21 @@ function expandTilde(input) {
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.Octokit = exports.customFetch = void 0;
|
||||
exports.getProxyAgent = getProxyAgent;
|
||||
exports.Octokit = void 0;
|
||||
const core_1 = __nccwpck_require__(60767);
|
||||
const plugin_paginate_rest_1 = __nccwpck_require__(93779);
|
||||
const plugin_rest_endpoint_methods_1 = __nccwpck_require__(49210);
|
||||
const undici_1 = __nccwpck_require__(46752);
|
||||
const fetch_1 = __nccwpck_require__(3385);
|
||||
const DEFAULTS = {
|
||||
baseUrl: "https://api.github.com",
|
||||
userAgent: "setup-uv",
|
||||
};
|
||||
function getProxyAgent() {
|
||||
const httpProxy = process.env.HTTP_PROXY || process.env.http_prox;
|
||||
if (httpProxy) {
|
||||
return new undici_1.ProxyAgent(httpProxy);
|
||||
}
|
||||
const httpsProxy = process.env.HTTPS_PROXY || process.env.https_proxy;
|
||||
if (httpsProxy) {
|
||||
return new undici_1.ProxyAgent(httpsProxy);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
const customFetch = async (url, opts) => await (0, undici_1.fetch)(url, {
|
||||
dispatcher: getProxyAgent(),
|
||||
...opts,
|
||||
});
|
||||
exports.customFetch = customFetch;
|
||||
exports.Octokit = core_1.Octokit.plugin(plugin_paginate_rest_1.paginateRest, plugin_rest_endpoint_methods_1.legacyRestEndpointMethods).defaults(function buildDefaults(options) {
|
||||
return {
|
||||
...DEFAULTS,
|
||||
...options,
|
||||
request: {
|
||||
fetch: exports.customFetch,
|
||||
fetch: fetch_1.fetch,
|
||||
...options.request,
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user