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,22 +24,31 @@ 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+ baseVersion=${{ inputs.base_version }}
29+ existingVersion=$(grep "version" gradle.properties | awk -F= '{print $2}')
30+
2731 # read the major, minor, and patch components, consume -SNAPSHOT
28- IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"$oldVersion"
32+ IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"$baseVersion"
33+ INC=0
34+ # Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1
35+ if [ -z $SNAPSHOT ]; then
36+ echo "$baseVersion is a final release version, increase patch for next snapshot"
37+ INC=1
38+ else
39+ echo "$baseVersion is not a final release version (contains \"$SNAPSHOT\"), will not increase patch"
40+ fi
2941
3042 # construct the new version
31- newVersion="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+1 ))"-SNAPSHOT
43+ newVersion="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+$INC ))"-SNAPSHOT
3244
33- # replace every occurrence of =$oldVersion with =$newVersion
34- grep -rlz "$oldVersion " . --exclude=\*.{sh,bin} | xargs sed -i "s/$oldVersion /$newVersion/g"
45+ # replace every occurrence of =$baseVersion with =$newVersion
46+ grep -rlz "$existingVersion " . --exclude=\*.{sh,bin} | xargs sed -i "s/$existingVersion /$newVersion/g"
3547
36- echo "Bumped the version from $oldVersion to $newVersion"
48+ echo "Bumped the version from $baseVersion to $newVersion"
3749
3850 # Commit and push to the desired branch, defaults to 'main'
3951 git add .
40- git commit --message "Bump version from $oldVersion to $newVersion [skip ci]"
52+ git commit --message "Bump version from $baseVersion to $newVersion [skip ci]"
4153
4254 git push origin ${{ inputs.target_branch }}
0 commit comments