From 23efba51ba1b6a808b9aa0a5fe592d6b5b1b5326 Mon Sep 17 00:00:00 2001 From: Rajesh Kumar Date: Fri, 16 Aug 2024 20:33:40 +0530 Subject: [PATCH] Governance: Automatically update the appVersion in Chart when released #547 --- .github/workflows/release.yaml | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 01f04888..b8fbc885 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -138,3 +138,40 @@ jobs: args: release --clean --config .goreleaser/${{ env.GO_RELEASER_CONFIG }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get new chart version from the chart repo + id: get_chart_version + run: | + helm repo add kusionstack https://kusionstack.github.io/charts + helm repo update + version=$(helm search repo kusionstack/karpor --versions | head -n 2 | tail -n 1 | awk '{print $2}') + if [ -z "$version" ]; then + echo "Error: Unable to fetch chart version" >&2 + exit 1 + fi + echo "Current chart version is: $version") + major=$(echo "$version" | cut -d. -f1) + minor=$(echo "$version" | cut -d. -f2) + patch=$(echo "$version" | cut -d. -f3) + new_chart_version="${major}.${minor}.$((patch + 1))" + echo "New chart version is: $new_chart_version" + echo "::set-output name=new_chart_version::$new_chart_version" + + - name: Bump version in the related HelmChart Chart.yaml + uses: fjogeleit/yaml-update-action@main + with: + repository: KusionStack/charts + valueFile: 'charts/karpor/Chart.yaml' + propertyPath: '{"version":"${{ steps.get-chart-version.outputs.new_chart_version }}", "appVersion":"${{ steps.get_version.outputs.VERSION }}"}' + value: ${{ steps.get_version.outputs.VERSION }} + branch: bump-karpor-to-${{ steps.get_version.outputs.VERSION }} + targetBranch: test + createPR: false + message: 'refactor: bump karpor version to ${{ steps.get_version.outputs.VERSION }}' + token: ${{ secrets.GITHUB_TOKEN }} + workDir: . + + - name: Log Test Outputs # Log outputs for debugging + run: | + echo "Testing complete. Check the logs for details." + echo "New chart version: ${{ steps.get_chart_version.outputs.new_chart_version }}" + echo "App version: ${{ steps.get_version.outputs.VERSION }}"