diff --git a/Makefile b/Makefile index 2645bae3b..76ecbf4f6 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,8 @@ ifdef PACKAGE_DIR PKG_ARGS += --destination $(PACKAGE_DIR) endif +BASE_VERSION ?= 2024.2.0 + CHART_DIRS := $(subst /,,$(dir $(wildcard */Chart.yaml))) CHARTS := $(sort helm-toolkit $(CHART_DIRS)) @@ -44,7 +46,9 @@ lint-%: init-% if [ -d $* ]; then $(HELM) lint $*; fi build-%: lint-% - if [ -d $* ]; then $(HELM) package $* $(PKG_ARGS); fi + if [ -d $* ]; then \ + $(HELM) package $* --version $$(tools/chart_version.sh $* $(BASE_VERSION)) $(PKG_ARGS); \ + fi clean: @echo "Removed .b64, _partials.tpl, and _globals.tpl files" diff --git a/playbooks/build-chart.yaml b/playbooks/build-chart.yaml index cd283ac6a..929703f73 100644 --- a/playbooks/build-chart.yaml +++ b/playbooks/build-chart.yaml @@ -14,7 +14,7 @@ - hosts: all roles: - name: ensure-helm - helm_version: "3.6.3" + helm_version: "3.16.4" tasks: - name: make all diff --git a/tools/chart_version.sh b/tools/chart_version.sh new file mode 100755 index 000000000..e10bad932 --- /dev/null +++ b/tools/chart_version.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [[ $# -lt 2 ]]; then + echo "Usage: $0 " + echo " - The chart directory." + echo " - The base version. For example 2024.2.0." + echo " Will be modified to 2024.2.+" + exit 1 +fi + +CHART_DIR=$1 +BASE_VERSION=$2 +MAJOR=$(echo $BASE_VERSION | cut -d. -f1); +MINOR=$(echo $BASE_VERSION | cut -d. -f2); + +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) +else + # if there is no tag $BASE_VERSION, then we count the number of commits since the beginning + PATCH=$(git log --oneline $CHART_DIR | wc -l) +fi +OSH_INFRA_COMMIT_SHA=$(git rev-parse --short HEAD); + +echo "${MAJOR}.${MINOR}.${PATCH}+${OSH_INFRA_COMMIT_SHA}"