mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-04-03 01:47:33 +00:00
Shortcircuit latest version from manifest (#828)
The first version is guaranteed to be the latest
This commit is contained in:
committed by
GitHub
parent
4dd8ab4520
commit
cec208311d
@@ -1,5 +1,4 @@
|
||||
import * as core from "@actions/core";
|
||||
import * as semver from "semver";
|
||||
import { VERSIONS_MANIFEST_URL } from "../utils/constants";
|
||||
import { fetch } from "../utils/fetch";
|
||||
import { selectDefaultVariant } from "./variant-selection";
|
||||
@@ -99,20 +98,12 @@ export function parseManifest(
|
||||
export async function getLatestVersion(
|
||||
manifestUrl: string = VERSIONS_MANIFEST_URL,
|
||||
): Promise<string> {
|
||||
const versions = await fetchManifest(manifestUrl);
|
||||
const [firstVersion, ...remainingVersions] = versions.map(
|
||||
(versionData) => versionData.version,
|
||||
);
|
||||
const latestVersion = (await fetchManifest(manifestUrl))[0]?.version;
|
||||
|
||||
if (firstVersion === undefined) {
|
||||
if (latestVersion === undefined) {
|
||||
throw new Error("No versions found in manifest data");
|
||||
}
|
||||
|
||||
const latestVersion = remainingVersions.reduce(
|
||||
(latest, current) => (semver.gt(current, latest) ? current : latest),
|
||||
firstVersion,
|
||||
);
|
||||
|
||||
core.debug(`Latest version from manifest: ${latestVersion}`);
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user