switch to checking github tags for php releases

This commit is contained in:
Robin Appelman 2024-03-07 18:46:10 +01:00
commit 58becf3b4b
3 changed files with 19 additions and 23 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<info> <info>
<dependencies> <dependencies>
<nextcloud min-version="25" max-version="28" /> <nextcloud min-version="25" max-version="29" />
</dependencies> </dependencies>
</info> </info>

20
dist/index.js vendored
View file

@ -42555,12 +42555,8 @@ function parseVersionId(raw) {
return parseInt(matches[1], 10) / 10 + parseInt(matches[2], 10) / 10 return parseInt(matches[1], 10) / 10 + parseInt(matches[2], 10) / 10
} }
async function getAllPhpVersions() { async function isPhpVersionReleased(version) {
// again hacky, but gives a nicely always-up-to-date list return await urlExist(`https://github.com/php/php-src/releases/tag/php-${version.toFixed(1)}.0`);
let res = await client.get(`https://www.php.net/releases/`);
let releasesHtml = await res.readBody();
let matches = [...releasesHtml.matchAll(/<h2>(\d+\.\d+\.\d+)<\/h2>/g)];
return matches.map(match => match[1]);
} }
async function distroSupportsPhpVersion(version) { async function distroSupportsPhpVersion(version) {
@ -42629,7 +42625,8 @@ function copy(obj) {
const versions = range(minVersion, maxVersion); const versions = range(minVersion, maxVersion);
const versionData= await Promise.all(versions.map(async (version) => { // we reverse the order to put highest version first for the "branched off check"
const versionData= (await Promise.all(versions.reverse().map(async (version) => {
const branch = await getBranch(version); const branch = await getBranch(version);
const php = await getSupportedVersions(branch); const php = await getSupportedVersions(branch);
return { return {
@ -42637,9 +42634,7 @@ function copy(obj) {
"phpMax": php.max, "phpMax": php.max,
"branch": branch, "branch": branch,
} }
})); }))).reverse();
// parseFloat will ignore patch versions, leaving us with all major and minor releases
const possiblePhpVersions = (await getAllPhpVersions()).map(parseFloat).filter(onlyUnique);
// matrix with a single php version per server version // matrix with a single php version per server version
const serverMatrix = cartesianProduct({ const serverMatrix = cartesianProduct({
@ -42662,8 +42657,11 @@ function copy(obj) {
for(let version = phpMin; version <= phpMax; version += 0.1) { for(let version = phpMin; version <= phpMax; version += 0.1) {
// floats are a pain // floats are a pain
version = parseFloat(version.toFixed(1)); version = parseFloat(version.toFixed(1));
if (possiblePhpVersions.includes(version)) { if (await isPhpVersionReleased(version)) {
php.push(version.toFixed(1)); php.push(version.toFixed(1));
} else {
// no more minors for this major
version = Math.ceil(version) - 0.1;
} }
} }

View file

@ -41,12 +41,8 @@ function parseVersionId(raw) {
return parseInt(matches[1], 10) / 10 + parseInt(matches[2], 10) / 10 return parseInt(matches[1], 10) / 10 + parseInt(matches[2], 10) / 10
} }
async function getAllPhpVersions() { async function isPhpVersionReleased(version) {
// again hacky, but gives a nicely always-up-to-date list return await urlExist(`https://github.com/php/php-src/releases/tag/php-${version.toFixed(1)}.0`);
let res = await client.get(`https://www.php.net/releases/`);
let releasesHtml = await res.readBody();
let matches = [...releasesHtml.matchAll(/<h2>(\d+\.\d+\.\d+)<\/h2>/g)];
return matches.map(match => match[1]);
} }
async function distroSupportsPhpVersion(version) { async function distroSupportsPhpVersion(version) {
@ -115,7 +111,8 @@ function copy(obj) {
const versions = range(minVersion, maxVersion); const versions = range(minVersion, maxVersion);
const versionData= await Promise.all(versions.map(async (version) => { // we reverse the order to put highest version first for the "branched off check"
const versionData= (await Promise.all(versions.reverse().map(async (version) => {
const branch = await getBranch(version); const branch = await getBranch(version);
const php = await getSupportedVersions(branch); const php = await getSupportedVersions(branch);
return { return {
@ -123,9 +120,7 @@ function copy(obj) {
"phpMax": php.max, "phpMax": php.max,
"branch": branch, "branch": branch,
} }
})); }))).reverse();
// parseFloat will ignore patch versions, leaving us with all major and minor releases
const possiblePhpVersions = (await getAllPhpVersions()).map(parseFloat).filter(onlyUnique);
// matrix with a single php version per server version // matrix with a single php version per server version
const serverMatrix = cartesianProduct({ const serverMatrix = cartesianProduct({
@ -148,8 +143,11 @@ function copy(obj) {
for(let version = phpMin; version <= phpMax; version += 0.1) { for(let version = phpMin; version <= phpMax; version += 0.1) {
// floats are a pain // floats are a pain
version = parseFloat(version.toFixed(1)); version = parseFloat(version.toFixed(1));
if (possiblePhpVersions.includes(version)) { if (await isPhpVersionReleased(version)) {
php.push(version.toFixed(1)); php.push(version.toFixed(1));
} else {
// no more minors for this major
version = Math.ceil(version) - 0.1;
} }
} }