Shortcut to latest version for minimum version specifier (#598)

This is faster than downloading all available versions from GitHub to
determine the highest matching version.

Fixes: #585
This commit is contained in:
Kevin Stillhammer
2025-09-30 19:55:27 +02:00
committed by GitHub
parent d0cc045d04
commit d8a37f6566
3 changed files with 88 additions and 113 deletions

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

@@ -129037,20 +129037,29 @@ function getExtension(platform) {
async function resolveVersion(versionInput, manifestFile, githubToken) {
core.debug(`Resolving version: ${versionInput}`);
let version;
const isSimpleMinimumVersionSpecifier = versionInput.includes(">") && !versionInput.includes(",");
if (isSimpleMinimumVersionSpecifier) {
core.info("Found minimum version specifier, using latest version");
}
if (manifestFile) {
version =
versionInput === "latest"
versionInput === "latest" || isSimpleMinimumVersionSpecifier
? await (0, version_manifest_1.getLatestKnownVersion)(manifestFile)
: versionInput;
}
else {
version =
versionInput === "latest"
versionInput === "latest" || isSimpleMinimumVersionSpecifier
? await getLatestVersion(githubToken)
: versionInput;
}
if (tc.isExplicitVersion(version)) {
core.debug(`Version ${version} is an explicit version.`);
if (isSimpleMinimumVersionSpecifier) {
if (!pep440.satisfies(version, versionInput)) {
throw new Error(`No version found for ${versionInput}`);
}
}
return version;
}
const availableVersions = await getAvailableVersions(githubToken);