#!/usr/bin/env bash
# set the actual commit date and commit hash in version.txt
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
GIT_BRANCH_SHORT=$(echo $GIT_BRANCH | cut -d "/" -f 1)
GIT_COMMIT_DATE=$(git log -1 --format=%cd --date=format:%Y%m%d%H%M)
GIT_COMMIT_ID_SHORT=$(git rev-parse --short HEAD)

VERSION=$GIT_COMMIT_DATE.$GIT_COMMIT_ID_SHORT

CURRENT_DIR=$(dirname "$0")
VERSION_FILE="${CURRENT_DIR}/version.txt"

echo "Saving version ${VERSION} to file ${VERSION_FILE}"

echo $VERSION
echo $VERSION > $VERSION_FILE

