mirror of
https://github.com/icewind1991/nextcloud-version-matrix.git
synced 2026-06-03 17:44:08 +02:00
bundle
This commit is contained in:
parent
bab067c141
commit
33c0246e79
6 changed files with 38861 additions and 7 deletions
44
src/action.js
Normal file
44
src/action.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
const core = require('@actions/core');
|
||||
const xpath = require('xpath');
|
||||
const DOMParser = require('xmldom').DOMParser;
|
||||
const fs = require('fs');
|
||||
const urlExist = require('url-exist');
|
||||
|
||||
function isVersionReleased(version) {
|
||||
return urlExist(`https://download.nextcloud.com/server/releases/latest-${version}.zip`);
|
||||
}
|
||||
|
||||
function range(from, to) {
|
||||
return [...Array(to - from + 1).keys()].map(i => i + from);
|
||||
}
|
||||
|
||||
function onlyUnique(value, index, array) {
|
||||
return array.indexOf(value) === index;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const filename = core.getInput('filename') || 'appinfo/info.xml';
|
||||
|
||||
const content = fs.readFileSync(filename, 'utf8');
|
||||
const document = new DOMParser().parseFromString(content);
|
||||
const minVersion = parseInt(xpath.select1("//info//dependencies//nextcloud/@min-version", document).value, 10);
|
||||
const maxVersion = parseInt(xpath.select1("//info//dependencies//nextcloud/@max-version", document).value, 10);
|
||||
|
||||
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";
|
||||
}
|
||||
}));
|
||||
|
||||
core.setOutput("branches", JSON.stringify(branches.filter(onlyUnique)));
|
||||
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue