aboutsummaryrefslogtreecommitdiff
path: root/generate-version.sh
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-01 15:32:48 +0200
committerDaniel Eklöf <daniel@ekloef.se>2020-08-01 15:32:48 +0200
commitb947448795d604f169246b0c3191028ae6a0ab83 (patch)
tree6d99443c8f46d6e2730344efcca6b9d972fdce00 /generate-version.sh
downloadwbg-b947448795d604f169246b0c3191028ae6a0ab83.tar.gz
Initial commit
Can display a single PNG image scaled-to-fit on all outputs.
Diffstat (limited to 'generate-version.sh')
-rwxr-xr-xgenerate-version.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/generate-version.sh b/generate-version.sh
new file mode 100755
index 0000000..c77560a
--- /dev/null
+++ b/generate-version.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+set -e
+
+default_version=${1}
+src_dir=${2}
+out_file=${3}
+
+# echo "default version: ${default_version}"
+# echo "source directory: ${src_dir}"
+# echo "output file: ${out_file}"
+
+if [ -d "${src_dir}/.git" ] && command -v git > /dev/null; then
+ workdir=$(pwd)
+ cd "${src_dir}"
+ git_version=$(git describe --always --tags)
+ git_branch=$(git rev-parse --abbrev-ref HEAD)
+ cd "${workdir}"
+
+ new_version="${git_version} ($(env LC_TIME=C date "+%b %d %Y"), branch '${git_branch}')"
+else
+ new_version="${default_version}"
+fi
+
+new_version="#define FUZZEL_VERSION \"${new_version}\""
+
+if [ -f "${out_file}" ]; then
+ old_version=$(cat "${out_file}")
+else
+ old_version=""
+fi
+
+# echo "old version: ${old_version}"
+# echo "new version: ${new_version}"
+
+if [ "${old_version}" != "${new_version}" ]; then
+ echo "${new_version}" > "${out_file}"
+fi