@redpanda-data/docs-extensions-and-macros 3.2.8 → 3.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/version-fetcher/get-latest-console-version.js +2 -2
- package/extensions/version-fetcher/get-latest-redpanda-helm-version.js +33 -0
- package/extensions/version-fetcher/get-latest-redpanda-version.js +33 -14
- package/extensions/version-fetcher/set-latest-version.js +53 -53
- package/package.json +1 -1
|
@@ -18,11 +18,11 @@ const github = new OctokitWithRetries(githubOptions);
|
|
|
18
18
|
|
|
19
19
|
module.exports = async () => {
|
|
20
20
|
try {
|
|
21
|
-
// Fetch the latest 10 releases
|
|
22
21
|
const releases = await github.rest.repos.listReleases({
|
|
23
22
|
owner,
|
|
24
23
|
repo,
|
|
25
|
-
|
|
24
|
+
page: 1,
|
|
25
|
+
per_page: 50
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Filter valid semver tags and sort them
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const { Octokit } = require("@octokit/rest");
|
|
2
|
+
const { retry } = require("@octokit/plugin-retry");
|
|
3
|
+
const yaml = require('js-yaml');
|
|
4
|
+
const OctokitWithRetries = Octokit.plugin(retry);
|
|
5
|
+
|
|
6
|
+
const githubOptions = {
|
|
7
|
+
userAgent: 'Redpanda Docs',
|
|
8
|
+
baseUrl: 'https://api.github.com',
|
|
9
|
+
auth: process.env.REDPANDA_GITHUB_TOKEN
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const github = new OctokitWithRetries(githubOptions);
|
|
13
|
+
const owner = 'redpanda-data';
|
|
14
|
+
const repo = 'helm-charts';
|
|
15
|
+
const path = 'charts/redpanda/Chart.yaml';
|
|
16
|
+
|
|
17
|
+
module.exports = async () => {
|
|
18
|
+
try {
|
|
19
|
+
const response = await github.repos.getContent({
|
|
20
|
+
owner: owner,
|
|
21
|
+
repo: repo,
|
|
22
|
+
path: path,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const contentBase64 = response.data.content;
|
|
26
|
+
const contentDecoded = Buffer.from(contentBase64, 'base64').toString('utf8');
|
|
27
|
+
const chartYaml = yaml.load(contentDecoded);
|
|
28
|
+
return chartYaml.version;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('Failed to fetch chart version:', error.message);
|
|
31
|
+
return null
|
|
32
|
+
}
|
|
33
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// Fetch the latest release version from GitHub
|
|
2
1
|
const { Octokit } = require("@octokit/rest");
|
|
3
2
|
const { retry } = require("@octokit/plugin-retry");
|
|
3
|
+
const semver = require("semver");
|
|
4
4
|
const OctokitWithRetries = Octokit.plugin(retry);
|
|
5
|
+
|
|
5
6
|
const owner = 'redpanda-data';
|
|
6
7
|
const repo = 'redpanda';
|
|
7
8
|
|
|
@@ -18,22 +19,40 @@ const github = new OctokitWithRetries(githubOptions);
|
|
|
18
19
|
|
|
19
20
|
module.exports = async () => {
|
|
20
21
|
try {
|
|
21
|
-
// Fetch the
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
// Fetch all the releases from the repository
|
|
23
|
+
const releases = await github.rest.repos.listReleases({
|
|
24
|
+
owner,
|
|
25
|
+
repo,
|
|
26
|
+
page: 1,
|
|
27
|
+
per_page: 50
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Filter valid semver tags and sort them to find the highest version
|
|
31
|
+
const sortedReleases = releases.data
|
|
32
|
+
.map(release => release.tag_name.replace(/^v/, ''))
|
|
33
|
+
.filter(tag => semver.valid(tag))
|
|
34
|
+
// Sort in descending order to get the highest version first
|
|
35
|
+
.sort(semver.rcompare);
|
|
36
|
+
console.log(sortedReleases)
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const releaseSha = tagRef.data.object.sha;
|
|
38
|
+
if (sortedReleases.length > 0) {
|
|
39
|
+
const latestRedpandaReleaseVersion = sortedReleases[0];
|
|
29
40
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
// Get the commit hash for the highest version tag
|
|
42
|
+
const commitData = await github.rest.git.getRef({
|
|
43
|
+
owner,
|
|
44
|
+
repo,
|
|
45
|
+
ref: `tags/v${latestRedpandaReleaseVersion}`
|
|
46
|
+
});
|
|
47
|
+
const latestRedpandaReleaseCommitHash = commitData.data.object.sha;
|
|
33
48
|
|
|
34
|
-
|
|
49
|
+
return [latestRedpandaReleaseVersion, latestRedpandaReleaseCommitHash.substring(0, 7)];
|
|
50
|
+
} else {
|
|
51
|
+
console.log("No valid semver releases found for Redpanda.");
|
|
52
|
+
return [null, null];
|
|
53
|
+
}
|
|
35
54
|
} catch (error) {
|
|
36
|
-
console.error(error);
|
|
55
|
+
console.error('Failed to fetch Redpanda release information:', error);
|
|
37
56
|
return [null, null];
|
|
38
57
|
}
|
|
39
|
-
};
|
|
58
|
+
};
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
/* Example:
|
|
2
|
-
antora:
|
|
3
|
-
extensions:
|
|
4
|
-
- require: ./extensions/setLatestVersion.js
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
1
|
const GetLatestRedpandaVersion = require('./get-latest-redpanda-version');
|
|
8
2
|
const GetLatestConsoleVersion = require('./get-latest-console-version');
|
|
9
3
|
const GetLatestOperatorVersion = require('./get-latest-operator-version');
|
|
10
|
-
const
|
|
11
|
-
|
|
4
|
+
const GetLatestHelmChartVersion = require('./get-latest-redpanda-helm-version');
|
|
5
|
+
const chalk = require('chalk');
|
|
12
6
|
|
|
13
7
|
module.exports.register = function ({ config }) {
|
|
14
|
-
const logger = this.getLogger('set-latest-version-extension')
|
|
8
|
+
const logger = this.getLogger('set-latest-version-extension');
|
|
15
9
|
if (!process.env.REDPANDA_GITHUB_TOKEN) {
|
|
16
10
|
logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.');
|
|
17
11
|
}
|
|
18
|
-
this
|
|
19
|
-
.on('contentClassified', async ({ contentCatalog }) => {
|
|
20
|
-
try {
|
|
21
|
-
const LatestRedpandaVersion = await GetLatestRedpandaVersion();
|
|
22
|
-
const LatestConsoleVersion = await GetLatestConsoleVersion();
|
|
23
|
-
const LatestOperatorVersion = await GetLatestOperatorVersion();
|
|
24
|
-
if (LatestRedpandaVersion.length !== 2 || !LatestRedpandaVersion[0]) {
|
|
25
|
-
logger.warn('Failed to get the latest Redpanda version - using defaults');
|
|
26
|
-
}
|
|
27
|
-
if (!LatestConsoleVersion) {
|
|
28
|
-
logger.warn(`Failed to get latest Console version from GitHub - using default`)
|
|
29
|
-
}
|
|
30
|
-
if (!LatestOperatorVersion) {
|
|
31
|
-
logger.warn(`Failed to get latest Operator version from GitHub - using default`)
|
|
32
|
-
}
|
|
33
|
-
const components = await contentCatalog.getComponents();
|
|
34
|
-
for (let i = 0; i < components.length; i++) {
|
|
35
|
-
let component = components[i];
|
|
36
12
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
this.on('contentClassified', async ({ contentCatalog }) => {
|
|
14
|
+
try {
|
|
15
|
+
const results = await Promise.allSettled([
|
|
16
|
+
GetLatestRedpandaVersion(),
|
|
17
|
+
GetLatestConsoleVersion(),
|
|
18
|
+
GetLatestOperatorVersion(),
|
|
19
|
+
GetLatestHelmChartVersion()
|
|
20
|
+
]);
|
|
43
21
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
// Extracting results with fallbacks if promises were rejected
|
|
23
|
+
const LatestRedpandaVersion = results[0].status === 'fulfilled' ? results[0].value : null;
|
|
24
|
+
const LatestConsoleVersion = results[1].status === 'fulfilled' ? results[1].value : null;
|
|
25
|
+
const LatestOperatorVersion = results[2].status === 'fulfilled' ? results[2].value : null;
|
|
26
|
+
const LatestHelmChartVersion = results[3].status === 'fulfilled' ? results[3].value : null;
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
const components = await contentCatalog.getComponents();
|
|
29
|
+
components.forEach(component => {
|
|
30
|
+
component.versions.forEach(({ name, version, asciidoc }) => {
|
|
31
|
+
if (LatestConsoleVersion) {
|
|
32
|
+
asciidoc.attributes['latest-console-version'] = LatestConsoleVersion;
|
|
33
|
+
logger.info(`Set Redpanda Console version to ${LatestConsoleVersion} in ${name} ${version}`);
|
|
50
34
|
}
|
|
35
|
+
});
|
|
51
36
|
|
|
52
|
-
|
|
37
|
+
if (!component.latest.asciidoc) {
|
|
38
|
+
component.latest.asciidoc = { attributes: {} };
|
|
39
|
+
}
|
|
53
40
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
41
|
+
// Handle each version setting with appropriate logging
|
|
42
|
+
if (LatestRedpandaVersion) {
|
|
43
|
+
component.latest.asciidoc.attributes['full-version'] = LatestRedpandaVersion[0];
|
|
44
|
+
component.latest.asciidoc.attributes['latest-release-commit'] = LatestRedpandaVersion[1];
|
|
45
|
+
logger.info(`Set the latest Redpanda version to ${LatestRedpandaVersion[0]} ${LatestRedpandaVersion[1]}`);
|
|
46
|
+
} else {
|
|
47
|
+
logger.warn("Failed to get the latest Redpanda version - using defaults");
|
|
48
|
+
}
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
if (LatestOperatorVersion) {
|
|
51
|
+
component.latest.asciidoc.attributes['latest-operator-version'] = LatestOperatorVersion;
|
|
52
|
+
logger.info(`Set the latest Redpanda Operator version to ${LatestOperatorVersion}`);
|
|
53
|
+
} else {
|
|
54
|
+
logger.warn("Failed to get the latest Operator version from GitHub - using default");
|
|
55
|
+
}
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
if (LatestHelmChartVersion) {
|
|
58
|
+
component.latest.asciidoc.attributes['latest-redpanda-helm-chart-version'] = LatestHelmChartVersion;
|
|
59
|
+
logger.info(`Set the latest Redpanda Helm chart version to ${LatestHelmChartVersion}`);
|
|
60
|
+
} else {
|
|
61
|
+
logger.warn("Failed to get the latest Helm Chart version - using default");
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
console.log(`${chalk.green('Updated Redpanda documentation versions successfully.')}`);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
logger.error(`Error updating versions: ${error}`);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|