From f4d18e530bc7d5f2de979a6558576118d5115961 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger <43503240+paullatzelsperger@users.noreply.github.com> Date: Thu, 22 Jun 2023 08:17:49 +0200 Subject: [PATCH] feat(build): use release version in bump-job (#3207) * feat(build): use release version in bump-job * use variable instead of literal * renamed parameter --- .github/actions/bump-version/action.yml | 24 ++++++++++++++++++++---- .github/workflows/release-edc.yml | 3 ++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/actions/bump-version/action.yml b/.github/actions/bump-version/action.yml index fa8d33a32f8..3de9e51b0a6 100644 --- a/.github/actions/bump-version/action.yml +++ b/.github/actions/bump-version/action.yml @@ -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" @@ -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" diff --git a/.github/workflows/release-edc.yml b/.github/workflows/release-edc.yml index 44149c6af58..643b0946eca 100644 --- a/.github/workflows/release-edc.yml +++ b/.github/workflows/release-edc.yml @@ -71,4 +71,5 @@ jobs: - uses: actions/checkout@v3 - uses: ./.github/actions/bump-version with: - target_branch: "main" \ No newline at end of file + target_branch: "main" + base_version: ${{ needs.Prepare-Release.outputs.edc-version }} \ No newline at end of file