@redpanda-data/docs-extensions-and-macros 3.2.8 → 3.2.10
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 +32 -14
- package/extensions/version-fetcher/set-latest-version.js +50 -54
- 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,39 @@ 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);
|
|
25
36
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const releaseSha = tagRef.data.object.sha;
|
|
37
|
+
if (sortedReleases.length > 0) {
|
|
38
|
+
const latestRedpandaReleaseVersion = sortedReleases[0];
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
// Get the commit hash for the highest version tag
|
|
41
|
+
const commitData = await github.rest.git.getRef({
|
|
42
|
+
owner,
|
|
43
|
+
repo,
|
|
44
|
+
ref: `tags/v${latestRedpandaReleaseVersion}`
|
|
45
|
+
});
|
|
46
|
+
const latestRedpandaReleaseCommitHash = commitData.data.object.sha;
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
return [latestRedpandaReleaseVersion, latestRedpandaReleaseCommitHash.substring(0, 7)];
|
|
49
|
+
} else {
|
|
50
|
+
console.log("No valid semver releases found for Redpanda.");
|
|
51
|
+
return [null, null];
|
|
52
|
+
}
|
|
35
53
|
} catch (error) {
|
|
36
|
-
console.error(error);
|
|
54
|
+
console.error('Failed to fetch Redpanda release information:', error);
|
|
37
55
|
return [null, null];
|
|
38
56
|
}
|
|
39
|
-
};
|
|
57
|
+
};
|
|
@@ -1,70 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const GetLatestRedpandaVersion = require('./get-latest-redpanda-version');
|
|
8
|
-
const GetLatestConsoleVersion = require('./get-latest-console-version');
|
|
9
|
-
const GetLatestOperatorVersion = require('./get-latest-operator-version');
|
|
1
|
+
const GetLatestRedpandaVersion = require('./get-latest-redpanda-version')
|
|
2
|
+
const GetLatestConsoleVersion = require('./get-latest-console-version')
|
|
3
|
+
const GetLatestOperatorVersion = require('./get-latest-operator-version')
|
|
4
|
+
const GetLatestHelmChartVersion = require('./get-latest-redpanda-helm-version')
|
|
10
5
|
const chalk = require('chalk')
|
|
11
|
-
|
|
6
|
+
const semver = require('semver')
|
|
12
7
|
|
|
13
8
|
module.exports.register = function ({ config }) {
|
|
14
9
|
const logger = this.getLogger('set-latest-version-extension')
|
|
15
10
|
if (!process.env.REDPANDA_GITHUB_TOKEN) {
|
|
16
|
-
logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.')
|
|
11
|
+
logger.warn('REDPANDA_GITHUB_TOKEN environment variable not set. Attempting unauthenticated request.')
|
|
17
12
|
}
|
|
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
13
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
this.on('contentClassified', async ({ contentCatalog }) => {
|
|
15
|
+
try {
|
|
16
|
+
const results = await Promise.allSettled([
|
|
17
|
+
GetLatestRedpandaVersion(),
|
|
18
|
+
GetLatestConsoleVersion(),
|
|
19
|
+
GetLatestOperatorVersion(),
|
|
20
|
+
GetLatestHelmChartVersion()
|
|
21
|
+
])
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
component.latest.asciidoc.attributes['
|
|
56
|
-
|
|
41
|
+
if (LatestRedpandaVersion && semver.valid(LatestRedpandaVersion[0])) {
|
|
42
|
+
let currentVersion = component.latest.asciidoc.attributes['full-version'] || '0.0.0'
|
|
43
|
+
if (semver.gt(LatestRedpandaVersion[0], currentVersion)) {
|
|
44
|
+
component.latest.asciidoc.attributes['full-version'] = `${LatestRedpandaVersion[0]}@`
|
|
45
|
+
component.latest.asciidoc.attributes['latest-release-commit'] = `${LatestRedpandaVersion[1]}@`
|
|
46
|
+
logger.info(`Updated to latest Redpanda version: ${LatestRedpandaVersion[0]} with commit: ${LatestRedpandaVersion[1]}`)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
57
49
|
|
|
58
|
-
|
|
50
|
+
if (LatestOperatorVersion) {
|
|
51
|
+
component.latest.asciidoc.attributes['latest-operator-version'] = `${LatestOperatorVersion}@`
|
|
52
|
+
logger.info(`Updated to latest Redpanda Operator version: ${LatestOperatorVersion}`)
|
|
53
|
+
}
|
|
59
54
|
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
if (LatestHelmChartVersion) {
|
|
56
|
+
component.latest.asciidoc.attributes['latest-redpanda-helm-chart-version'] = `${LatestHelmChartVersion}@`
|
|
57
|
+
logger.info(`Updated to latest Redpanda Helm chart version: ${LatestHelmChartVersion}`)
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
console.log(`${chalk.green('Updated Redpanda documentation versions successfully.')}`)
|
|
62
|
+
} catch (error) {
|
|
63
|
+
logger.error(`Error updating versions: ${error}`)
|
|
64
|
+
}
|
|
65
|
+
})
|
|
70
66
|
}
|