Skip to content

Commit

Permalink
docs: added an Antora extension that get versions from Makefile an in…
Browse files Browse the repository at this point in the history
…ject the result as AsciiDoc attributes

Signed-off-by: Fabrice Flore-Thébault <[email protected]>
  • Loading branch information
themr0c authored and praveenkumar committed Sep 26, 2023
1 parent f69c337 commit 18cdd4a
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions antora-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ urls:
antora:
extensions:
- "@antora/lunr-extension"
- ./docs/extensions/get-versions.js
asciidoc:
sourcemap: true
attributes:
Expand Down
52 changes: 52 additions & 0 deletions docs/extensions/get-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";
const fs = require("fs");
const child_process = require("child_process");
module.exports.register = function () {
this.on("playbookBuilt", function ({ playbook }) {
// Get versions from Makefile
// Use utf8 encoding to have a string rather than a buffer in the output
const ocp_ver_full = child_process.execSync(
"grep '^OPENSHIFT_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
{ encoding: "utf8" }
);
const ocp_ver = child_process.execSync(
"grep '^OPENSHIFT_VERSION' Makefile | cut -d' ' -f3 | cut -d'.' -f-2 | tr -d '\n'",
{ encoding: "utf8" }
);
const podman_ver = child_process.execSync(
"grep '^PODMAN_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
{ encoding: "utf8" }
);
const prod_ver_full = child_process.execSync(
"grep '^CRC_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
{ encoding: "utf8" }
);
const prod_ver = child_process.execSync(
"grep '^CRC_VERSION' Makefile | cut -d' ' -f3 | cut -d'.' -f-2 | tr -d '\n'",
{ encoding: "utf8" }
);
const ushift_ver = child_process.execSync(
"grep '^MICROSHIFT_VERSION' Makefile | cut -d' ' -f3 | tr -d '\n'",
{ encoding: "utf8" }
);

// Display versions
console.log("OpenShift patch version: " + ocp_ver_full);
console.log("OpenShift minor version: " + ocp_ver);
console.log("Podman version: " + podman_ver);
console.log("CRC patch version: " + prod_ver_full);
console.log("CRC minor version: " + prod_ver);
console.log("MicroShift version: " + ushift_ver);

// Set attributes values
Object.assign(playbook.asciidoc.attributes, {
"ocp-ver": ocp_ver,
"ocp-ver-full": ocp_ver_full,
"podman-ver": podman_ver,
"prod-ver": prod_ver,
"prod-ver-full": prod_ver_full,
"ushift-ver": ushift_ver,
});
this.updateVariables({ playbook });
});
};

0 comments on commit 18cdd4a

Please sign in to comment.