Add version commit hash (#3286)

* Add version commit hash

* Add frontend client hash

* Remove export
This commit is contained in:
Bruce Berrios 2022-07-02 12:49:13 -04:00 committed by GitHub
parent 162beea1b8
commit 616e26b5c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -3,6 +3,7 @@ import { padNumbers } from "./utils/misc";
import { readFileSync, writeFileSync, existsSync } from "fs";
const SERVER_VERSION_FILE_PATH = join(__dirname, "./server.version");
const { COMMIT_HASH = "NO_HASH" } = process.env;
function getDateVersion(): string {
const date = new Date();
@ -28,7 +29,7 @@ function getVersion(): string {
return readFileSync(SERVER_VERSION_FILE_PATH, "utf-8");
}
const serverVersion = getDateVersion();
const serverVersion = `${getDateVersion()}.${COMMIT_HASH}`;
writeFileSync(SERVER_VERSION_FILE_PATH, serverVersion);
return serverVersion;

View file

@ -8,7 +8,7 @@
"audit": "npx webpack --config ./webpack/config.audit.js",
"dep-graph": "madge -c -i \"dep-graph.png\" ./src/ts",
"build": "npx gulp build",
"build-live": "npx gulp build-production",
"build-live": "export COMMIT_HASH=`git rev-parse --short HEAD` && npx gulp build-production",
"dev": "concurrently \"webpack serve --config=./webpack/config.dev.js\" \"npx gulp watch\"",
"deploy-live": "npm run build-live && firebase deploy -P live --only hosting",
"tsc": "tsc"

View file

@ -13,6 +13,8 @@ function pad(numbers, maxLength, fillString) {
);
}
const { COMMIT_HASH = "NO_HASH" } = process.env;
/** @type { import('webpack').Configuration } */
const PRODUCTION_CONFIG = {
mode: "production",
@ -38,7 +40,7 @@ const PRODUCTION_CONFIG = {
).join(".");
const version = [versionPrefix, versionSuffix].join("_");
return `export const CLIENT_VERSION = "${version}";`;
return `export const CLIENT_VERSION = "${version}.${COMMIT_HASH}";`;
},
flags: "g",
},