Skip to content

Commit 273ea54

Browse files
AsCressadityastic
andauthored
chore: updated push pipeline to configure automatic versioning (#2451)
Co-authored-by: Aditya Gupta <adityaofficialgupta@gmail.com>
1 parent 6552dc9 commit 273ea54

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

.github/workflows/push-event.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,39 @@ jobs:
3434
distribution: 'adopt'
3535
java-version: '17'
3636

37+
- name: Hydrate and Update Version
38+
id: android-version
39+
run: |
40+
git config --global user.name "${{ github.workflow }}"
41+
git config --global user.email "gh-actions@${{ github.repository_owner }}"
42+
43+
git clone --branch=version https://${{ github.repository_owner }}:${{ github.token }}@github.com/${{ github.repository }} version
44+
cd version
45+
46+
# Read and increment version name
47+
IFS='.' read -r major minor patch < versionName.txt
48+
current_patch_version_name="$major.$minor.$patch"
49+
echo "VERSION_NAME=$current_patch_version_name" >> $GITHUB_OUTPUT
50+
51+
next_patch=$((patch + 1))
52+
next_patch_version_name="$major.$minor.$next_patch"
53+
echo "$next_patch_version_name" > versionName.txt
54+
55+
# Read and increment version code
56+
read -r version_code < versionCode.txt
57+
echo "VERSION_CODE=$version_code" >> $GITHUB_OUTPUT
58+
59+
new_version_code=$((version_code + 1))
60+
echo "$new_version_code" > versionCode.txt
61+
62+
# Force push to version branch
63+
git checkout --orphan temporary
64+
git add --all .
65+
git commit -am "[Auto] Update versionName: $next_patch_version_name & versionCode: $new_version_code ($(date +%Y-%m-%d.%H:%M:%S))"
66+
git branch -D version
67+
git branch -m version
68+
git push --force origin version
69+
3770
- name: Prepare Build Keys
3871
env:
3972
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
@@ -46,6 +79,8 @@ jobs:
4679
STORE_PASS: ${{ secrets.STORE_PASS }}
4780
ALIAS: ${{ secrets.ALIAS }}
4881
KEY_PASS: ${{ secrets.KEY_PASS }}
82+
VERSION_CODE: ${{ steps.android-version.outputs.VERSION_CODE }}
83+
VERSION_NAME: ${{ steps.android-version.outputs.VERSION_NAME }}
4984
run: |
5085
bash ./gradlew build --stacktrace
5186
bash ./gradlew bundle --stacktrace

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ android {
1515
applicationId = "io.pslab"
1616
minSdk = 24
1717
targetSdk = 34
18-
versionCode = 26
19-
versionName = "3.1.2"
18+
versionCode = System.getenv("VERSION_CODE")?.toInt() ?: 1
19+
versionName = System.getenv("VERSION_NAME") ?: "1.0.0"
2020
resConfigs("en","ru","ar","si","pl")
2121
}
2222

0 commit comments

Comments
 (0)