From 9efb03ceb2fc950430b84044458ad7a28a8aee66 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Fri, 28 Nov 2025 18:25:40 +0100 Subject: [PATCH] feat(helm): enhance chart versioning for development and stable releases Signed-off-by: Marc Nuri --- .github/workflows/release-helm.yaml | 28 ++++++++++++++++++++++++---- build/helm.mk | 12 ++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release-helm.yaml b/.github/workflows/release-helm.yaml index cb4360df..2f2cbf92 100644 --- a/.github/workflows/release-helm.yaml +++ b/.github/workflows/release-helm.yaml @@ -33,10 +33,20 @@ jobs: with: version: '3.19.2' - - name: Extract versions + - name: Determine chart version id: versions run: | - CHART_VERSION=$(make helm-print-chart-version) + BASE_VERSION=$(make helm-print-chart-version) + + # Use development version for workflow_dispatch, stable version for tags + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + GIT_SHORT_SHA=$(git rev-parse --short HEAD) + CHART_VERSION="${BASE_VERSION}-dev.${GIT_SHORT_SHA}" + echo "::notice::Creating development release: ${CHART_VERSION}" + else + CHART_VERSION="${BASE_VERSION}" + echo "::notice::Creating stable release: ${CHART_VERSION}" + fi echo "chart_version=$CHART_VERSION" >> $GITHUB_OUTPUT echo "Chart version: $CHART_VERSION" @@ -59,15 +69,25 @@ jobs: run: | echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ steps.versions.outputs.helm_registry }} -u ${{ github.actor }} --password-stdin - - name: Package Helm chart and push chart to OCI registry + - name: Package and push Helm chart + env: + HELM_CHART_VERSION: ${{ steps.versions.outputs.chart_version }} run: make helm-push - name: Verify chart installation + env: + HELM_CHART_VERSION: ${{ steps.versions.outputs.chart_version }} run: make helm-verify - name: Generate release summary run: | - echo "## Helm Chart Release Summary" >> $GITHUB_STEP_SUMMARY + if [[ "${{ steps.versions.outputs.chart_version }}" == *"-dev."* ]]; then + RELEASE_TYPE="Development" + else + RELEASE_TYPE="Stable" + fi + + echo "## Helm Chart Release Summary ($RELEASE_TYPE)" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "- **Chart Name:** ${{ steps.versions.outputs.chart_name }}" >> $GITHUB_STEP_SUMMARY echo "- **Chart Version:** ${{ steps.versions.outputs.chart_version }}" >> $GITHUB_STEP_SUMMARY diff --git a/build/helm.mk b/build/helm.mk index 9aa746db..3f35b358 100644 --- a/build/helm.mk +++ b/build/helm.mk @@ -1,7 +1,8 @@ ##@ Helm Chart build targets HELM_CHART_DIR = ./charts/kubernetes-mcp-server -HELM_CHART_VERSION = $(shell grep '^version:' $(HELM_CHART_DIR)/Chart.yaml | awk '{print $$2}') +HELM_CHART_VERSION_BASE = $(shell grep '^version:' $(HELM_CHART_DIR)/Chart.yaml | awk '{print $$2}') +HELM_CHART_VERSION ?= $(HELM_CHART_VERSION_BASE) HELM_PACKAGE_DIR = ./_output/helm-packages HELM_REGISTRY ?= ghcr.io HELM_REGISTRY_ORG ?= containers @@ -38,14 +39,17 @@ helm-validate: kubeconform ## Validate Helm chart manifests with kubeconform helm template test-release $(HELM_CHART_DIR) --set ingress.host=localhost | $(KUBECONFORM) -strict -summary -ignore-missing-schemas .PHONY: helm-package -helm-package: helm-lint helm-template ## Package the Helm chart +helm-package: helm-lint helm-template ## Package the Helm chart (supports HELM_CHART_VERSION override) @mkdir -p $(HELM_PACKAGE_DIR) - @echo "Updating appVersion to $(GIT_TAG_VERSION)..." - @sed -i.bak "s/appVersion: .*/appVersion: \"$(GIT_TAG_VERSION)\"/" $(HELM_CHART_DIR)/Chart.yaml + @echo "Updating Chart.yaml for packaging..." + @sed -i.bak -e "s/version: .*/version: $(HELM_CHART_VERSION)/" \ + -e "s/appVersion: .*/appVersion: \"$(GIT_TAG_VERSION)\"/" \ + $(HELM_CHART_DIR)/Chart.yaml @echo "Updated Chart.yaml:" @cat $(HELM_CHART_DIR)/Chart.yaml helm package $(HELM_CHART_DIR) --destination $(HELM_PACKAGE_DIR) @mv $(HELM_CHART_DIR)/Chart.yaml.bak $(HELM_CHART_DIR)/Chart.yaml + @echo "Chart packaged as version $(HELM_CHART_VERSION)" .PHONY: helm-push helm-push: helm-package ## Push Helm chart to OCI registry (assumes helm registry login has been performed)