From 35a66c6c024d4308a99e5e98b2bfd1d7083febb4 Mon Sep 17 00:00:00 2001 From: Rupam-It Date: Fri, 20 Mar 2026 21:24:29 +0530 Subject: [PATCH] automated release for helm chart --- .../workflows/helm-auto-release-netmon.yml | 116 ++++++++++++++++++ .github/workflows/helm-auto-release.yml | 116 ++++++++++++++++++ .github/workflows/helm-chart-validation.yml | 59 +++++++++ 3 files changed, 291 insertions(+) create mode 100644 .github/workflows/helm-auto-release-netmon.yml create mode 100644 .github/workflows/helm-auto-release.yml create mode 100644 .github/workflows/helm-chart-validation.yml diff --git a/.github/workflows/helm-auto-release-netmon.yml b/.github/workflows/helm-auto-release-netmon.yml new file mode 100644 index 00000000..6b76ceb3 --- /dev/null +++ b/.github/workflows/helm-auto-release-netmon.yml @@ -0,0 +1,116 @@ +name: Auto Release Helm Chart (zxporter-netmon) + +# Triggers on any merge to main that touches helm-chart/zxporter-netmon/** +# EXCEPT Chart.yaml — that file is updated by this workflow itself via PR, +# and we exclude it to prevent an infinite release loop. +on: + push: + branches: [main] + paths: + - 'helm-chart/zxporter-netmon/**' + - '!helm-chart/zxporter-netmon/Chart.yaml' + +env: + REGISTRY: registry-1.docker.io + CHART_NAME: zxporter-netmon + ORG: devzeroinc + CHART_TAG_PREFIX: chart-netmon-v + +jobs: + auto-release: + name: Patch release zxporter-netmon chart + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: '3.12.3' + + - name: Install yq + run: | + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + + - name: Helm registry login + run: | + echo "${{ secrets.DOCKERHUB_ZXPORTER_BALANCE_TOKEN }}" | \ + helm registry login registry-1.docker.io \ + --username "${{ secrets.DOCKERHUB_ZXPORTER_BALANCE_USERNAME }}" \ + --password-stdin + + - name: Enable Helm OCI support + run: echo "HELM_EXPERIMENTAL_OCI=1" >> $GITHUB_ENV + + - name: Fetch tags + run: git fetch --tags + + - name: Bump patch version + id: version + run: | + LAST_TAG=$(git tag --list '${{ env.CHART_TAG_PREFIX }}*' --sort=-v:refname | head -n 1) + if [ -z "$LAST_TAG" ]; then + LAST_VERSION="0.0.0" + else + LAST_VERSION="${LAST_TAG#${{ env.CHART_TAG_PREFIX }}}" + fi + IFS='.' read -r MAJOR MINOR PATCH <<< "$LAST_VERSION" + PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "Auto-releasing chart patch: $LAST_VERSION → $NEW_VERSION (triggered by: ${{ github.event.head_commit.message }})" + + - name: Create and push chart tag + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + git tag "${{ env.CHART_TAG_PREFIX }}${{ steps.version.outputs.new_version }}" + git push origin "${{ env.CHART_TAG_PREFIX }}${{ steps.version.outputs.new_version }}" + + - name: Update chart dependencies + run: helm dependency update helm-chart/zxporter-netmon + + - name: Lint Helm chart + run: helm lint helm-chart/zxporter-netmon + + - name: Package Helm chart + run: | + mkdir -p helm-chart/packages + helm package helm-chart/zxporter-netmon \ + --version ${{ steps.version.outputs.new_version }} \ + --app-version ${{ steps.version.outputs.new_version }} \ + --destination helm-chart/packages + + - name: Push chart to Docker Hub OCI registry + run: | + helm push helm-chart/packages/zxporter-netmon-${{ steps.version.outputs.new_version }}.tgz \ + oci://${{ env.REGISTRY }}/${{ env.ORG }} + + - name: Update Chart.yaml version and appVersion + run: | + yq e -i '.version = "${{ steps.version.outputs.new_version }}"' helm-chart/zxporter-netmon/Chart.yaml + yq e -i '.appVersion = "${{ steps.version.outputs.new_version }}"' helm-chart/zxporter-netmon/Chart.yaml + + - name: Create PR to update Chart.yaml + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "chore(helm): update Chart.yaml version to ${{ steps.version.outputs.new_version }}" + title: "chore(helm): update zxporter-netmon Chart.yaml version to ${{ steps.version.outputs.new_version }}" + body: | + Automated patch release triggered by changes to `helm-chart/zxporter-netmon/`. + + This PR updates `version` and `appVersion` in `helm-chart/zxporter-netmon/Chart.yaml` to `${{ steps.version.outputs.new_version }}`. + + Triggered by commit: ${{ github.event.head_commit.message }} + branch: "update/chart-version-netmon-${{ steps.version.outputs.new_version }}" + add-paths: | + helm-chart/zxporter-netmon/Chart.yaml \ No newline at end of file diff --git a/.github/workflows/helm-auto-release.yml b/.github/workflows/helm-auto-release.yml new file mode 100644 index 00000000..3c980386 --- /dev/null +++ b/.github/workflows/helm-auto-release.yml @@ -0,0 +1,116 @@ +name: Auto Release Helm Chart (zxporter) + +# Triggers on any merge to main that touches helm-chart/zxporter/** +# EXCEPT Chart.yaml — that file is updated by this workflow itself via PR, +# and we exclude it to prevent an infinite release loop. +on: + push: + branches: [main] + paths: + - 'helm-chart/zxporter/**' + - '!helm-chart/zxporter/Chart.yaml' + +env: + REGISTRY: registry-1.docker.io + CHART_NAME: zxporter + ORG: devzeroinc + CHART_TAG_PREFIX: chart-v + +jobs: + auto-release: + name: Patch release zxporter chart + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: '3.12.3' + + - name: Install yq + run: | + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + + - name: Helm registry login + run: | + echo "${{ secrets.DOCKERHUB_ZXPORTER_BALANCE_TOKEN }}" | \ + helm registry login registry-1.docker.io \ + --username "${{ secrets.DOCKERHUB_ZXPORTER_BALANCE_USERNAME }}" \ + --password-stdin + + - name: Enable Helm OCI support + run: echo "HELM_EXPERIMENTAL_OCI=1" >> $GITHUB_ENV + + - name: Fetch tags + run: git fetch --tags + + - name: Bump patch version + id: version + run: | + LAST_TAG=$(git tag --list '${{ env.CHART_TAG_PREFIX }}*' --sort=-v:refname | head -n 1) + if [ -z "$LAST_TAG" ]; then + LAST_VERSION="0.0.0" + else + LAST_VERSION="${LAST_TAG#${{ env.CHART_TAG_PREFIX }}}" + fi + IFS='.' read -r MAJOR MINOR PATCH <<< "$LAST_VERSION" + PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "Auto-releasing chart patch: $LAST_VERSION → $NEW_VERSION (triggered by: ${{ github.event.head_commit.message }})" + + - name: Create and push chart tag + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" + git tag "${{ env.CHART_TAG_PREFIX }}${{ steps.version.outputs.new_version }}" + git push origin "${{ env.CHART_TAG_PREFIX }}${{ steps.version.outputs.new_version }}" + + - name: Update chart dependencies + run: helm dependency update helm-chart/zxporter + + - name: Lint Helm chart + run: helm lint helm-chart/zxporter + + - name: Package Helm chart + run: | + mkdir -p helm-chart/packages + helm package helm-chart/zxporter \ + --version ${{ steps.version.outputs.new_version }} \ + --app-version ${{ steps.version.outputs.new_version }} \ + --destination helm-chart/packages + + - name: Push chart to Docker Hub OCI registry + run: | + helm push helm-chart/packages/zxporter-${{ steps.version.outputs.new_version }}.tgz \ + oci://${{ env.REGISTRY }}/${{ env.ORG }} + + - name: Update Chart.yaml version and appVersion + run: | + yq e -i '.version = "${{ steps.version.outputs.new_version }}"' helm-chart/zxporter/Chart.yaml + yq e -i '.appVersion = "${{ steps.version.outputs.new_version }}"' helm-chart/zxporter/Chart.yaml + + - name: Create PR to update Chart.yaml + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "chore(helm): update Chart.yaml version to ${{ steps.version.outputs.new_version }}" + title: "chore(helm): update Chart.yaml version to ${{ steps.version.outputs.new_version }}" + body: | + Automated patch release triggered by changes to `helm-chart/zxporter/`. + + This PR updates `version` and `appVersion` in `helm-chart/zxporter/Chart.yaml` to `${{ steps.version.outputs.new_version }}`. + + Triggered by commit: ${{ github.event.head_commit.message }} + branch: "update/chart-version-${{ steps.version.outputs.new_version }}" + add-paths: | + helm-chart/zxporter/Chart.yaml \ No newline at end of file diff --git a/.github/workflows/helm-chart-validation.yml b/.github/workflows/helm-chart-validation.yml new file mode 100644 index 00000000..1746cc07 --- /dev/null +++ b/.github/workflows/helm-chart-validation.yml @@ -0,0 +1,59 @@ +name: Helm Chart Validation + +on: + pull_request: + paths: + - 'helm-chart/zxporter/**' + - 'helm-chart/zxporter-netmon/**' + workflow_dispatch: + +jobs: + validate-zxporter: + name: Lint & template zxporter chart + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: '3.12.3' + + - name: Update chart dependencies + run: helm dependency update helm-chart/zxporter + + - name: Lint chart + run: helm lint helm-chart/zxporter + + - name: Template render check + run: | + helm template zxporter helm-chart/zxporter \ + --set zxporter.clusterToken=ci-test-token \ + --set zxporter.kubeContextName=ci-test-cluster \ + --set zxporter.k8sProvider=other \ + > /dev/null + echo "zxporter chart rendered successfully" + + validate-netmon: + name: Lint & template zxporter-netmon chart + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: '3.12.3' + + - name: Update chart dependencies + run: helm dependency update helm-chart/zxporter-netmon + + - name: Lint chart + run: helm lint helm-chart/zxporter-netmon + + - name: Template render check + run: | + helm template zxporter-netmon helm-chart/zxporter-netmon > /dev/null + echo "zxporter-netmon chart rendered successfully" \ No newline at end of file