2015-12-19 10:07:20 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
|
2016-01-05 10:56:34 +01:00
|
|
|
if [ -f .version ]; then
|
2015-12-19 10:07:20 +01:00
|
|
|
# Get version from the .version file
|
2025-05-15 21:51:10 +02:00
|
|
|
VERSION=$(cat .version)
|
|
|
|
|
fi
|
|
|
|
|
|
2026-02-24 11:34:31 +01:00
|
|
|
if [ -z "$VERSION" ] && [ -d .git ]; then
|
|
|
|
|
# Get version from git tags, removing the 'v' prefix
|
|
|
|
|
VERSION=$(git describe --match 'v*' 2>/dev/null | sed 's/^v//')
|
|
|
|
|
fi
|
|
|
|
|
|
2025-05-15 21:51:10 +02:00
|
|
|
if [ -z "$VERSION" ] && [ -d .git ]; then
|
|
|
|
|
# Fall back to short commit hash
|
|
|
|
|
VERSION=0-$(git rev-parse --short HEAD 2>/dev/null)
|
2016-01-05 10:56:34 +01:00
|
|
|
fi
|
|
|
|
|
|
2026-02-24 11:34:31 +01:00
|
|
|
if [ -z "$VERSION" ]; then
|
2025-05-15 21:51:10 +02:00
|
|
|
# No version, but still use a number
|
|
|
|
|
VERSION="0"
|
2015-12-19 10:07:20 +01:00
|
|
|
fi
|
|
|
|
|
|
2026-02-24 11:34:31 +01:00
|
|
|
# Apply common rules to all outputs:
|
2026-03-11 00:24:39 +01:00
|
|
|
# - Remove "-" at the end
|
|
|
|
|
# - Replace "rc-" with "rc"
|
|
|
|
|
# - Replace "beta-" with "beta"
|
|
|
|
|
# - Replace all remaining dashes with "."
|
|
|
|
|
VERSION=$(echo "$VERSION" | sed 's/-$//; s/rc-/rc/g; s/beta-/beta/g; s/-/./g')
|
2026-02-24 11:34:31 +01:00
|
|
|
|
2015-12-19 10:07:20 +01:00
|
|
|
printf '%s' "$VERSION"
|