From 1d46148d15b69f89ff0631182077c8698be45087 Mon Sep 17 00:00:00 2001 From: Shen <1648645367@qq.com> Date: Wed, 8 May 2024 17:39:49 +0800 Subject: [PATCH 1/3] feat: add pipeline auto-update Helm Charts and Risingwave Operator on New Release --- ...e-helm-and-operator-version-by-release.yml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/auto-update-helm-and-operator-version-by-release.yml diff --git a/.github/workflows/auto-update-helm-and-operator-version-by-release.yml b/.github/workflows/auto-update-helm-and-operator-version-by-release.yml new file mode 100644 index 0000000000000..b462c66cdb788 --- /dev/null +++ b/.github/workflows/auto-update-helm-and-operator-version-by-release.yml @@ -0,0 +1,65 @@ +name: Update Helm Charts and Risingwave Operator on New Release + +on: + release: + types: [published] + +jobs: + update-helm-charts: + runs-on: ubuntu-latest + steps: + - name: Checkout Helm Charts Repoistory + uses: actions/checkout@v3 + with: + repository: 'risingwavelabs/helm-charts' + token: ${{ secrets.GITHUB_TOKEN }} + path: 'helm-charts' + + - name: Update values.yaml + run: | + sed -i "s/^ tag:.*/ tag: \"${{ github.event.release.tag_name }}\"/" helm-charts/charts/risingwave/values.yaml + + - name: Update Chart.yaml + run: | + cd helm-charts/charts/risingwave + CURRENT_VERSION=$(grep 'version:' Chart.yaml | awk '{print $2}' | head -n 1) + NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. -v OFS='.' '{$NF++; print}') + sed -i "/type: application/,/version:/!b; /version:/s/version: .*/version: $NEW_VERSION/" Chart.yaml + sed -i "s/^appVersion: .*/appVersion: \"${{ github.event.release.tag_name }}\"/" Chart.yaml + echo "NEW_CHART_VERSION=$NEW_VERSION" >> $GITHUB_ENV + echo "NEW_APP_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: 'chore: bump risingwave to ${{ env.NEW_APP_VERSION }}, release chart ${{ env.NEW_CHART_VERSION }}' + title: 'chore: bump risingwave to ${{ env.NEW_APP_VERSION }}, release chart ${{ env.NEW_CHART_VERSION }}' + body: 'This is an automated pull request to update the chart versions' + branch: 'auto-update-${{ github.event.release.tag_name }}' + + update-risingwave-operator: + runs-on: ubuntu-latest + steps: + - name: Checkout Risingwave Operator Repository + uses: actions/checkout@v3 + with: + repository: 'risingwavelabs/risingwave-operator' + token: ${{ secrets.GITHUB_TOKEN }} + path: 'risingwave-operator' + + - name: Update risingwave-operator image tags + run: | + cd risingwave-operator + PREV_VERSION=$(grep -roh "risingwavelabs/risingwave:v[0-9\.]*" * | head -n 1 | cut -d':' -f2) + grep -rl "risingwavelabs/risingwave:$PREV_VERSION" . | xargs sed -i "s|risingwavelabs/risingwave:${PREV_VERSION}|risingwavelabs/risingwave:${{ env.NEW_APP_VERSION }}|g" + + - name: Create Pull Request for risingwave-operator + uses: peter-evans/create-pull-request@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: 'chore: bump risingwave image tags to ${{ env.NEW_APP_VERSION }}' + title: 'chore: bump risingwave image tags to ${{ env.NEW_APP_VERSION }}' + body: 'This is an automated pull request to update the risingwave image tags' + branch: 'auto-update-${{ github.event.release.tag_name }}' + path: 'risingwave-operator' From 5313bb01c9ad0eff026f7e4104c5d72adf647f93 Mon Sep 17 00:00:00 2001 From: Shen <1648645367@qq.com> Date: Thu, 9 May 2024 14:35:45 +0800 Subject: [PATCH 2/3] add workflow_dispatch --- ...pdate-helm-and-operator-version-by-release.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-update-helm-and-operator-version-by-release.yml b/.github/workflows/auto-update-helm-and-operator-version-by-release.yml index b462c66cdb788..e5ecdd23c7e20 100644 --- a/.github/workflows/auto-update-helm-and-operator-version-by-release.yml +++ b/.github/workflows/auto-update-helm-and-operator-version-by-release.yml @@ -3,6 +3,11 @@ name: Update Helm Charts and Risingwave Operator on New Release on: release: types: [published] + workflow_dispatch: + inputs: + version: + description: 'release version' + required: true jobs: update-helm-charts: @@ -17,7 +22,7 @@ jobs: - name: Update values.yaml run: | - sed -i "s/^ tag:.*/ tag: \"${{ github.event.release.tag_name }}\"/" helm-charts/charts/risingwave/values.yaml + sed -i "s/^ tag:.*/ tag: \"${{ github.event.inputs.version || github.event.release.tag_name }}\"/" helm-charts/charts/risingwave/values.yaml - name: Update Chart.yaml run: | @@ -25,9 +30,9 @@ jobs: CURRENT_VERSION=$(grep 'version:' Chart.yaml | awk '{print $2}' | head -n 1) NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. -v OFS='.' '{$NF++; print}') sed -i "/type: application/,/version:/!b; /version:/s/version: .*/version: $NEW_VERSION/" Chart.yaml - sed -i "s/^appVersion: .*/appVersion: \"${{ github.event.release.tag_name }}\"/" Chart.yaml + sed -i "s/^appVersion: .*/appVersion: \"${{ github.event.inputs.version || github.event.release.tag_name }}\"/" Chart.yaml echo "NEW_CHART_VERSION=$NEW_VERSION" >> $GITHUB_ENV - echo "NEW_APP_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV + echo "NEW_APP_VERSION=${{ github.event.inputs.version || github.event.release.tag_name }}" >> $GITHUB_ENV - name: Create Pull Request uses: peter-evans/create-pull-request@v4 @@ -36,7 +41,7 @@ jobs: commit-message: 'chore: bump risingwave to ${{ env.NEW_APP_VERSION }}, release chart ${{ env.NEW_CHART_VERSION }}' title: 'chore: bump risingwave to ${{ env.NEW_APP_VERSION }}, release chart ${{ env.NEW_CHART_VERSION }}' body: 'This is an automated pull request to update the chart versions' - branch: 'auto-update-${{ github.event.release.tag_name }}' + branch: 'auto-update-${{ github.event.inputs.version || github.event.release.tag_name }}' update-risingwave-operator: runs-on: ubuntu-latest @@ -61,5 +66,5 @@ jobs: commit-message: 'chore: bump risingwave image tags to ${{ env.NEW_APP_VERSION }}' title: 'chore: bump risingwave image tags to ${{ env.NEW_APP_VERSION }}' body: 'This is an automated pull request to update the risingwave image tags' - branch: 'auto-update-${{ github.event.release.tag_name }}' + branch: 'auto-update-${{ github.event.inputs.version || github.event.release.tag_name }}' path: 'risingwave-operator' From 940e7ecf859ebb792c29d20c9aebac46518f60ce Mon Sep 17 00:00:00 2001 From: Shen <1648645367@qq.com> Date: Thu, 9 May 2024 15:40:59 +0800 Subject: [PATCH 3/3] refactor --- ...ate-helm-and-operator-version-by-release.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/auto-update-helm-and-operator-version-by-release.yml b/.github/workflows/auto-update-helm-and-operator-version-by-release.yml index e5ecdd23c7e20..1641caa3301fd 100644 --- a/.github/workflows/auto-update-helm-and-operator-version-by-release.yml +++ b/.github/workflows/auto-update-helm-and-operator-version-by-release.yml @@ -9,11 +9,14 @@ on: description: 'release version' required: true +env: + NEW_APP_VERSION: ${{ github.event.inputs.version || github.event.release.tag_name }} + jobs: update-helm-charts: runs-on: ubuntu-latest steps: - - name: Checkout Helm Charts Repoistory + - name: Checkout Helm Charts Repository uses: actions/checkout@v3 with: repository: 'risingwavelabs/helm-charts' @@ -22,7 +25,7 @@ jobs: - name: Update values.yaml run: | - sed -i "s/^ tag:.*/ tag: \"${{ github.event.inputs.version || github.event.release.tag_name }}\"/" helm-charts/charts/risingwave/values.yaml + sed -i "s/^ tag:.*/ tag: \"${{ env.NEW_APP_VERSION }}\"/" helm-charts/charts/risingwave/values.yaml - name: Update Chart.yaml run: | @@ -30,9 +33,8 @@ jobs: CURRENT_VERSION=$(grep 'version:' Chart.yaml | awk '{print $2}' | head -n 1) NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. -v OFS='.' '{$NF++; print}') sed -i "/type: application/,/version:/!b; /version:/s/version: .*/version: $NEW_VERSION/" Chart.yaml - sed -i "s/^appVersion: .*/appVersion: \"${{ github.event.inputs.version || github.event.release.tag_name }}\"/" Chart.yaml + sed -i "s/^appVersion: .*/appVersion: \"${{ env.NEW_APP_VERSION }}\"/" Chart.yaml echo "NEW_CHART_VERSION=$NEW_VERSION" >> $GITHUB_ENV - echo "NEW_APP_VERSION=${{ github.event.inputs.version || github.event.release.tag_name }}" >> $GITHUB_ENV - name: Create Pull Request uses: peter-evans/create-pull-request@v4 @@ -41,7 +43,7 @@ jobs: commit-message: 'chore: bump risingwave to ${{ env.NEW_APP_VERSION }}, release chart ${{ env.NEW_CHART_VERSION }}' title: 'chore: bump risingwave to ${{ env.NEW_APP_VERSION }}, release chart ${{ env.NEW_CHART_VERSION }}' body: 'This is an automated pull request to update the chart versions' - branch: 'auto-update-${{ github.event.inputs.version || github.event.release.tag_name }}' + branch: 'auto-update-${{ env.NEW_APP_VERSION }}' update-risingwave-operator: runs-on: ubuntu-latest @@ -57,7 +59,7 @@ jobs: run: | cd risingwave-operator PREV_VERSION=$(grep -roh "risingwavelabs/risingwave:v[0-9\.]*" * | head -n 1 | cut -d':' -f2) - grep -rl "risingwavelabs/risingwave:$PREV_VERSION" . | xargs sed -i "s|risingwavelabs/risingwave:${PREV_VERSION}|risingwavelabs/risingwave:${{ env.NEW_APP_VERSION }}|g" + grep -rl "risingwavelabs/risingwave:$PREV_VERSION" . | xargs sed -i "s|risingwavelabs/risingwave:$PREV_VERSION|risingwavelabs/risingwave:${{ env.NEW_APP_VERSION }}|g" - name: Create Pull Request for risingwave-operator uses: peter-evans/create-pull-request@v4 @@ -66,5 +68,4 @@ jobs: commit-message: 'chore: bump risingwave image tags to ${{ env.NEW_APP_VERSION }}' title: 'chore: bump risingwave image tags to ${{ env.NEW_APP_VERSION }}' body: 'This is an automated pull request to update the risingwave image tags' - branch: 'auto-update-${{ github.event.inputs.version || github.event.release.tag_name }}' - path: 'risingwave-operator' + branch: 'auto-update-${{ env.NEW_APP_VERSION }}'