From d97a41be5f4c17cd3aa1e6eb2dd867d6168fe5e4 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 11:38:50 +0800 Subject: [PATCH] Add github workflow to auto bump bwc version (#799) (#805) * Adding bump bwc version github workflow * revert app id --------- (cherry picked from commit eda85eb5add3e1d4ae18b852ce99a4c0c3195f7b) Signed-off-by: Hailong Cui Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .github/workflows/bump-bwc.yml | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/bump-bwc.yml diff --git a/.github/workflows/bump-bwc.yml b/.github/workflows/bump-bwc.yml new file mode 100644 index 00000000..dfdec028 --- /dev/null +++ b/.github/workflows/bump-bwc.yml @@ -0,0 +1,66 @@ +name: Bump bwc version + +on: + workflow_dispatch: + inputs: + tag: + type: string + required: true + push: + tags: + - '*.*.*.*' + +permissions: {} +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.5.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + + - uses: actions/checkout@v4 + - name: Fetch Tag and Version Information + run: | + if [ -n ${{ inputs.tag }} ]; then + TAG=${{ inputs.tag }} + else + TAG=$(echo "${GITHUB_REF#refs/*/}") + fi + CURRENT_VERSION_ARRAY=($(echo "$TAG" | tr . '\n')) + CURRENT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") + CURRENT_VERSION_ARRAY[1]=$((CURRENT_VERSION_ARRAY[1]+1)) + NEXT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") + echo "TAG=$TAG" >> $GITHUB_ENV + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + ref: main + token: ${{ steps.github_app_token.outputs.token }} + + - name: Bump bwc version for main branch + run: | + echo Bumping bwc version to $NEXT_VERSION + sed -i "s/def bwcVersionShort = \"$CURRENT_VERSION\"/def bwcVersionShort = \"$NEXT_VERSION\"/g" notifications/notifications/build.gradle + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ steps.github_app_token.outputs.token }} + base: main + branch: 'create-pull-request/patch-main' + commit-message: Bump bwc version to ${{ env.NEXT_VERSION }} + signoff: true + delete-branch: true + labels: | + autocut + title: '[AUTO] [main] Bump bwc version to ${{ env.NEXT_VERSION }}.' + body: | + I've noticed that a new tag ${{ env.TAG }} was pushed, and bump bwc version to ${{ env.NEXT_VERSION }}. +