-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (190 loc) · 7.12 KB
/
Copy pathgradle.yml
File metadata and controls
235 lines (190 loc) · 7.12 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: Nightly Snapshot
on:
#schedule:
# - cron: "0 0 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
# The name of the main module repository
main_project_module: app
# The name of the App
app_name: Valolink
# The name of the android app package
package_name: dev.bittim.valolink
jobs:
CheckNewCommits:
runs-on: ubuntu-latest
outputs:
doRebuild: ${{ steps.decideRebuild.outputs.doRebuild }}
steps:
- name: Checking out branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest commit SHA
id: latestsha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Get Previous tag
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: Get commit SHA of latest Tag
id: tagsha
run: echo "sha=$(git rev-list -n 1 ${{ steps.previoustag.outputs.tag }})" >> $GITHUB_OUTPUT
- name: Decide rebuild
id: decideRebuild
env:
LATEST_SHA: ${{ steps.latestsha.outputs.sha }}
TAG_SHA: ${{ steps.tagsha.outputs.sha }}
run: |
if [[ $LATEST_SHA == $TAG_SHA ]]; then
echo "doRebuild=false" >> $GITHUB_OUTPUT
else
echo "doRebuild=true" >> $GITHUB_OUTPUT
fi
Build:
needs: [ CheckNewCommits ]
if: needs.CheckNewCommits.outputs.doRebuild == 'true'
runs-on: ubuntu-latest
outputs:
apkName: ${{ steps.apkName.outputs.apkName }}
aabName: ${{ steps.aabName.outputs.aabName }}
steps:
- name: Checking out branch
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@main
with:
distribution: 'temurin'
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Making gradlew executable
run: chmod +x ./gradlew
# Run Tests Build
- name: Run gradle test
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: ./gradlew test
# This will decode the keystore from base 64 text representation that we have stored in secrets
# and generates and keystore file and gets stored in /android-app path
- name: Decode Keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE_64 }}
run: |
echo $KEYSTORE_BASE64 | base64 -di > keystore.jks
- name: Build Release apk
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: ./gradlew assembleRelease --stacktrace
- name: Build Release bundle
env:
STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: ./gradlew bundleRelease --stacktrace
- name: Get APK file path
id: apkFile
run: echo "apkFile=$(find app/build/outputs/apk/release/*.apk)" >> $GITHUB_OUTPUT
- name: Get AAB file path
id: aabFile
run: echo "aabFile=$(find app/build/outputs/bundle/release/*.aab)" >> $GITHUB_OUTPUT
- name: Get APK file name
id: apkName
run: echo "apkName=$(basename ${{ steps.apkFile.outputs.apkFile }})" >> $GITHUB_OUTPUT
- name: Get AAB file name
id: aabName
run: echo "aabName=$(basename ${{ steps.aabFile.outputs.aabFile }})" >> $GITHUB_OUTPUT
- name: Upload Release Build APK to Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.apkName.outputs.apkName }}
path: ${{ steps.apkFile.outputs.apkFile }}
- name: Upload Release Build AAB to Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.aabName.outputs.aabName }}
path: ${{ steps.aabFile.outputs.aabFile }}
- name: Store reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: reports
path: |
**/build/reports/
**/build/test-results/
CreateNewTag:
needs: [ Build ]
runs-on: ubuntu-latest
outputs:
date: ${{ steps.date.outputs.date }}
versionName: ${{ steps.versionName.outputs.versionName }}
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current date
id: date
run: echo "date=$(date +'%d-%m-%Y_%H-%M')" >> $GITHUB_OUTPUT
- name: Read all values from version.properties
uses: BrycensRanch/read-properties-action@v1
id: versionProperties
with:
file: app/version.properties
all: true
- name: Get current version name
id: versionName
run: echo "versionName=$(echo v${{ steps.versionProperties.outputs.MAJOR }}.${{ steps.versionProperties.outputs.MINOR }}.${{ steps.versionProperties.outputs.PATCH }}-${{ steps.versionProperties.outputs.BUILD }})" >> $GITHUB_OUTPUT
- name: Generate tag name
id: tag
run: echo "tag=$(echo ${{ steps.versionName.outputs.versionName }}_${{ steps.date.outputs.date }})" >> $GITHUB_OUTPUT
- name: Create Tag
uses: ydataai/create-tag@v1
with:
tag: ${{ steps.tag.outputs.tag }}
message: ${{ env.app_name }} Nightly ${{ steps.versionName.outputs.versionName }} (${{ steps.date.outputs.date }})
Deploy:
needs: [ Build, CreateNewTag ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate Changelog
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.CreateNewTag.outputs.tag }}
- name: Truncate Changelog length (Max 500)
id: truncate-changelog
env:
CHANGES: ${{ steps.changelog.outputs.changes }}
run:
echo "length=$(echo $CHANGES | sed 's/\(.\{500\}\).*/\1/')"
- name: Create whatsnew directory and file
env:
TRUNC_CHANGES: ${{ steps.truncate-changelog.outputs.changes }}
run: |
mkdir whatsnew
echo "$TRUNC_CHANGES" > whatsnew/whatsnew-en-US
- name: Download artifact of release AAB
uses: actions/download-artifact@master
with:
name: ${{ needs.Build.outputs.aabName }}
- name: Upload artifact to Google Play Internal track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
packageName: ${{ env.package_name }}
releaseFiles: ${{ needs.Build.outputs.aabName }}
status: draft
track: internal
whatsNewDirectory: whatsnew