chart version auto-increment scheme

Refer to the example for auto-increment presented by Bob Church:
https://review.opendev.org/c/starlingx/platform-armada-app/+/904464

Implement these specifics for vault-helm:

 - Use StarlingX debian git revcount packaging mechanisms to derive the
   semver BUILD version for upstream helm charts which maintains the
   upstream chart version and adds a versioned BUILD extension.

     <valid semver> ::= <version core> "+" <build>

   Chart version (MAJOR.MINOR.PATCH+STX.REV) is passed to 'helm package'
   command to force the version, where REV == 'git revcount'

 - Update the rules to automatically update the chart versions in the
   fluxCD helmrelease.yaml files.

Test Plan:
PASS  file byte level comparison of package before/after
PASS  AIO-SX vault sanity
PASS  application-update

Story: 2010929
Task: 49399

Change-Id: Id40547c1001ab8fa2d7c83abbcc5c9d44185ee2f
Signed-off-by: Michel Thebeau <Michel.Thebeau@windriver.com>
This commit is contained in:
Michel Thebeau 2024-01-04 20:54:46 +00:00
parent fae21895d7
commit d921df347e
5 changed files with 28 additions and 19 deletions

View File

@ -10,7 +10,7 @@ export REVISION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export APP_NAME = vault
export APP_VERSION = $(RELEASE)-$(REVISION)
export APP_TARBALL_FLUXCD = $(APP_NAME)-$(APP_VERSION).tgz
export APP_TARBALL = $(APP_NAME)-$(APP_VERSION).tgz
export HELM_REPO = stx-platform
export STAGING = staging
@ -30,9 +30,22 @@ override_dh_auto_build:
# Setup the staging directory.
mkdir -p $(STAGING)
cp files/metadata.yaml $(STAGING)
cp -Rv fluxcd-manifests $(STAGING)/
mkdir -p $(STAGING)/charts
cp /usr/lib/helm/vault*.tgz $(STAGING)/charts
# Adjust the helmrelease yamls based on the chart versions
for c in $(STAGING)/charts/*; do \
chart=$$(basename $$c .tgz); \
chart_name=$${chart%-*}; \
chart_version=$${chart##*-}; \
echo "Found $$chart; name: $$chart_name, version: $$chart_version"; \
chart_manifest=$$(find $(STAGING)/fluxcd-manifests -name helmrelease.yaml -exec grep -q $$chart_name {} \; -print); \
echo "Updating manifest: $$chart_manifest"; \
sed -i "s/REPLACE_HELM_CHART_VERSION/$$chart_version/g" $$chart_manifest; \
grep version $$chart_manifest; \
done
# Populate metadata.
sed -i 's/APP_REPLACE_NAME/$(APP_NAME)/g' $(STAGING)/metadata.yaml
sed -i 's/APP_REPLACE_VERSION/$(APP_VERSION)/g' $(STAGING)/metadata.yaml
@ -42,13 +55,10 @@ override_dh_auto_build:
mkdir -p $(STAGING)/plugins
cp /plugins/*.whl $(STAGING)/plugins
# Prepare staging for fluxcd package
cp -R fluxcd-manifests $(STAGING)/
# calculate checksum of all files in staging for the fluxcd app
# calculate checksum of all files in staging for the app
cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
# package fluxcd app
tar -zcf $(APP_TARBALL_FLUXCD) -C $(STAGING)/ .
# package the app
tar -zcf $(APP_TARBALL) -C $(STAGING)/ .
# Cleanup staging
rm -rf $(STAGING)
@ -56,6 +66,6 @@ override_dh_auto_build:
override_dh_auto_install:
# Install the app tar file.
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL_FLUXCD) $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER)
override_dh_usrlocal:

View File

@ -15,7 +15,7 @@ spec:
chart:
spec:
chart: vault
version: 0.25.0
version: REPLACE_HELM_CHART_VERSION
sourceRef:
kind: HelmRepository
name: stx-platform

View File

@ -3,9 +3,8 @@ Section: libs
Priority: optional
Maintainer: StarlingX Developers <starlingx-discuss@lists.starlingx.io>
Build-Depends: debhelper-compat (= 13),
chartmuseum,
helm,
procps
build-info,
Standards-Version: 4.5.1
Homepage: https://www.starlingx.io

View File

@ -1,12 +1,14 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export PATCH_VERSION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export CHART_BASE_VERSION = "0.25.0"
export CHART_VERSION = $(CHART_BASE_VERSION)+STX.$(PATCH_VERSION)
export ROOT = debian/tmp
export APP_FOLDER = $(ROOT)/usr/lib/helm
export APP_TARBALL = vault-0.25.0.tgz
export STAGING = staging
%:
dh $@
@ -18,11 +20,11 @@ override_dh_auto_build:
cat _helpers-CA.tpl >> templates/_helpers.tpl
mv templates vault/templates
# Create the TGZ file.
make vault
make CHART_VERSION=$(CHART_VERSION) vault
override_dh_auto_install:
# Install the app tar file.
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER)
install -p -D -m 755 vault*.tgz $(APP_FOLDER)
override_dh_auto_test:

View File

@ -25,18 +25,16 @@ $(CHARTS):
init-%:
if [ -f $*/Makefile ]; then make -C $*; fi
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
lint-%: init-%
if [ -d $* ]; then helm lint $*; fi
build-%:
if [ -d $* ]; then helm package $*; fi
if [ -d $* ]; then helm package --version $(CHART_VERSION) $*; fi
clean:
@echo "Clean all build artifacts"
rm -f */templates/_partials.tpl */templates/_globals.tpl
rm -f *tgz */charts/*tgz */requirements.lock
rm -rf */charts */tmpcharts
%: