From 8b57da66a2fcaa82d2e25396952e7285f83419a1 Mon Sep 17 00:00:00 2001 From: MoritzWeber Date: Tue, 25 Jun 2024 09:20:07 +0200 Subject: [PATCH] build: Derive helm version from Git tags Currently, we tag all helm releases with 1.0.0 / 0.0.0. The versions are displayed when running `helm history`. --- Makefile | 5 ++++- ci-templates/gitlab/k8s-deploy.yml | 11 +++++++++-- helm/Chart.yaml | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ca2655ace..06c2523b9 100644 --- a/Makefile +++ b/Makefile @@ -84,6 +84,8 @@ helm-deploy: @kubectl create namespace $(SESSION_NAMESPACE) 2> /dev/null || true @[[ ! $$(helm dependency list ./helm | grep missing) ]] || helm dependency update ./helm; @echo "Start helm upgrade..." + HELM_PACKAGE_DIR=$$(mktemp -d) + helm package --app-version=$$(git rev-parse --abbrev-ref HEAD) --version=$$(git describe --tags) -d "$$HELM_PACKAGE_DIR" helm @helm upgrade --install \ --kube-context k3d-$(CLUSTER_NAME) \ --create-namespace \ @@ -98,7 +100,8 @@ helm-deploy: --set cluster.ingressClassName=traefik \ --set cluster.ingressNamespace=kube-system \ --set backend.k8sSessionNamespace="$(SESSION_NAMESPACE)" \ - $(RELEASE) ./helm + $(RELEASE) $$HELM_PACKAGE_DIR/collab-manager-*.tgz + rm -rf "$$HELM_PACKAGE_DIR" $(MAKE) provision-guacamole wait open: diff --git a/ci-templates/gitlab/k8s-deploy.yml b/ci-templates/gitlab/k8s-deploy.yml index 4df4c8c9d..78fa6683b 100644 --- a/ci-templates/gitlab/k8s-deploy.yml +++ b/ci-templates/gitlab/k8s-deploy.yml @@ -64,13 +64,20 @@ variables: # prettier-ignore - DOCKER_TAG=$(echo $REVISION | sed 's/[^a-zA-Z0-9.]/-/g')-$CI_COMMIT_REF_SLUG - helm repo add grafana-helm-remote ${GRAFANA_HELM_CHART} + - helm dependency update ./helm + - HELM_PACKAGE_DIR=$(mktemp -d) + - > + helm package \ + --app-version="$DOCKER_TAG" \ + --version="$(git describe --tags)" \ + -d "$HELM_PACKAGE_DIR" \ + helm - > helm upgrade ${RELEASE} \ - --dependency-update \ --namespace ${NAMESPACE} \ --set docker.tag=${DOCKER_TAG} \ -f ../${TARGET}/general.values.yaml \ - -f ../plain.values.yaml helm + -f ../plain.values.yaml "$HELM_PACKAGE_DIR"/collab-manager-*.tgz - kubectl rollout restart deployment ${RELEASE}-backend - kubectl rollout restart deployment ${RELEASE}-frontend - kubectl rollout restart deployment ${RELEASE}-docs diff --git a/helm/Chart.yaml b/helm/Chart.yaml index a012e3801..52ccedf2b 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -6,8 +6,8 @@ name: collab-manager description: Capella Collaboration Manager home: https://github.com/DSD-DBS/capella-collab-manager type: application -version: 0.0.0 # The version is not used. The version is managed via Git tags. -appVersion: "1.0.0" +version: 0.0.0 # The version is automatically updated by the release process. +appVersion: 0.0.0 # The appVersion is automatically updated by the release process. dependencies: - name: loki alias: loki