From b7b0de6f6bcc660b53a4cac736763ee4f7e045d3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 29 Aug 2026 14:07:05 +0200 Subject: [PATCH] perf(versions): Hardcode known PHP versions and Nextcloud PHP version ranges Signed-off-by: Joas Schilling --- src/action.mjs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/action.mjs b/src/action.mjs index b1047b1..d116140 100644 --- a/src/action.mjs +++ b/src/action.mjs @@ -9,11 +9,40 @@ import {HttpClient} from '@actions/http-client' const client = new HttpClient('nextcloud-version-matrix') +// Known PHP version ranges of the stable branches of nextcloud/server. +// Values match what parsing lib/versioncheck.php of the branch would yield. +const KNOWN_PHP_VERSION_RANGES = { + stable22: {min: 7.3, max: 8.0}, + stable23: {min: 7.3, max: 8.0}, + stable24: {min: 7.4, max: 8.1}, + stable25: {min: 7.4, max: 8.1}, + stable26: {min: 8.0, max: 8.2}, + stable27: {min: 8.0, max: 8.2}, + stable28: {min: 8.0, max: 8.3}, + stable29: {min: 8.0, max: 8.3}, + stable30: {min: 8.1, max: 8.3}, + stable31: {min: 8.1, max: 8.4}, + stable32: {min: 8.1, max: 8.4}, + stable33: {min: 8.2, max: 8.5}, + stable34: {min: 8.2, max: 8.5}, + stable35: {min: 8.3, max: 8.5}, +}; + +// PHP versions known to have a php-src release tag. +const KNOWN_RELEASED_PHP_VERSIONS = new Set([ + '7.0', '7.1', '7.2', '7.3', '7.4', + '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', +]); + function versionHashBranch(version) { return urlExist(`https://github.com/nextcloud/server/tree/stable${version}`); } async function getBranch(version) { + if (KNOWN_PHP_VERSION_RANGES[`stable${version}`]) { + return `stable${version}`; + } + if (await versionHashBranch(version)) { return `stable${version}`; } else { @@ -26,6 +55,10 @@ function range(from, to) { } async function getSupportedVersions(branch) { + if (KNOWN_PHP_VERSION_RANGES[branch]) { + return {...KNOWN_PHP_VERSION_RANGES[branch]}; + } + // yes, this is hacky, but it saves having to keep a list updated let res = await client.get(`https://raw.githubusercontent.com/nextcloud/server/${branch}/lib/versioncheck.php`); let versionCheckCode = await res.readBody(); @@ -47,6 +80,11 @@ function parseVersionId(raw) { } async function isPhpVersionReleased(version) { + const shortVersion = version.toFixed(1); + if (KNOWN_RELEASED_PHP_VERSIONS.has(shortVersion)) { + return true; + } + return await urlExist(`https://github.com/php/php-src/releases/tag/php-${version.toFixed(1)}.0`); }