diff --git a/package.json b/package.json index 898b26fd..38c567e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chadscript", - "version": "0.2.0-beta", + "version": "0.3.0-beta", "description": "A JavaScript to native code compiler using LLVM", "type": "module", "main": "dist/chad-node.js", diff --git a/scripts/gen-version.js b/scripts/gen-version.js index 08569722..19403ab7 100644 --- a/scripts/gen-version.js +++ b/scripts/gen-version.js @@ -1,3 +1,18 @@ import { readFileSync, writeFileSync } from "fs"; +import { execSync } from "child_process"; + const pkg = JSON.parse(readFileSync("package.json", "utf8")); -writeFileSync("src/version.ts", `export const VERSION = "${pkg.version}";\n`); + +let gitCommit = "unknown"; +try { + gitCommit = execSync("git rev-parse --short HEAD", { stdio: ["ignore", "pipe", "ignore"] }) + .toString() + .trim(); +} catch { + // not a git checkout (e.g., building from a release tarball) +} + +const buildDate = new Date().toISOString().slice(0, 10); +const fullVersion = `${pkg.version}-${gitCommit}-${buildDate}`; + +writeFileSync("src/version.ts", `export const VERSION = "${fullVersion}";\n`);