diff --git a/common/dist/index.js b/common/dist/index.js
index c6ad5af..85023f0 100644
--- a/common/dist/index.js
+++ b/common/dist/index.js
@@ -163772,6 +163772,7 @@ module.exports = SBOMParser;
const core = __nccwpck_require__(42186);
const github = __nccwpck_require__(95438);
+const https = __nccwpck_require__(95687);
module.exports = async function () {
@@ -163779,6 +163780,7 @@ module.exports = async function () {
const getVersionLabels = async function (potentialLabels, latestMinorVersion) {
const promises = potentialLabels.map(async potentialLabel => {
+
const minorVersion = getMinorFromPotentialLabel(potentialLabel);
if (minorVersion === latestMinorVersion) {
@@ -163795,10 +163797,10 @@ module.exports = async function () {
if (!latestPatchVersion) {
const calculatedVersionLabel = getVersionLabelFromPotential(potentialLabel); // fallback if GitHub is down, pom version is wrong, error at parsing
console.log(`No latest patch version found for potential label: ${potentialLabel}, returning calculated version ${calculatedVersionLabel}`);
- return calculatedVersionLabel;
+ return getNextPatchVersion(calculatedVersionLabel);
}
- return latestPatchVersion;
+ return getNextPatchVersion(calculatedVersionLabel);;
});
// Wait for all promises to settle and filter out null values
@@ -163858,6 +163860,12 @@ module.exports = async function () {
return match ? match[1] : null;
}
+ const getNextPatchVersion = function (currentVersion) {
+ const versionParts = currentVersion.split('.');
+ versionParts[2] = parseInt(versionParts[2]) + 1;
+ return versionParts.join('.');
+ }
+
const getLatestPatchVersion = async function (potentialLabel) {
console.log(`Get latest patch version for issue: #${issueNumber} for potential label:`, potentialLabel);
try {
@@ -163870,15 +163878,25 @@ module.exports = async function () {
console.log(`Minor version found: ${minorVersion}`);
}
- const maintenanceRepoName = 'camunda-bpm-platform-maintenance';
- const pomXML = await getFileContent(owner, maintenanceRepoName, 'pom.xml', minorVersion);
+ const patchVersionRegex = new RegExp(`(camDownloads\\.branches\\['${minorVersion}'\\]\\s*=\\s*)(\\[[\\s\\S]*?\\])(\\s*;)`);
+ const matchJson = downloadPage.match(patchVersionRegex);
+
+ // Return the version if found, otherwise return null
+ let versionsJsonString = matchJson ? matchJson[2] : null;
+
+ if (versionsJsonString == null) {
+ console.log(`No patch version could be extracted for potential label: ${potentialLabel}. Returning null.`);
+ return null;
+ }
+
+ console.log(`Patch Versions to fetch first element:`, versionsJsonString);
- // Define regex to match ...
- const patchVersionRegex = /camunda-root<\/artifactId>\s*(\d+\.\d+\.\d+)(?:-\w+)?<\/version>/;
- const match = pomXML.match(patchVersionRegex); //FIXME something is not working here
+ const extractFirstPatchVersionFromJson = new RegExp(`(number\\: ')(.*)\\,`);
+ const matchFirstPatch = versionsJsonString.match(extractFirstPatchVersionFromJson);
+ let firstPatchVersion = matchFirstPatch ? matchFirstPatch[2] : null;
- // Return the version if found, otherwise return null
- return match ? match[1] : null;
+ console.log(`The latest version is: ${firstPatchVersion}`);
+ return firstPatchVersion;
} catch (error) {
console.error("Error fetching the XML document:", error);
return null;
@@ -163897,22 +163915,30 @@ module.exports = async function () {
return match ? match[1] : null;
}
- async function getFileContent(owner, repo, path, ref) {
- try {
- const response = await octokit.rest.repos.getContent({
- owner,
- repo,
- path,
- ref, // branch name, commit SHA, or tag
- });
-
- // The content is base64 encoded, so we need to decode it
- const fileContent = Buffer.from(response.data.content, 'base64').toString('utf-8');
- console.log(fileContent);
- return fileContent
- } catch (error) {
- console.error("Error fetching file:", error);
- }
+ async function fetchDownloadPage() {
+ const url = `https://docs.camunda.org/enterprise/download/`;
+
+ return new Promise((resolve, reject) => {
+ https.get(url, (response) => {
+ let data = '';
+
+ if (response.statusCode !== 200) {
+ reject(new Error(`Failed to fetch data. Status code: ${response.statusCode}`));
+ response.resume(); // Consume response data to free up memory
+ return;
+ }
+
+ response.on('data', (chunk) => {
+ data += chunk;
+ });
+
+ response.on('end', () => {
+ resolve(data);
+ });
+ }).on('error', (error) => {
+ reject(error);
+ });
+ });
}
const setLabels = async function (owner, repo, issueNumber, labels) {
@@ -163948,11 +163974,12 @@ module.exports = async function () {
return;
}
+ const downloadPage = await fetchDownloadPage();
+
const latestVersion = await getLatestMinorVersion();
console.log(`Latest minor version: ${latestVersion}`);
const versionLabels = await getVersionLabels(potentialLabels, latestVersion);
- console.log(versionLabels);
await setLabels(owner, repoName, issueNumber, versionLabels);
await removeLabels(owner, repoName, issueNumber, potentialLabels);
diff --git a/common/src/set-version-labels.js b/common/src/set-version-labels.js
index 590295e..1543d8f 100644
--- a/common/src/set-version-labels.js
+++ b/common/src/set-version-labels.js
@@ -1,5 +1,6 @@
const core = require('@actions/core');
const github = require('@actions/github');
+const https = require('https');
module.exports = async function () {
@@ -7,6 +8,7 @@ module.exports = async function () {
const getVersionLabels = async function (potentialLabels, latestMinorVersion) {
const promises = potentialLabels.map(async potentialLabel => {
+
const minorVersion = getMinorFromPotentialLabel(potentialLabel);
if (minorVersion === latestMinorVersion) {
@@ -23,10 +25,10 @@ module.exports = async function () {
if (!latestPatchVersion) {
const calculatedVersionLabel = getVersionLabelFromPotential(potentialLabel); // fallback if GitHub is down, pom version is wrong, error at parsing
console.log(`No latest patch version found for potential label: ${potentialLabel}, returning calculated version ${calculatedVersionLabel}`);
- return calculatedVersionLabel;
+ return getNextPatchVersion(calculatedVersionLabel);
}
- return latestPatchVersion;
+ return getNextPatchVersion(calculatedVersionLabel);;
});
// Wait for all promises to settle and filter out null values
@@ -86,6 +88,12 @@ module.exports = async function () {
return match ? match[1] : null;
}
+ const getNextPatchVersion = function (currentVersion) {
+ const versionParts = currentVersion.split('.');
+ versionParts[2] = parseInt(versionParts[2]) + 1;
+ return versionParts.join('.');
+ }
+
const getLatestPatchVersion = async function (potentialLabel) {
console.log(`Get latest patch version for issue: #${issueNumber} for potential label:`, potentialLabel);
try {
@@ -98,15 +106,25 @@ module.exports = async function () {
console.log(`Minor version found: ${minorVersion}`);
}
- const maintenanceRepoName = 'camunda-bpm-platform-maintenance';
- const pomXML = await getFileContent(owner, maintenanceRepoName, 'pom.xml', minorVersion);
+ const patchVersionRegex = new RegExp(`(camDownloads\\.branches\\['${minorVersion}'\\]\\s*=\\s*)(\\[[\\s\\S]*?\\])(\\s*;)`);
+ const matchJson = downloadPage.match(patchVersionRegex);
+
+ // Return the version if found, otherwise return null
+ let versionsJsonString = matchJson ? matchJson[2] : null;
- // Define regex to match ...
- const patchVersionRegex = /camunda-root<\/artifactId>\s*(\d+\.\d+\.\d+)(?:-\w+)?<\/version>/;
- const match = pomXML.match(patchVersionRegex); //FIXME something is not working here
+ if (versionsJsonString == null) {
+ console.log(`No patch version could be extracted for potential label: ${potentialLabel}. Returning null.`);
+ return null;
+ }
- // Return the version if found, otherwise return null
- return match ? match[1] : null;
+ console.log(`Patch Versions to fetch first element:`, versionsJsonString);
+
+ const extractFirstPatchVersionFromJson = new RegExp(`(number\\: ')(.*)('\\,)`);
+ const matchFirstPatch = versionsJsonString.match(extractFirstPatchVersionFromJson);
+ let firstPatchVersion = matchFirstPatch ? matchFirstPatch[2] : null;
+
+ console.log(`The latest version is: ${firstPatchVersion}`);
+ return firstPatchVersion;
} catch (error) {
console.error("Error fetching the XML document:", error);
return null;
@@ -125,22 +143,30 @@ module.exports = async function () {
return match ? match[1] : null;
}
- async function getFileContent(owner, repo, path, ref) {
- try {
- const response = await octokit.rest.repos.getContent({
- owner,
- repo,
- path,
- ref, // branch name, commit SHA, or tag
- });
-
- // The content is base64 encoded, so we need to decode it
- const fileContent = Buffer.from(response.data.content, 'base64').toString('utf-8');
- console.log(fileContent);
- return fileContent
- } catch (error) {
- console.error("Error fetching file:", error);
- }
+ async function fetchDownloadPage() {
+ const url = `https://docs.camunda.org/enterprise/download/`;
+
+ return new Promise((resolve, reject) => {
+ https.get(url, (response) => {
+ let data = '';
+
+ if (response.statusCode !== 200) {
+ reject(new Error(`Failed to fetch data. Status code: ${response.statusCode}`));
+ response.resume(); // Consume response data to free up memory
+ return;
+ }
+
+ response.on('data', (chunk) => {
+ data += chunk;
+ });
+
+ response.on('end', () => {
+ resolve(data);
+ });
+ }).on('error', (error) => {
+ reject(error);
+ });
+ });
}
const setLabels = async function (owner, repo, issueNumber, labels) {
@@ -176,11 +202,12 @@ module.exports = async function () {
return;
}
+ const downloadPage = await fetchDownloadPage();
+
const latestVersion = await getLatestMinorVersion();
console.log(`Latest minor version: ${latestVersion}`);
const versionLabels = await getVersionLabels(potentialLabels, latestVersion);
- console.log(versionLabels);
await setLabels(owner, repoName, issueNumber, versionLabels);
await removeLabels(owner, repoName, issueNumber, potentialLabels);