From 6840f62dd768ecc05144ef8c7e5a2db2fe37aedb Mon Sep 17 00:00:00 2001 From: Chirayu Kapoor Date: Fri, 11 Apr 2025 15:22:37 +0530 Subject: [PATCH] feat: Add support for auto chart bump - New charts will be pushed to branch with name chart/[MAJOR-VERSION].[MINOR-VERSION] --- .github/workflows/release.yaml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 275bfbd4..415b4f0f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -105,6 +105,39 @@ jobs: done echo "Charts successfully uploaded to GitHub release $TAG" + - name: Add charts to branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + version=$(echo '${{ steps.goreleaser.outputs.metadata }}' | jq -r '.version') + branch_version=v$(echo "$version" | cut -d'.' -f1,2) + charts_branch=charts/$branch_version + if [ ! -e ~/.gitconfig ]; then + git config --global user.name "aks-operator-bot" + git config --global user.email aks-operator@suse.de + fi + echo "Publishing helm chart in the branch $charts_branch" + if ! git ls-remote --exit-code --heads origin "$charts_branch"; then + git checkout --orphan "$charts_branch" + git rm -rf . + echo "# AKS Operator Helm Charts for $branch_version versions" > README.md + echo "The documentation is centralized in a unique place, checkout https://github.com/rancher/aks-operator." >> README.md + git checkout origin/main -- License .gitignore + git add README.md License .gitignore + git commit -m "Initial commit for $charts_branch" + else + git checkout . + git checkout "$charts_branch" + fi + mkdir -p charts + for f in $(find bin/ -name '*.tgz'); do + tar -xf $f -C charts/ + done + git add charts/**/* + git commit -m "Update charts to version $version" + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git + git push origin "$charts_branch" + dispatch-dependency: permissions: contents: read