also get supported php versions

This commit is contained in:
Robin Appelman 2023-11-02 18:06:11 +01:00
commit a82a7d40fd
7 changed files with 82 additions and 15 deletions

47
dist/index.js vendored
View file

@ -38791,15 +38791,39 @@ const xpath = __nccwpck_require__(5319);
const DOMParser = (__nccwpck_require__(7286)/* .DOMParser */ .a);
const fs = __nccwpck_require__(7147);
const urlExist = __nccwpck_require__(5565);
const {HttpClient} = __nccwpck_require__(6255);
function isVersionReleased(version) {
return urlExist(`https://download.nextcloud.com/server/releases/latest-${version}.zip`);
const client = new HttpClient('nextcloud-version-matrix')
function versionHashBranch(version) {
return urlExist(`https://github.com/nextcloud/server/tree/stable${version}`);
}
async function getBranch(version) {
if (await versionHashBranch(version)) {
return `stable${version}`;
} else {
return "master";
}
}
function range(from, to) {
return [...Array(to - from + 1).keys()].map(i => i + from);
}
async function getSupportedVersions(branch) {
let res = await client.get(`https://raw.githubusercontent.com/nextcloud/server/${branch}/lib/versioncheck.php`);
let versionCheckCode = await res.readBody();
let min = parseVersionId(versionCheckCode.match(/PHP_VERSION_ID < (\d+)/)[1]);
let max = parseVersionId(versionCheckCode.match(/PHP_VERSION_ID >= (\d+)/)[1]);
return {min: min, max: max};
}
function parseVersionId(raw) {
let matches = raw.match(/^(\d\d)(\d)/)
return parseInt(matches[1], 10) / 10 + parseInt(matches[2], 10) / 10
}
function onlyUnique(value, index, array) {
return array.indexOf(value) === index;
}
@ -38816,17 +38840,24 @@ function onlyUnique(value, index, array) {
console.log(`App supports from ${minVersion} till ${maxVersion}`);
const versions = range(minVersion, maxVersion);
core.setOutput("versions", JSON.stringify(versions));
const branches = await Promise.all(versions.map(async (version) => {
if (await isVersionReleased(version)) {
return `stable${version}`;
} else {
return "master";
const matrix = await Promise.all(versions.map(async (version) => {
const branch = await getBranch(version);
const php = await getSupportedVersions(branch);
return {
"php-versions": php.min.toFixed(1),
"server-versions": branch,
}
}));
core.setOutput("versions", JSON.stringify(versions));
const branches = matrix.map(matrix => matrix["server-versions"]);
core.setOutput("branches", JSON.stringify(branches.filter(onlyUnique)));
core.setOutput("matrix", JSON.stringify({
include: matrix
}));
} catch (error) {
core.setFailed(error.message);