Skip to content

Commit c87ee43

Browse files
dblockzelinh
authored andcommitted
Auto-increment version on new release tags. (#106)
Signed-off-by: dblock <dblock@amazon.com> Signed-off-by: Zelin Hao <zelinhao@amazon.com>
1 parent 0ecb54b commit c87ee43

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
# common-utils
2929
- name: Build and Test
3030
run: |
31-
./gradlew build -Dopensearch.version=1.3.0-SNAPSHOT
31+
./gradlew build
3232
3333
- name: Publish to Maven Local
3434
run: |
35-
./gradlew publishToMavenLocal -Dopensearch.version=1.3.0-SNAPSHOT
35+
./gradlew publishToMavenLocal
3636
3737
- name: Upload Coverage Report
3838
uses: codecov/codecov-action@v1

.github/workflows/version.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Increment Version
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*.*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Fetch Tag and Version Information
16+
run: |
17+
TAG=$(echo "${GITHUB_REF#refs/*/}")
18+
CURRENT_VERSION_ARRAY=($(echo "$TAG" | tr . '\n'))
19+
BASE=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:2}")
20+
CURRENT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}")
21+
CURRENT_VERSION_ARRAY[2]=$((CURRENT_VERSION_ARRAY[2]+1))
22+
NEXT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}")
23+
echo "TAG=$TAG" >> $GITHUB_ENV
24+
echo "BASE=$BASE" >> $GITHUB_ENV
25+
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
26+
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
27+
- uses: actions/checkout@v2
28+
with:
29+
ref: ${{ env.BASE }}
30+
- name: Increment Version
31+
run: |
32+
echo Incrementing $CURRENT_VERSION to $NEXT_VERSION
33+
sed -i "s/$CURRENT_VERSION-SNAPSHOT/$NEXT_VERSION-SNAPSHOT/g" build.gradle
34+
- name: Create Pull Request
35+
uses: peter-evans/create-pull-request@v3
36+
with:
37+
base: ${{ env.BASE }}
38+
commit-message: Incremented version to ${{ env.NEXT_VERSION }}
39+
delete-branch: true
40+
title: '[AUTO] Incremented version to ${{ env.NEXT_VERSION }}.'
41+
body: |
42+
I've noticed that a new tag ${{ env.TAG }} was pushed, and incremented the version from ${{ env.CURRENT_VERSION }} to ${{ env.NEXT_VERSION }}.

0 commit comments

Comments
 (0)