2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-10-20 06:35:33 +00:00
Files
confluent/mkversion
T
Markus Hilger f25d121fc5 Version the Python package rpms with ~dev as well
confluent_client and confluent_server rpms took the PEP 440 version
setup.py needs, 4.0.1.dev5+g..., which rpm sorts after 4.0.1: a
released package did not upgrade a development build of it. Stamp the
rpm with the ~dev form the other packages already use and keep .dev only
for setup.py and the sdist name. The debs already sort right, since
stdeb rewrites .dev to ~dev.
2026-10-15 19:20:16 +02:00

42 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# Print the version to stamp on packages built from this checkout.
#
# --tilde use "~dev" rather than ".dev": the package version, as "~" sorts
# before the release and ".dev" after it. Only setup.py takes ".dev",
# which PEP 440 requires.
#
# The root VERSION file names the release this branch is working toward. Release
# tags do not always live on master (3.15.2 through 3.15.6 are on branch 3.15), so
# git describe alone stamps master builds with an already-released version. The
# newest tag reachable from HEAD is kept as a floor, so forgetting to bump VERSION
# after tagging *this* branch cannot walk the version backwards; staying ahead of
# tags on other branches is what the VERSION file itself is for. See README.md for
# the branch-cutting order.
cd "$(dirname "$0")" || exit 1
sep=.
case "$1" in
--tilde) sep='~' ;;
'') ;;
*) echo "mkversion: unknown argument '$1'" >&2; exit 1 ;;
esac
next=$(tr -d '[:space:]' < VERSION 2>/dev/null)
case "$next" in
[0-9]*.[0-9]*.[0-9]*) ;;
*) echo "mkversion: VERSION must hold a release like 4.0.0, got '$next'" >&2; exit 1 ;;
esac
# plain describe: release tags are annotated, so lightweight ones (3.15.5-test) are
# already ignored. Never guess a version -- a silent fallback here would label a dev
# build as the release.
desc=$(git describe 2>/dev/null) ||
{ echo "mkversion: git describe failed, cannot version this build" >&2; exit 1; }
tag=${desc%%-*}
numcommits=$(echo "$desc" | cut -d- -f2)
if [ "$numcommits" = "$tag" ]; then # HEAD is exactly a tag: release build
echo "$tag"
exit 0
fi
bumped=$(echo "$tag" | awk -F. -v OFS=. '{$NF=$NF+1; print}')
base=$(printf '%s\n%s\n' "$bumped" "$next" | sort -V | tail -1) && [ -n "$base" ] ||
{ echo "mkversion: sort -V failed" >&2; exit 1; }
echo "${base}${sep}dev${numcommits}+$(echo "$desc" | cut -d- -f3)"