openstack-helm/tools/chart_version.sh
Vladimir Kozhukalov 49c1174433 Update versions of all charts to 2025.1.0
Also update chart_version.sh script which
counts the number of commits since the BASE_VERSION
if BASE_VERSION tag is found. If the tag
doesn't exist it counts the number of commits since the
beginning. So when we use for example 2025.1.0 as
the BASE_VERSION but the tag 2025.1.0 is not yet created
the version of the e.g. nova chart will be calculated as
like 2025.1.563+<sha> and then when we create tag the nova version
will be 2025.1.0+<sha> which is undesired.

Lets use BASE_VERSION-<sha> if the tag is not found.

Change-Id: I032e8269ab17b490898d190adaec5c282e96fa88
2025-04-16 12:32:26 -05:00

30 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
if [[ $# -lt 2 ]]; then
echo "Usage: $0 <chart_dir> <base_version>"
echo " <chart_dir> - The chart directory."
echo " <base_version> - The base version must be <major>.<minor>.<patch>"
echo " For example 2024.2.0"
echo " Will be modified to 2024.2.<patch>+<commit_sha>"
echo " where <patch> is the number of commits since the tag"
echo " equal to <base_version>. If no such tag exists,"
echo " <patch> will be taken from <base_version>."
exit 1
fi
CHART_DIR=$1
BASE_VERSION=$2
MAJOR=$(echo "$BASE_VERSION" | cut -d. -f1)
MINOR=$(echo "$BASE_VERSION" | cut -d. -f2)
PATCH=$(echo "$BASE_VERSION" | cut -d. -f3)
if git show-ref --tags "$BASE_VERSION" --quiet; then
# if there is tag $BASE_VERSION, then we count the number of commits since the tag
PATCH=$(git log --oneline "${BASE_VERSION}.." "$CHART_DIR" | wc -l | xargs)
fi
COMMIT_SHA=$(git rev-parse --short HEAD)
echo "${MAJOR}.${MINOR}.${PATCH}+${COMMIT_SHA}"