-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added an Antora extension that get versions from Makefile an in…
…ject the result as AsciiDoc attributes Signed-off-by: Fabrice Flore-Thébault <[email protected]>
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); | ||
}; |