From 5201dcea9ed74d1b8757f7e6323c6eb45428c3cf Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:02:10 -0700 Subject: [PATCH] Adding workflow to increment version after release (#664) (#671) * Adding workflow to increment version after release on the 2.x branch * Added CHANGELOG --------- (cherry picked from commit 7d38fe5719215b62e8a39b2a7d80419a854f302a) Signed-off-by: Vacha Shah Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .github/workflows/increment-version.yml | 66 +++++++++++++++++++++++++ CHANGELOG.md | 1 + 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/increment-version.yml diff --git a/.github/workflows/increment-version.yml b/.github/workflows/increment-version.yml new file mode 100644 index 0000000000..e8e754dd04 --- /dev/null +++ b/.github/workflows/increment-version.yml @@ -0,0 +1,66 @@ +name: Increment Version + +on: + push: + tags: + - '*.*.*' + +permissions: {} +jobs: + build: + if: github.repository == 'opensearch-project/opensearch-java' + runs-on: ubuntu-latest + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v2.1.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: | + TAG=$(echo "${GITHUB_REF#refs/*/}") + CURRENT_VERSION_ARRAY=($(echo "${TAG//v}" | tr . '\n')) + CURRENT_VERSION_ARRAY[0]=$((CURRENT_VERSION_ARRAY[0]//v)) + BASE_X=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:1}.x") + 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}") + # if [[ ${#CURRENT_VERSION_ARRAY[2]} -gt 1 ]]; then + # NEXT_VERSION_ID="${CURRENT_VERSION_ARRAY[0]:0:3}0${CURRENT_VERSION_ARRAY[1]:0:3}${CURRENT_VERSION_ARRAY[2]:0:3}99" + # else + # NEXT_VERSION_ID=$(IFS=0 ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}99") + # fi + echo "TAG=$TAG" >> $GITHUB_ENV + # echo "BASE=$BASE" >> $GITHUB_ENV + echo "BASE_X=$BASE_X" >> $GITHUB_ENV + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV + # echo "NEXT_VERSION_ID=$NEXT_VERSION_ID" >> $GITHUB_ENV + - uses: actions/checkout@v4 + with: + ref: ${{ env.BASE_X }} + token: ${{ steps.github_app_token.outputs.token }} + + - name: Increment Minor Version + run: | + echo Incrementing $CURRENT_VERSION to $NEXT_VERSION + sed -i "s/systemProp.version = $CURRENT_VERSION/systemProp.version = $NEXT_VERSION/g" gradle.properties + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ steps.github_app_token.outputs.token }} + base: ${{ env.BASE_X }} + branch: 'create-pull-request/patch-${{ env.BASE }}' + commit-message: Increment version to ${{ env.NEXT_VERSION }} + signoff: true + delete-branch: true + labels: | + autocut + title: '[AUTO] Increment version to ${{ env.NEXT_VERSION }}.' + body: | + I've noticed that a new tag ${{ env.TAG }} was pushed, and incremented the version from ${{ env.CURRENT_VERSION }} to ${{ env.NEXT_VERSION }}. diff --git a/CHANGELOG.md b/CHANGELOG.md index 4096cb11bc..7e71d603c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added support for wrapper queries ([#630](https://github.com/opensearch-project/opensearch-java/pull/630)) - Added support for "script_fields" in multi search request ([#632](https://github.com/opensearch-project/opensearch-java/pull/632)) - Added size attribute to MultiTermsAggregation ([#627](https://github.com/opensearch-project/opensearch-java/pull/627)) +- Added version increment workflow that executes after release ([#664](https://github.com/opensearch-project/opensearch-java/pull/664)) ### Dependencies - Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.0.0 to 5.2.0