Skip to content

Commit 18cdd4a

Browse files
themr0cpraveenkumar
authored andcommitted
docs: added an Antora extension that get versions from Makefile an inject the result as AsciiDoc attributes
Signed-off-by: Fabrice Flore-Thébault <ffloreth@redhat.com>
1 parent f69c337 commit 18cdd4a

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

antora-playbook.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ urls:
2929
antora:
3030
extensions:
3131
- "@antora/lunr-extension"
32+
- ./docs/extensions/get-versions.js
3233
asciidoc:
3334
sourcemap: true
3435
attributes:

docs/extensions/get-versions.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"use strict";
2+
const fs = require("fs");
3+
const child_process = require("child_process");
4+
module.exports.register = function () {
5+
this.on("playbookBuilt", function ({ playbook }) {
6+
// Get versions from Makefile
7+
// Use utf8 encoding to have a string rather than a buffer in the output
8+
const ocp_ver_full = child_process.execSync(
9+
"grep '^OPENSHIFT_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
10+
{ encoding: "utf8" }
11+
);
12+
const ocp_ver = child_process.execSync(
13+
"grep '^OPENSHIFT_VERSION' Makefile | cut -d' ' -f3 | cut -d'.' -f-2 | tr -d '\n'",
14+
{ encoding: "utf8" }
15+
);
16+
const podman_ver = child_process.execSync(
17+
"grep '^PODMAN_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
18+
{ encoding: "utf8" }
19+
);
20+
const prod_ver_full = child_process.execSync(
21+
"grep '^CRC_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
22+
{ encoding: "utf8" }
23+
);
24+
const prod_ver = child_process.execSync(
25+
"grep '^CRC_VERSION' Makefile | cut -d' ' -f3 | cut -d'.' -f-2 | tr -d '\n'",
26+
{ encoding: "utf8" }
27+
);
28+
const ushift_ver = child_process.execSync(
29+
"grep '^MICROSHIFT_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
30+
{ encoding: "utf8" }
31+
);
32+
33+
// Display versions
34+
console.log("OpenShift patch version: " + ocp_ver_full);
35+
console.log("OpenShift minor version: " + ocp_ver);
36+
console.log("Podman version: " + podman_ver);
37+
console.log("CRC patch version: " + prod_ver_full);
38+
console.log("CRC minor version: " + prod_ver);
39+
console.log("MicroShift version: " + ushift_ver);
40+
41+
// Set attributes values
42+
Object.assign(playbook.asciidoc.attributes, {
43+
"ocp-ver": ocp_ver,
44+
"ocp-ver-full": ocp_ver_full,
45+
"podman-ver": podman_ver,
46+
"prod-ver": prod_ver,
47+
"prod-ver-full": prod_ver_full,
48+
"ushift-ver": ushift_ver,
49+
});
50+
this.updateVariables({ playbook });
51+
});
52+
};

0 commit comments

Comments
 (0)