@redpanda-data/docs-extensions-and-macros 4.2.3 → 4.2.4
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module.exports = async (github, owner, repo) => {
|
|
2
|
-
const semver = require('semver')
|
|
2
|
+
const semver = require('semver');
|
|
3
3
|
try {
|
|
4
4
|
// Fetch all the releases from the repository
|
|
5
5
|
const releases = await github.rest.repos.listReleases({
|
|
@@ -11,46 +11,52 @@ module.exports = async (github, owner, repo) => {
|
|
|
11
11
|
|
|
12
12
|
// Filter valid semver tags and sort them to find the highest version
|
|
13
13
|
const sortedReleases = releases.data
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
.filter(release => semver.valid(release.tag_name.replace(/^v/, '')))
|
|
15
|
+
.sort((a, b) => semver.rcompare(
|
|
16
|
+
a.tag_name.replace(/^v/, ''),
|
|
17
|
+
b.tag_name.replace(/^v/, '')
|
|
18
|
+
));
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
// Find latest non-RC release that is NOT a draft
|
|
21
|
+
const latestRedpandaRelease = sortedReleases.find(
|
|
22
|
+
release => !release.tag_name.includes('-rc') && !release.draft
|
|
23
|
+
);
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
// Find latest RC release (can be draft or not, adjust if needed)
|
|
26
|
+
const latestRcRelease = sortedReleases.find(
|
|
27
|
+
release => release.tag_name.includes('-rc')
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
let latestRedpandaReleaseCommitHash = null;
|
|
31
|
+
if (latestRedpandaRelease) {
|
|
23
32
|
const commitData = await github.rest.git.getRef({
|
|
24
33
|
owner,
|
|
25
34
|
repo,
|
|
26
|
-
ref: `tags/${
|
|
35
|
+
ref: `tags/${latestRedpandaRelease.tag_name}`
|
|
27
36
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
let latestRcReleaseCommitHash = null;
|
|
31
|
-
if (latestRcReleaseVersion) {
|
|
32
|
-
const rcCommitData = await github.rest.git.getRef({
|
|
33
|
-
owner,
|
|
34
|
-
repo,
|
|
35
|
-
ref: `tags/${latestRcReleaseVersion}`
|
|
36
|
-
});
|
|
37
|
-
latestRcReleaseCommitHash = rcCommitData.data.object.sha;
|
|
38
|
-
}
|
|
37
|
+
latestRedpandaReleaseCommitHash = commitData.data.object.sha;
|
|
38
|
+
}
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} : null
|
|
49
|
-
};
|
|
50
|
-
} else {
|
|
51
|
-
console.log("No valid semver releases found for Redpanda.");
|
|
52
|
-
return { latestRedpandaRelease: null, latestRcRelease: null };
|
|
40
|
+
let latestRcReleaseCommitHash = null;
|
|
41
|
+
if (latestRcRelease) {
|
|
42
|
+
const rcCommitData = await github.rest.git.getRef({
|
|
43
|
+
owner,
|
|
44
|
+
repo,
|
|
45
|
+
ref: `tags/${latestRcRelease.tag_name}`
|
|
46
|
+
});
|
|
47
|
+
latestRcReleaseCommitHash = rcCommitData.data.object.sha;
|
|
53
48
|
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
latestRedpandaRelease: latestRedpandaRelease ? {
|
|
52
|
+
version: latestRedpandaRelease.tag_name,
|
|
53
|
+
commitHash: latestRedpandaReleaseCommitHash.substring(0, 7)
|
|
54
|
+
} : null,
|
|
55
|
+
latestRcRelease: latestRcRelease ? {
|
|
56
|
+
version: latestRcRelease.tag_name,
|
|
57
|
+
commitHash: latestRcReleaseCommitHash.substring(0, 7)
|
|
58
|
+
} : null
|
|
59
|
+
};
|
|
54
60
|
} catch (error) {
|
|
55
61
|
console.error('Failed to fetch Redpanda release information:', error);
|
|
56
62
|
return { latestRedpandaRelease: null, latestRcRelease: null };
|