2015-12-19 10:07:20 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
|
2026-08-12 00:33:14 +02:00
|
|
|
SRCDIR="${srcdir:-$(dirname "$0")}"
|
|
|
|
|
|
|
|
|
|
if [ -f "$SRCDIR/.version" ]; then
|
2015-12-19 10:07:20 +01:00
|
|
|
# Get version from the .version file
|
2026-08-12 00:33:14 +02:00
|
|
|
VERSION=$(cat "$SRCDIR/.version")
|
2025-05-15 21:51:10 +02:00
|
|
|
fi
|
|
|
|
|
|
2026-08-12 00:33:14 +02:00
|
|
|
if [ -z "$VERSION" ] && [ -e "$SRCDIR/.git" ]; then
|
2026-02-24 11:34:31 +01:00
|
|
|
# Get version from git tags, removing the 'v' prefix
|
2026-08-12 00:33:14 +02:00
|
|
|
VERSION=$(git -C "$SRCDIR" describe --match 'v*' 2>/dev/null | sed 's/^v//')
|
2026-02-24 11:34:31 +01:00
|
|
|
fi
|
|
|
|
|
|
2026-08-12 00:33:14 +02:00
|
|
|
if [ -z "$VERSION" ] && [ -e "$SRCDIR/.git" ]; then
|
2025-05-15 21:51:10 +02:00
|
|
|
# Fall back to short commit hash
|
2026-08-12 00:33:14 +02:00
|
|
|
VERSION=0-$(git -C "$SRCDIR" 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"
|