Skip to content

Commit

Permalink
Fetch docs version from changelog rather than tag
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed Aug 5, 2022
1 parent 14c4f7e commit 27ff617
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions .backstage/get_version.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require("fs");
const path = require("path");

const changelogFile = path.join(__dirname, "../CHANGELOG.md");

const err = (m) => {
console.error(m);
process.exit(1);
}

if (!fs.existsSync(changelogFile)) err(`Script expected a file at ${changelogFile}`);

let contents = fs.readFileSync(changelogFile, { encoding: "utf-8" });
let version = "", lines = contents.split(/\n/g);
let it = lines.entries();

while (!(entry = it.next()).done) {
let [, line] = entry.value;
// Read until we reach the section for the latest version.
if (/^\s*##\s+v/i.test(line)) {
version = line.match(/^\s*##\s+(v\S+)/)[1];
if (version) {
console.log(version);
process.exit(0);
}
}
}

err("No version found in changelog");
2 changes: 1 addition & 1 deletion .cloudcannon/prebuild
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export HUGO_PAGEFIND_DOCS_VERSION=$(git describe --tags --abbrev=0)
export HUGO_PAGEFIND_DOCS_VERSION=$(node ./.backstage/get_version.cjs)
echo "Building documentation for $HUGO_PAGEFIND_DOCS_VERSION"

0 comments on commit 27ff617

Please sign in to comment.