Build source with docker technology
[anna.git] / tools / version
diff --git a/tools/version b/tools/version
new file mode 100755 (executable)
index 0000000..33bbb4c
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+#############
+# VARIABLES #
+#############
+
+REPO_DIR="$(git rev-parse --show-toplevel 2>/dev/null)"
+[ -z "$REPO_DIR" ] && { echo "You must execute under a valid git repository !" ; exit 1 ; }
+
+#############
+# EXECUTION #
+#############
+
+# Get version from CMakeLists.txt:
+major=$(grep -w "VERSION_MAJOR" ${REPO_DIR}/CMakeLists.txt | egrep -o '[0-9]+')
+minor=$(grep -w "VERSION_MINOR" ${REPO_DIR}/CMakeLists.txt | egrep -o '[0-9]+')
+patch=$(grep -w "VERSION_PATCH" ${REPO_DIR}/CMakeLists.txt | egrep -o '[0-9]+')
+
+echo ${major}.${minor}.${patch}
+
+