54 lines
1.6 KiB
Bash
Executable File
54 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Construct base version: '1.2.3-123+20230527T195630.811d543'
|
|
# Platform specific versions may add extra info: '1.2.3-123+20230527T195630.811d543.linux.x11'
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
|
|
pushd "$SCRIPT_DIR"/.. 2>&1 1>/dev/null
|
|
|
|
# Fetch all tags from remote (if something changed)
|
|
git fetch --tags
|
|
|
|
# Get current version from latest tag
|
|
VERSION_SHORT=$(git describe --tags --abbrev=0)
|
|
|
|
echo "Current Version: $VERSION_SHORT"
|
|
|
|
# Advance by one revision
|
|
# check if revision present
|
|
if [[ $VERSION_SHORT != *"-"* ]]; then
|
|
VERSION_SHORT="$VERSION_SHORT-0"
|
|
fi
|
|
# seperate base version from revision
|
|
BASE_VERSION=$(echo $VERSION_SHORT | sed -E 's~^(.*[.].*[.].*)-([0-9]+)~\1~I')
|
|
REVISION=$(echo $VERSION_SHORT | sed -E 's~^(.*[.].*[.].*)-([0-9]+)~\2~I')
|
|
# +1
|
|
REVISION=$(($REVISION+1)) || $(echo 1)
|
|
# Assemble new version
|
|
VERSION_SHORT="$BASE_VERSION-$REVISION"
|
|
|
|
read -p "Enter New Version [$VERSION_SHORT]: " VERSION_SHORT_INPUT
|
|
VERSION_SHORT=${VERSION_SHORT_INPUT:-$VERSION_SHORT}
|
|
|
|
# Collect extra build information
|
|
# CMAKE_VERSION=$(grep CMAKE_PROJECT_VERSION:STATIC build/CMakeCache.txt | cut -d "=" -f2)
|
|
TIME=$(date -u +"%Y%m%dT%H%M%S")
|
|
COMMIT=$(git rev-parse HEAD)
|
|
|
|
VERSION_LONG="$VERSION_SHORT+$TIME.$COMMIT"
|
|
|
|
# Push any outstanding commits
|
|
git commit --allow-empty -m "Release $VERSION_SHORT" -m "[CI SKIP]"
|
|
git push
|
|
|
|
# Create annotated tag named named after short version and annotated with long version
|
|
git tag -a -m "$VERSION_LONG" "$VERSION_SHORT"
|
|
|
|
# push the new tag
|
|
git push origin "$VERSION_SHORT"
|
|
|
|
popd 2>&1 1>/dev/null
|