Skip to content

Commit

Permalink
Merge pull request #97 from remyroy/version-from-git
Browse files Browse the repository at this point in the history
Add version numbers from git tag and commit
  • Loading branch information
colfax23 authored Nov 4, 2021
2 parents a4b3376 + 0fe9fe8 commit 3fe5456
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@rauschma/stringio": "^1.4.0",
"@types/git-revision-webpack-plugin": "^3.0.3",
"css-loader": "^5.2.6",
"file-loader": "^6.2.0",
"git-revision-webpack-plugin": "^5.0.0",
"html-webpack-plugin": "^5.3.2",
"js-yaml": "^4.1.0",
"react": "^17.0.2",
Expand Down
5 changes: 4 additions & 1 deletion src/electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import path from "path";

import { accessSync, constants } from "fs";

declare var VERSION: string;
declare var COMMITHASH: string;

const doesFileExist = (filename: string): boolean => {
try {
accessSync(filename, constants.F_OK);
Expand All @@ -20,7 +23,7 @@ app.on("ready", () => {
iconPath = bundledIconPath;
}

const title = `${app.getName()}`;
const title = `${app.getName()} ${VERSION}-${COMMITHASH}`;

const window = new BrowserWindow({
width: 950,
Expand Down
16 changes: 16 additions & 0 deletions webpack.electron.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
'use strict';

const path = require('path');
const webpack = require('webpack');

const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin({
branch: true,
commithashCommand: 'rev-list --max-count=1 --no-merges --abbrev-commit HEAD',
});

module.exports = {
mode: 'development',
Expand All @@ -14,6 +21,15 @@ module.exports = {
{ test: /\.tsx?$/, loader: 'ts-loader' }
]
},
plugins: [
gitRevisionPlugin,
new webpack.DefinePlugin({
VERSION: JSON.stringify(gitRevisionPlugin.version()),
COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
BRANCH: JSON.stringify(gitRevisionPlugin.branch()),
LASTCOMMITDATETIME: JSON.stringify(gitRevisionPlugin.lastcommitdatetime()),
})
],
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
Expand Down
67 changes: 65 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,13 @@
dependencies:
"@types/node" "*"

"@types/git-revision-webpack-plugin@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/git-revision-webpack-plugin/-/git-revision-webpack-plugin-3.0.3.tgz#a14ddbed9a229203cffad01540f8219004ad4e85"
integrity sha512-GDEHBBSTbNUWpLimFfGD7yKWChI56Otcn6XXG++6bnZMh2N2RNHu55/aSGwPxTE2ZEDhY6G45pH7OpX7axVnEQ==
dependencies:
"@types/webpack" "^4"

"@types/glob@^7.1.1":
version "7.1.4"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.4.tgz#ea59e21d2ee5c517914cb4bc8e4153b99e566672"
Expand Down Expand Up @@ -582,6 +589,11 @@
resolved "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz"
integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==

"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"
integrity sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==

"@types/styled-components@^5.1.11":
version "5.1.12"
resolved "https://registry.npmjs.org/@types/styled-components/-/styled-components-5.1.12.tgz"
Expand All @@ -591,16 +603,49 @@
"@types/react" "*"
csstype "^3.0.2"

"@types/tapable@^1":
version "1.0.8"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.8.tgz#b94a4391c85666c7b73299fd3ad79d4faa435310"
integrity sha512-ipixuVrh2OdNmauvtT51o3d8z12p6LtFW9in7U79der/kwejjdNchQC5UMn5u/KxNoM7VHHOs/l8KS8uHxhODQ==

"@types/tmp@^0.2.2":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.2.2.tgz#424537a3b91828cb26aaf697f21ae3cd1b69f7e7"
integrity sha512-MhSa0yylXtVMsyT8qFpHA1DLHj4DvQGH5ntxrhHSh8PxUVNi35Wk+P5hVgqbO2qZqOotqr9jaoPRL+iRjWYm/A==

"@types/uglify-js@*":
version "3.13.1"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.13.1.tgz#5e889e9e81e94245c75b6450600e1c5ea2878aea"
integrity sha512-O3MmRAk6ZuAKa9CHgg0Pr0+lUOqoMLpc9AS4R8ano2auvsg7IE8syF3Xh/NPr26TWklxYcqoEEFdzLLs1fV9PQ==
dependencies:
source-map "^0.6.1"

"@types/verror@^1.10.3":
version "1.10.5"
resolved "https://registry.yarnpkg.com/@types/verror/-/verror-1.10.5.tgz#2a1413aded46e67a1fe2386800e291123ed75eb1"
integrity sha512-9UjMCHK5GPgQRoNbqdLIAvAy0EInuiqbW0PBMtVP6B5B2HQJlvoJHM+KodPZMEjOa5VkSc+5LH7xy+cUzQdmHw==

"@types/webpack-sources@*":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@types/webpack-sources/-/webpack-sources-3.2.0.tgz#16d759ba096c289034b26553d2df1bf45248d38b"
integrity sha512-Ft7YH3lEVRQ6ls8k4Ff1oB4jN6oy/XmU6tQISKdhfh+1mR+viZFphS6WL0IrtDOzvefmJg5a0s7ZQoRXwqTEFg==
dependencies:
"@types/node" "*"
"@types/source-list-map" "*"
source-map "^0.7.3"

"@types/webpack@^4":
version "4.41.31"
resolved "https://registry.yarnpkg.com/@types/webpack/-/webpack-4.41.31.tgz#c35f252a3559ddf9c85c0d8b0b42019025e581aa"
integrity sha512-/i0J7sepXFIp1ZT7FjUGi1eXMCg8HCCzLJEQkKsOtbJFontsJLolBcDC+3qxn5pPwiCt1G0ZdRmYRzNBtvpuGQ==
dependencies:
"@types/node" "*"
"@types/tapable" "^1"
"@types/uglify-js" "*"
"@types/webpack-sources" "*"
anymatch "^3.0.0"
source-map "^0.6.0"

"@types/yargs-parser@*":
version "20.2.1"
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-20.2.1.tgz#3b9ce2489919d9e4fea439b76916abc34b2df129"
Expand Down Expand Up @@ -840,6 +885,14 @@ any-promise@^1.1.0:
resolved "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz"
integrity sha1-q8av7tzqUugJzcA3au0845Y10X8=

anymatch@^3.0.0:
version "3.1.2"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"
integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==
dependencies:
normalize-path "^3.0.0"
picomatch "^2.0.4"

app-builder-bin@3.5.13:
version "3.5.13"
resolved "https://registry.yarnpkg.com/app-builder-bin/-/app-builder-bin-3.5.13.tgz#6dd7f4de34a4e408806f99b8c7d6ef1601305b7e"
Expand Down Expand Up @@ -2058,6 +2111,11 @@ get-stream@^6.0.0:
resolved "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz"
integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==

git-revision-webpack-plugin@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/git-revision-webpack-plugin/-/git-revision-webpack-plugin-5.0.0.tgz#0683a6a110ece618499880431cd89e1eb597b536"
integrity sha512-RptQN/4UKcEPkCBmRy8kLPo5i8MnF8+XfAgFYN9gbwmKLTLx4YHsQw726H+C5+sIGDixDkmGL3IxPA2gKo+u4w==

glob-parent@^5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz"
Expand Down Expand Up @@ -3083,6 +3141,11 @@ node-releases@^1.1.73:
resolved "https://registry.npmjs.org/node-releases/-/node-releases-1.1.73.tgz"
integrity sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==

normalize-path@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==

normalize-url@^4.1.0:
version "4.5.1"
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz"
Expand Down Expand Up @@ -3283,7 +3346,7 @@ pend@~1.2.0:
resolved "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz"
integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA=

picomatch@^2.2.3:
picomatch@^2.0.4, picomatch@^2.2.3:
version "2.3.0"
resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz"
integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==
Expand Down Expand Up @@ -3843,7 +3906,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1:
resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==

source-map@~0.7.2:
source-map@^0.7.3, source-map@~0.7.2:
version "0.7.3"
resolved "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz"
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
Expand Down

0 comments on commit 3fe5456

Please # to comment.