Skip to content

Commit

Permalink
fix: revert wrong version, fix bump job
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Jun 22, 2023
1 parent 43c48d3 commit 40f8af6
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions .github/actions/bump-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ inputs:
default: 'main'
description: "Branch on which the version bump is to be done."
required: false
base_version:
description: "The current version, which is to be bumped to the next snapshot"
required: false

runs:
using: "composite"
Expand All @@ -21,22 +24,31 @@ runs:
git fetch origin
git checkout ${{ inputs.target_branch }}
# determine current version
oldVersion=$(grep "version" gradle.properties | awk -F= '{print $2}')
# use current version from input
baseVersion=${{ inputs.base_version }}
existingVersion=$(grep "version" gradle.properties | awk -F= '{print $2}')
# read the major, minor, and patch components, consume -SNAPSHOT
IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"$oldVersion"
IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"$baseVersion"
INC=0
# Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1
if [ -z $SNAPSHOT ]; then
echo "$baseVersion is a final release version, increase patch for next snapshot"
INC=1
else
echo "$baseVersion is not a final release version (contains \"$SNAPSHOT\"), will not increase patch"
fi
# construct the new version
newVersion="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+1))"-SNAPSHOT
newVersion="$RELEASE_VERSION_MAJOR.$RELEASE_VERSION_MINOR.$((RELEASE_VERSION_PATCH+$INC))"-SNAPSHOT
# replace every occurrence of =$oldVersion with =$newVersion
grep -rlz "$oldVersion" . --exclude=\*.{sh,bin} | xargs sed -i "s/$oldVersion/$newVersion/g"
# replace every occurrence of =$baseVersion with =$newVersion
grep -rlz "$existingVersion" . --exclude=\*.{sh,bin} | xargs sed -i "s/$existingVersion/$newVersion/g"
echo "Bumped the version from $oldVersion to $newVersion"
echo "Bumped the version from $baseVersion to $newVersion"
# Commit and push to the desired branch, defaults to 'main'
git add .
git commit --message "Bump version from $oldVersion to $newVersion [skip ci]"
git commit --message "Bump version from $baseVersion to $newVersion [skip ci]"
git push origin ${{ inputs.target_branch }}

0 comments on commit 40f8af6

Please sign in to comment.