diff --git a/.github/workflows/helmchart_on_release.yml b/.github/workflows/helmchart_on_release.yml new file mode 100644 index 0000000000..1d63cbc326 --- /dev/null +++ b/.github/workflows/helmchart_on_release.yml @@ -0,0 +1,66 @@ +name: Publish Helm Chart on Release + +on: + release: + types: [published] + +jobs: + bump-helm-version: + runs-on: ubicloud-standard-2 + + steps: + - name: Checkout on helm repository + uses: actions/checkout@v3 + with: + repository: windmill-labs/windmill-helm-charts + token: ${{ secrets.DOCS_TOKEN }} + + - name: Get version + id: get_version + run: | + echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + + - name: Create new branch + run: | + # Check if branch already exists remotely + if git ls-remote --heads origin bump-helm-version-${{ env.VERSION }} | grep -q bump-helm-version-${{ env.VERSION }}; then + # Branch exists, check it out + git fetch origin bump-helm-version-${{ env.VERSION }} + git checkout bump-helm-version-${{ env.VERSION }} + else + # Create new branch + git checkout -b bump-helm-version-${{ env.VERSION }} + fi + + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Bump helm version + run: | + # Get current version and increment it by 1 + CURRENT_VERSION=$(grep "version:" ./charts/windmill/Chart.yaml | awk '{print $2}' | head -n 1) + NEW_VERSION=$(echo "$CURRENT_VERSION" | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') + sed -i "s/^version: .*/version: $NEW_VERSION/" ./charts/windmill/Chart.yaml + + # Get the app version from the version + VERSION=${{ env.VERSION }} + APP_VERSION=${VERSION#refs/tag/} + APP_VERSION=${APP_VERSION#v} + APP_VERSION=${APP_VERSION%/} + sed -i "s/appVersion: .*/appVersion: $APP_VERSION/" ./charts/windmill/Chart.yaml + + - name: Commit and push + run: | + git add . + git commit -m "Bump helm version to ${{ env.VERSION }}" + git push origin bump-helm-version-${{ env.VERSION }} + + - name: Create PR + env: + GH_TOKEN: ${{ secrets.DOCS_TOKEN }} + run: | + gh pr create \ + --title "helm: bump version to ${{ env.VERSION }}" \ + --body "This PR was auto-generated to bring the helm chart up to date for [release ${{ env.VERSION }}](https://github.com/windmill-labs/windmill/releases/tag/v${{ env.VERSION }}) in the main repo." \ + --head bump-helm-version-${{ env.VERSION }} \ + --base main