mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-12-04 02:16:06 +00:00
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:
1 parent
521745f16c
commit
36300bab3f
19 files changed
+1637
-1647
No files matched your search
@@ -1,10 +1,6 @@
|
||||
export const TOOL_CACHE_NAME = "uv";
|
||||
export const STATE_UV_PATH = "uv-path";
|
||||
export const STATE_UV_VERSION = "uv-version";
|
||||
export const VERSIONS_MANIFEST_URL =
|
||||
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
|
||||
export const GITHUB_VERSIONS_MANIFEST_URL =
|
||||
"https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
|
||||
|
||||
/** GitHub Releases URL prefix for uv artifacts. */
|
||||
export const GITHUB_RELEASES_PREFIX =
|
||||
|
||||
+32
-8
@@ -19,6 +19,30 @@ export interface CacheLocalPath {
|
||||
|
||||
export type ResolutionStrategy = "highest" | "lowest";
|
||||
|
||||
export interface ManifestSource {
|
||||
readonly url: string;
|
||||
readonly newestFirst: boolean;
|
||||
readonly fallbackUrl?: string;
|
||||
readonly custom: boolean;
|
||||
}
|
||||
|
||||
const VERSIONS_MANIFEST_URL =
|
||||
"https://releases.astral.sh/github/versions/main/v1/uv.ndjson";
|
||||
const GITHUB_VERSIONS_MANIFEST_URL =
|
||||
"https://raw.githubusercontent.com/astral-sh/versions/main/v1/uv.ndjson";
|
||||
|
||||
export const ASTRAL_MANIFEST: ManifestSource = {
|
||||
custom: false,
|
||||
fallbackUrl: GITHUB_VERSIONS_MANIFEST_URL,
|
||||
newestFirst: true,
|
||||
url: VERSIONS_MANIFEST_URL,
|
||||
};
|
||||
const GITHUB_MANIFEST: ManifestSource = {
|
||||
custom: false,
|
||||
newestFirst: true,
|
||||
url: GITHUB_VERSIONS_MANIFEST_URL,
|
||||
};
|
||||
|
||||
export interface SetupInputs {
|
||||
workingDirectory: string;
|
||||
version: string;
|
||||
@@ -45,7 +69,7 @@ export interface SetupInputs {
|
||||
toolDir?: string;
|
||||
pythonDir: string;
|
||||
githubToken: string;
|
||||
manifestFile?: string;
|
||||
manifestSource: ManifestSource;
|
||||
downloadFromAstralMirror: boolean;
|
||||
addProblemMatchers: boolean;
|
||||
quiet: boolean;
|
||||
@@ -84,9 +108,9 @@ export function loadInputs(): SetupInputs {
|
||||
const toolDir = getToolDir(workingDirectory);
|
||||
const pythonDir = getUvPythonDir();
|
||||
const githubToken = core.getInput("github-token");
|
||||
const manifestFile = getManifestFile();
|
||||
const downloadFromAstralMirror =
|
||||
core.getInput("download-from-astral-mirror") === "true";
|
||||
const manifestSource = getManifestSource(downloadFromAstralMirror);
|
||||
const addProblemMatchers = core.getInput("add-problem-matchers") === "true";
|
||||
const quiet = core.getInput("quiet") === "true";
|
||||
const resolutionStrategy = getResolutionStrategy();
|
||||
@@ -105,7 +129,7 @@ export function loadInputs(): SetupInputs {
|
||||
githubToken,
|
||||
ignoreEmptyWorkdir,
|
||||
ignoreNothingToCache,
|
||||
manifestFile,
|
||||
manifestSource,
|
||||
noProject,
|
||||
pruneCache,
|
||||
pythonArch,
|
||||
@@ -384,12 +408,12 @@ function resolveRelativePath(
|
||||
return hasNegation ? `!${resolvedPath}` : resolvedPath;
|
||||
}
|
||||
|
||||
function getManifestFile(): string | undefined {
|
||||
const manifestFileInput = core.getInput("manifest-file");
|
||||
if (manifestFileInput !== "") {
|
||||
return manifestFileInput;
|
||||
function getManifestSource(useAstralMirror: boolean): ManifestSource {
|
||||
const manifestFile = core.getInput("manifest-file");
|
||||
if (manifestFile !== "") {
|
||||
return { custom: true, newestFirst: false, url: manifestFile };
|
||||
}
|
||||
return undefined;
|
||||
return useAstralMirror ? ASTRAL_MANIFEST : GITHUB_MANIFEST;
|
||||
}
|
||||
|
||||
function getResolutionStrategy(): ResolutionStrategy {
|
||||
|
||||
Reference in new issue
Block a user