Skip to content

Commit

Permalink
feat(build): use release version in bump-job (#3207)
Browse files Browse the repository at this point in the history
* feat(build): use release version in bump-job

* use variable instead of literal

* renamed parameter
  • Loading branch information
paullatzelsperger authored Jun 22, 2023
1 parent 1b6162a commit f4d18e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 20 additions & 4 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,14 +24,27 @@ 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
oldVersion=${{ inputs.base_version }}
if [ -z $oldVersion ]; then
#... or read it from gradle.properties
echo "No base_version input was given, will read base version from gradle.properties"
oldVersion=$(grep "version" gradle.properties | awk -F= '{print $2}')
fi
# read the major, minor, and patch components, consume -SNAPSHOT
IFS=.- read -r RELEASE_VERSION_MAJOR RELEASE_VERSION_MINOR RELEASE_VERSION_PATCH SNAPSHOT<<<"$oldVersion"
INC=0
# Compute new snapshot version, do not increment snapshot on non-final releases, e.g. -rc1
if [ -z $SNAPSHOT ]; then
echo "$oldVersion is a final release version, increase patch for next snapshot"
INC=1
else
echo "$oldVersion 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"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release-edc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/bump-version
with:
target_branch: "main"
target_branch: "main"
base_version: ${{ needs.Prepare-Release.outputs.edc-version }}

0 comments on commit f4d18e5

Please sign in to comment.