From 27ef5610c652fc421fa7899c5115f8650c7d91bf Mon Sep 17 00:00:00 2001 From: Jina Jain Date: Wed, 2 Oct 2024 15:31:58 -0700 Subject: [PATCH] update release workflow --- .github/workflows/release.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e784b56..a731915 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,9 +1,13 @@ name: Release Charts on: + workflow_dispatch: push: branches: - main + # Release only if the 'version' field in Chart.yaml was updated + paths: + - charts/**/Chart.yaml jobs: release: @@ -16,12 +20,31 @@ jobs: with: fetch-depth: 0 + - name: Validate Chart.yaml Update + id: check_update_chart + run: | + LATEST_VERSION=$(curl -s https://api.github.com/repos/splunk/synthetics-helm-charts/releases/latest | grep tag_name | cut -d - -f 4 | cut -d \" -f 1) + CURRENT_VERSION=$(cat charts/splunk-synthetics-runner/Chart.yaml | grep -E "^version:" | cut -d " " -f 2) + if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then + echo "New release needed, creating..." + echo "VALID_UPDATE=1" >> $GITHUB_OUTPUT + else + echo "No new release needed" + echo "VALID_UPDATE=0" >> $GITHUB_OUTPUT + fi + - name: Configure Git run: | git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + if: ${{ steps.check_update_chart.outputs.VALID_UPDATE == 1 }} + + - name: Install Helm + uses: azure/setup-helm@v4 + if: ${{ steps.check_update_chart.outputs.VALID_UPDATE == 1 }} - name: Run chart-releaser uses: helm/chart-releaser-action@v1.6.0 env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: ${{ steps.check_update_chart.outputs.VALID_UPDATE == 1 }}