bunker/scripts/version_generator.sh
Stanislav N. aka pztrn e3b9c9ae40
Some checks failed
Linting and tests / Linting (push) Failing after 5s
Linting and tests / Tests (push) Failing after 4s
The very basic client app, not adapted for mobiles.
2025-09-10 19:34:49 +05:00

34 lines
843 B
Bash
Executable File

#!/usr/bin/env bash
# Generates version based on git tag.
LATEST_TAG=$(git tag | tail -n 1)
# Check latest tag commit. If it is equal to current - use that tag as version.
if [ "${LATEST_TAG}" != "" ]; then
LATEST_TAG_COMMIT=$(git rev-list -n 1 $LATEST_TAG)
LATEST_COMMIT=$(git rev-list -n 1 HEAD)
if [ "${LATEST_TAG_COMMIT}" == "${LATEST_COMMIT}" ]; then
echo "${LATEST_TAG}"
exit 0
fi
else
# No tags in repo. Assuming latest tag is "v0.0.0".
LATEST_TAG="0.0.0"
fi
# If we're here, then latest tag commit is not latest commit on current branch.
# We should increase second number and add "-dev" postfix.
IFS=. read MAJOR MINOR PATCH <<<"${LATEST_TAG}"
MINOR=$(($MINOR + 1))
case $1 in
client)
echo "${MAJOR}.${MINOR}.${PATCH}"
;;
*)
echo "v${MAJOR}.${MINOR}.${PATCH}-dev"
;;
esac