55 default : ' main'
66 description : " Branch on which the version bump is to be done."
77 required : false
8+ base_version :
9+ description : " The current version, which is to be bumped to the next snapshot"
10+ required : false
811
912runs :
1013 using : " composite"
@@ -21,14 +24,27 @@ runs:
2124 git fetch origin
2225 git checkout ${{ inputs.target_branch }}
2326
24- # determine current version
25- oldVersion=$(grep "version" gradle.properties | awk -F= '{print $2}')
26-
27+ # use current version from input
28+ oldVersion=${{ inputs.base_version }}
29+ if [ -z $oldVersion ]; then
30+ #... or read it from gradle.properties
31+ echo "No base_version input was given, will read base version from gradle.properties"
32+ oldVersion=$(grep "version" gradle.properties | awk -F= '{print $2}')
33+ fi
34+
2735 # read the major, minor, and patch components, consume -SNAPSHOT
2836 IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"$oldVersion"
37+ INC=0
38+ # Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1
39+ if [ -z $SNAPSHOT ]; then
40+ echo "$oldVersion is a final release version, increase patch for next snapshot"
41+ INC=1
42+ else
43+ echo "$oldVersion is not a final release version (contains \"$SNAPSHOT\"), will not increase patch"
44+ fi
2945
3046 # construct the new version
31- newVersion="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+1 ))"-SNAPSHOT
47+ newVersion="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+$INC ))"-SNAPSHOT
3248
3349 # replace every occurrence of =$oldVersion with =$newVersion
3450 grep -rlz "$oldVersion" . --exclude=\*.{sh,bin} | xargs sed -i "s/$oldVersion/$newVersion/g"
0 commit comments