Shortcircuit latest version from manifest (#828)

The first version is guaranteed to be the latest
This commit is contained in:
Kevin Stillhammer
2026-03-28 17:43:22 +01:00
committed by GitHub
parent 4dd8ab4520
commit cec208311d
4 changed files with 98 additions and 114 deletions

View File

@@ -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;
}