chore: add manual auto project version bump

This commit is contained in:
Steve Johnson 2023-10-19 14:25:28 +08:00 committed by GitHub
parent fcff23a222
commit aa9a2d9ecd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 5 deletions

View file

@ -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:

View file

@ -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