5
0
mirror of https://github.com/astral-sh/setup-uv.git synced 2025-12-23 11:01:03 +00:00

Use latest version from manifest-file (#458)

If a manifest-file is supplied the default value of the version input
(latest) will get the latest version available in the manifest. That
might not be the actual latest version available in the official uv
repo.
This commit is contained in:
Kevin Stillhammer
2025-06-19 21:23:43 +02:00
committed by GitHub
parent a02a550bdd
commit 445689ea25
5 changed files with 46 additions and 17 deletions

View File

@@ -7,7 +7,10 @@ import { OWNER, REPO, TOOL_CACHE_NAME } from "../utils/constants";
import type { Architecture, Platform } from "../utils/platforms";
import { validateChecksum } from "./checksum/checksum";
import { Octokit } from "../utils/octokit";
import { getDownloadUrl } from "./version-manifest";
import {
getDownloadUrl,
getLatestKnownVersion as getLatestVersionInManifest,
} from "./version-manifest";
export function tryGetFromToolCache(
arch: Architecture,
@@ -127,13 +130,22 @@ function getExtension(platform: Platform): string {
export async function resolveVersion(
versionInput: string,
manifestFile: string | undefined,
githubToken: string,
): Promise<string> {
core.debug(`Resolving version: ${versionInput}`);
const version =
versionInput === "latest"
? await getLatestVersion(githubToken)
: versionInput;
let version: string;
if (manifestFile) {
version =
versionInput === "latest"
? await getLatestVersionInManifest(manifestFile)
: versionInput;
} else {
version =
versionInput === "latest"
? await getLatestVersion(githubToken)
: versionInput;
}
if (tc.isExplicitVersion(version)) {
core.debug(`Version ${version} is an explicit version.`);
return version;

View File

@@ -87,7 +87,7 @@ async function setupUv(
checkSum: string | undefined,
githubToken: string,
): Promise<{ uvDir: string; version: string }> {
const resolvedVersion = await determineVersion();
const resolvedVersion = await determineVersion(manifestFile);
const toolCacheResult = tryGetFromToolCache(arch, resolvedVersion);
if (toolCacheResult.installedPath) {
core.info(`Found uv in tool-cache for ${toolCacheResult.version}`);
@@ -127,9 +127,11 @@ async function setupUv(
};
}
async function determineVersion(): Promise<string> {
async function determineVersion(
manifestFile: string | undefined,
): Promise<string> {
if (versionInput !== "") {
return await resolveVersion(versionInput, githubToken);
return await resolveVersion(versionInput, manifestFile, githubToken);
}
const versionFromUvToml = getUvVersionFromConfigFile(
`${workingDirectory}${path.sep}uv.toml`,
@@ -144,6 +146,7 @@ async function determineVersion(): Promise<string> {
}
return await resolveVersion(
versionFromUvToml || versionFromPyproject || "latest",
manifestFile,
githubToken,
);
}