mirror of
https://github.com/icewind1991/nextcloud-version-matrix.git
synced 2026-06-03 09:34:12 +02:00
also get supported php versions
This commit is contained in:
parent
d43cc64aae
commit
a82a7d40fd
7 changed files with 82 additions and 15 deletions
2
.github/workflows/info.xml
vendored
2
.github/workflows/info.xml
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<info>
|
<info>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<nextcloud min-version="25" max-version="29" />
|
<nextcloud min-version="25" max-version="28" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</info>
|
</info>
|
||||||
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
|
|
@ -23,3 +23,4 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
echo -e "Versions :\n${{ steps.run.outputs.versions }}"
|
echo -e "Versions :\n${{ steps.run.outputs.versions }}"
|
||||||
echo -e "Branches :\n${{ steps.run.outputs.branches }}"
|
echo -e "Branches :\n${{ steps.run.outputs.branches }}"
|
||||||
|
echo -e "Matrix :\n${{ steps.run.outputs.matrix }}"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ outputs:
|
||||||
description: 'List of supported nextcloud versions'
|
description: 'List of supported nextcloud versions'
|
||||||
branches:
|
branches:
|
||||||
description: 'List of branches for the supported nextcloud versions'
|
description: 'List of branches for the supported nextcloud versions'
|
||||||
|
matrix:
|
||||||
|
description: 'Test matrix with server branch and php version'
|
||||||
runs:
|
runs:
|
||||||
using: 'node20'
|
using: 'node20'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
|
||||||
47
dist/index.js
vendored
47
dist/index.js
vendored
|
|
@ -38791,15 +38791,39 @@ const xpath = __nccwpck_require__(5319);
|
||||||
const DOMParser = (__nccwpck_require__(7286)/* .DOMParser */ .a);
|
const DOMParser = (__nccwpck_require__(7286)/* .DOMParser */ .a);
|
||||||
const fs = __nccwpck_require__(7147);
|
const fs = __nccwpck_require__(7147);
|
||||||
const urlExist = __nccwpck_require__(5565);
|
const urlExist = __nccwpck_require__(5565);
|
||||||
|
const {HttpClient} = __nccwpck_require__(6255);
|
||||||
|
|
||||||
function isVersionReleased(version) {
|
const client = new HttpClient('nextcloud-version-matrix')
|
||||||
return urlExist(`https://download.nextcloud.com/server/releases/latest-${version}.zip`);
|
|
||||||
|
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) {
|
function range(from, to) {
|
||||||
return [...Array(to - from + 1).keys()].map(i => i + from);
|
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) {
|
function onlyUnique(value, index, array) {
|
||||||
return array.indexOf(value) === index;
|
return array.indexOf(value) === index;
|
||||||
}
|
}
|
||||||
|
|
@ -38816,17 +38840,24 @@ function onlyUnique(value, index, array) {
|
||||||
console.log(`App supports from ${minVersion} till ${maxVersion}`);
|
console.log(`App supports from ${minVersion} till ${maxVersion}`);
|
||||||
|
|
||||||
const versions = range(minVersion, maxVersion);
|
const versions = range(minVersion, maxVersion);
|
||||||
core.setOutput("versions", JSON.stringify(versions));
|
|
||||||
|
|
||||||
const branches = await Promise.all(versions.map(async (version) => {
|
const matrix = await Promise.all(versions.map(async (version) => {
|
||||||
if (await isVersionReleased(version)) {
|
const branch = await getBranch(version);
|
||||||
return `stable${version}`;
|
const php = await getSupportedVersions(branch);
|
||||||
} else {
|
return {
|
||||||
return "master";
|
"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("branches", JSON.stringify(branches.filter(onlyUnique)));
|
||||||
|
core.setOutput("matrix", JSON.stringify({
|
||||||
|
include: matrix
|
||||||
|
}));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|
|
||||||
1
package-lock.json
generated
1
package-lock.json
generated
|
|
@ -15,6 +15,7 @@
|
||||||
"xpath": "0.0.27"
|
"xpath": "0.0.27"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@actions/http-client": "^2.2.0",
|
||||||
"@vercel/ncc": "^0.38.1"
|
"@vercel/ncc": "^0.38.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
|
"@actions/http-client": "^2.2.0",
|
||||||
"url-exist": "^2.0.2",
|
"url-exist": "^2.0.2",
|
||||||
"xmldom": "^0.6.0",
|
"xmldom": "^0.6.0",
|
||||||
"xpath": "0.0.27"
|
"xpath": "0.0.27"
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,39 @@ const xpath = require('xpath');
|
||||||
const DOMParser = require('xmldom').DOMParser;
|
const DOMParser = require('xmldom').DOMParser;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const urlExist = require('url-exist');
|
const urlExist = require('url-exist');
|
||||||
|
const {HttpClient} = require('@actions/http-client');
|
||||||
|
|
||||||
|
const client = new HttpClient('nextcloud-version-matrix')
|
||||||
|
|
||||||
function versionHashBranch(version) {
|
function versionHashBranch(version) {
|
||||||
return urlExist(`https://github.com/nextcloud/server/tree/stable${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) {
|
function range(from, to) {
|
||||||
return [...Array(to - from + 1).keys()].map(i => i + from);
|
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) {
|
function onlyUnique(value, index, array) {
|
||||||
return array.indexOf(value) === index;
|
return array.indexOf(value) === index;
|
||||||
}
|
}
|
||||||
|
|
@ -28,17 +52,24 @@ function onlyUnique(value, index, array) {
|
||||||
console.log(`App supports from ${minVersion} till ${maxVersion}`);
|
console.log(`App supports from ${minVersion} till ${maxVersion}`);
|
||||||
|
|
||||||
const versions = range(minVersion, maxVersion);
|
const versions = range(minVersion, maxVersion);
|
||||||
core.setOutput("versions", JSON.stringify(versions));
|
|
||||||
|
|
||||||
const branches = await Promise.all(versions.map(async (version) => {
|
const matrix = await Promise.all(versions.map(async (version) => {
|
||||||
if (await versionHashBranch(version)) {
|
const branch = await getBranch(version);
|
||||||
return `stable${version}`;
|
const php = await getSupportedVersions(branch);
|
||||||
} else {
|
return {
|
||||||
return "master";
|
"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("branches", JSON.stringify(branches.filter(onlyUnique)));
|
||||||
|
core.setOutput("matrix", JSON.stringify({
|
||||||
|
include: matrix
|
||||||
|
}));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue