1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-05-12 12:00:13 +00:00
QB64-PE/.ci/calculate_version.sh
Matthew Kilgore 7be379c39d Add version calculation and separate label vs. commit
This slightly changes how the versioning works.
2022-04-28 17:19:37 -04:00

31 lines
599 B
Bash
Executable file

#!/bin/bash
if ! [ -x "$(command -v git)" ]; then
echo "-nongit"
exit 1
fi
LAST_TAG=$(git describe --tags --abbrev=0 HEAD)
COMMIT_COUNT=$(git rev-list $LAST_TAG.. --count)
COMMIT_HASH=$(git rev-parse --short HEAD)
git diff --no-ext-diff --quiet --exit-code
DIRTY=$?
VERSION=
if [ "$COMMIT_COUNT" != "0" ]; then
VERSION+="-$COMMIT_COUNT-$COMMIT_HASH"
fi
if [ "$DIRTY" != "0" ]; then
VERSION+="-dirty"
fi
if [ ! -z "$VERSION" ]; then
echo "Version label: $VERSION"
echo "$VERSION" > ./internal/version.txt
else
echo "Release version!"
rm -f ./internal/version.txt
fi