This repository has been archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (92 loc) ยท 3.55 KB
/
versioning-and-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Build, Increment Version, and Upload to Firebase App Distribution
on:
push:
branches:
- develop
workflow_dispatch:
jobs:
increment_version_code:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
- name: Update version code
id: update_version_code
run: |
# Get the current versionCode from build.gradle
VERSION_CODE=$(grep versionCode ./Nabi/presentation/build.gradle.kts | sed 's/[^0-9]*//g')
# Increment the versionCode
NEW_VERSION_CODE=$((VERSION_CODE + 1))
# Replace the old versionCode with the new one in build.gradle
sed -i "s/versionCode $VERSION_CODE/versionCode $NEW_VERSION_CODE/" ./Nabi/presentation/build.gradle.kts
# Check if there are changes to commit
if [ $(git status --porcelain | wc -l) -gt 0 ]; then
git config --global user.name "${{ secrets.GIT_USER_NAME }}"
git config --global user.email "${{ secrets.GIT_USER_EMAIL }}"
git checkout -b version-update
git commit -am "[GitHub Action] Increment versionCode to $NEW_VERSION_CODE"
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
- name: Push changes
if: steps.update_version_code.outputs.changed == 'true'
run: |
git push origin version-update
merge_version_update:
runs-on: ubuntu-latest
needs: increment_version_code
if: needs.increment_version_code.outputs.changed == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Merge version-update branch
run: |
git fetch origin
git checkout develop
git merge origin/version-update
git push origin develop
build_and_upload:
runs-on: ubuntu-latest
needs: merge_version_update
if: needs.merge_version_update.result == 'success'
env:
LOCAL_PROPERTIES_CONTENTS: ${{ secrets.LOCAL_PROPERTIES_CONTENTS }}
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
- name: Grant execute permission for gradlew
run: chmod +x ./Nabi/gradlew
- name: Decode and save keystore
run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > ./Nabi/presentation/keystore.jks
- name: Verify keystore
run: |
ls -alh ./Nabi/presentation/
echo "Checking JKS format..."
keytool -list -v -keystore ./Nabi/presentation/keystore.jks -storetype JKS || echo "JKS format verification failed"
- name: Create google-services.json
run: echo "$GOOGLE_SERVICES_JSON" > ./Nabi/presentation/google-services.json
- name: Create local.properties
run: echo "$LOCAL_PROPERTIES_CONTENTS" > ./Nabi/local.properties
- name: Build release APK
run: |
cd ./Nabi
./gradlew assembleRelease
- name: Upload to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_APP_ID }}
serviceCredentialsFileContent: ${{ secrets.CREDENTIAL_FILE_CONTENT }}
groups: nabi-team
file: ./Nabi/presentation/build/outputs/apk/release/Nabi-release.apk