prplos/scripts/prplos_version.sh
Petr Štetiar 14f4f27342
version.mk: introduce prplOS Git based versioning
Henceforth, we will utilize the prplOS version throughout the
development cycle, determined by the output of the `git describe`
command. The version will be composed of:

 - The fixed version number of the upcoming release currently in
   development.

 - The abbreviated (8 characters) object hash of the most recent commit.

For instance, with the ongoing development of prplOS version 3.0.0 and
having the Git hash `5a2a69d`, the resulting version would be
`3.0.0-5a2a69d`.

References: PCF-691
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2025-07-31 10:34:07 +00:00

25 lines
560 B
Bash
Executable File

#!/usr/bin/env bash
export LANG=C
export LC_ALL=C
PRPLOS_DEVELOPMENT_VERSION="${PRPLOS_DEVELOPMENT_VERSION:-3.0.0}"
tagged_version() {
local tag
tag=$(git describe --exact-match --tags HEAD 2>/dev/null | sed 's/^prplos-v//')
[ -n "$tag" ] && echo "$tag" && exit
}
development_version() {
local git_hash
git_hash=$(git log --pretty=format:%h -n 1 --abbrev=8 2>/dev/null)
[ -z "$git_hash" ] && git_hash="unknown"
echo "${PRPLOS_DEVELOPMENT_VERSION}-${git_hash}"
}
[ -n "$TOPDIR" ] && cd "$TOPDIR" || exit
tagged_version
development_version