Add version info into the apps (#330)

Both worker and coordinator display version number in the console during startup. Coordinator displays its version number in the top right corner of the index.html page.
This commit is contained in:
sergystepanov 2021-07-16 18:13:20 +03:00 committed by GitHub
parent cbabe69f30
commit 30d104ee98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 59 additions and 5 deletions

30
scripts/version.sh vendored Executable file
View file

@ -0,0 +1,30 @@
#!/bin/sh
file="$1"
version="$2"
from="(<span id=\"v\">).*?(<\/span>)"
# Prints app version derived from git in the following format:
#
# v2-1-gcafeb
# ^ ^ ^ ^
# | | | |
# | | | '- commit hash of HEAD (1st 5 symbols)
# | | '-- "g" stands for git
# | '---- n commits since the last tag
# '------- last tag
#
# See: https://git-scm.com/docs/git-describe
#
# The first input param replaces the version placeholder in the provided file.
# The second input param forces the use of some version value instead of a git-derived one.
#
if [ "$version" = "" ]; then
version=$(git describe --abbrev=5 --always --tags 2> /dev/null)
fi
if [ "$file" != "" ]; then
sed -i -E "s/$from/\1$version\2/" "$file"
echo "$file $version"
else
echo "$version"
fi