From aa9a2d9ecd956b3ea215b5f7071519a10b82587e Mon Sep 17 00:00:00 2001 From: Steve Johnson <144257728+stevejohnson7@users.noreply.github.com> Date: Thu, 19 Oct 2023 14:25:28 +0800 Subject: [PATCH] chore: add manual auto project version bump --- .github/workflows/build-release.yaml | 24 ++++++++++++++++++++++ .github/workflows/update-dependencies.yaml | 10 ++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index e8ef8fbc..3ec140f6 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -5,6 +5,11 @@ on: tags: - '*' # workflow_dispatch: + inputs: + auto-bump-version: + description: 'Bump project version before building release' + required: false + type: boolean jobs: BuildRelease: @@ -35,6 +40,25 @@ jobs: key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go- + + - name: Auto bump project version + if: ${{ inputs.auto-bump-version }} + run: | + # Update versionName and versionCode in build.gradle.kts + versionCode=$(grep -oP 'versionCode = \K\d+' build.gradle.kts) + versionName=$(grep -oP 'versionName = "\K[0-9.]+' build.gradle.kts) + major=$(echo $versionName | cut -d. -f1) + minor=$(echo $versionName | cut -d. -f2) + patch=$(echo $versionName | cut -d. -f3) + newPatch=$((patch + 1)) + newVersionName="$major.$minor.$newPatch" + newVersionCode=$((versionCode + 1)) + sed -i "s/versionCode = $versionCode/versionCode = $newVersionCode/" build.gradle.kts + sed -i "s/versionName = \"$versionName\"/versionName = \"$newVersionName\"/" build.gradle.kts + # Commit, tag and push + git commit -am "Bump version to $newVersionName ($newVersionCode)" + git tag "v$newVersionName" + git push --follow-tags - name: Signing properties env: diff --git a/.github/workflows/update-dependencies.yaml b/.github/workflows/update-dependencies.yaml index d652dc01..87ade93a 100644 --- a/.github/workflows/update-dependencies.yaml +++ b/.github/workflows/update-dependencies.yaml @@ -45,11 +45,11 @@ jobs: go mod download go mod tidy - # - name: Update Main Gomod - # run: | - # cd ./core/src/main/golang/ - # go mod download - # go mod tidy + - name: Update Main Gomod + run: | + cd ./core/src/main/golang/ + go mod download + go mod tidy - name: Create Pull Request id: cpr