-
Notifications
You must be signed in to change notification settings - Fork 83
/
.gitlab-ci.yml
337 lines (313 loc) · 9.49 KB
/
.gitlab-ci.yml
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
stages:
- build
- test
- deploy
- upload
variables:
GRADLE_USER_HOME: "${CI_PROJECT_DIR}/.gradle"
cache:
- key:
files:
- gradle/wrapper/gradle-wrapper.properties
paths:
- .gradle/wrapper
- .gradle/caches
#####################################
# Build XCFramework
xcframework:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
when: manual
artifacts:
name: "green_xcframework-$CI_COMMIT_SHORT_SHA"
expire_in: 4 days
when: on_success
paths:
- common/build/XCFrameworks/*.zip
tags:
- osx
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- ./gradlew assembleXCFramework
- cd common/build/XCFrameworks
- zip -r debug.zip debug
- zip -r release.zip release
#####################################
# Build Signed APKs
production:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 7 days
when: on_success
paths:
- green/build/outputs/apk/productionGoogle/release/*.apk
tags:
- ga
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- echo $ANDROID_KEYSTORE_BASE64 | base64 -d > keystore.jks
- ./gradlew useBlockstreamKeys
- ./gradlew assembleProductionGoogleRelease
production_fdroid:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
when: manual
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 7 days
when: on_success
paths:
- green/build/outputs/apk/productionFDroid/release/*.apk
tags:
- ga
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- echo $ANDROID_KEYSTORE_BASE64 | base64 -d > keystore.jks
- ./prepare_fdroid.sh
- ./gradlew useBlockstreamKeys
- ./gradlew assembleProductionFDroidRelease
development:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
when: manual
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 7 days
when: on_success
paths:
- green/build/outputs/apk/development/release/*.apk
tags:
- ga
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- echo $ANDROID_KEYSTORE_BASE64 | base64 -d > keystore.jks
- ./gradlew useBlockstreamKeys
- ./gradlew assembleDevelopmentRelease
production_debug:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
when: manual
cache:
policy: pull
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 7 days
when: on_success
paths:
- green/build/outputs/apk/productionGoogle/debug/*.apk
tags:
- ga
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- echo $ANDROID_KEYSTORE_BASE64 | base64 -d > keystore.jks
- ./gradlew useBlockstreamKeys
- ./gradlew assembleProductionGoogleDebug
gdk_commit:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA-gdk-$GDK_COMMIT"
expire_in: 7 days
when: on_success
paths:
- green/build/outputs/apk/development/debug/*.apk
tags:
- ga
when: manual
cache:
policy: pull
variables:
GDK_COMMIT: master
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- echo $ANDROID_KEYSTORE_BASE64 | base64 -d > keystore.jks
- echo "GDK_COMMIT=$GDK_COMMIT"
- ./gdk/fetch_android_binaries.sh -c $GDK_COMMIT
- ./gradlew useBlockstreamKeys
- ./gradlew assembleDevelopmentDebug
#####################################
# Build Unsigned APK
build_google_play:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: build
when: manual
cache:
policy: pull
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 1 hour
when: on_success
paths:
- green/build/outputs/apk/productionGoogle/release/*.apk
- green/build/outputs/mapping/*/mapping.txt
tags:
- ga
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- ./gradlew lintProductionGoogleRelease
- ./gradlew useBlockstreamKeys
- ./gradlew assembleProductionGoogleRelease
build_osx:
stage: build
when: manual
tags:
- osx
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- ./gradlew useBlockstreamKeys
- ./gradlew assembleProductionGoogleRelease
#####################################
# Test
unit_tests:
image:
name: greenaddress/android@sha256:2e1c287e43417d4d69c11bf517f03043d23aba75f9aba1ee97cb47870c2106ca
entrypoint: [""]
stage: test
needs: []
cache:
policy: pull
tags:
- ga
variables:
GIT_SUBMODULE_STRATEGY: recursive
script:
- cd $CI_PROJECT_DIR
- ./gradlew useBlockstreamKeys
# - ./gradlew lintProductionGoogleRelease
- ./gradlew test
#####################################
# Sign production build
sign_google_play:
tags:
- garelease
stage: deploy
cache: []
artifacts:
name: "$CI_PROJECT_NAME-$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA"
expire_in: 30 days
paths:
- green/build/outputs/*
when: on_success
script:
- cd $CI_PROJECT_DIR/green/build/outputs/apk/productionGoogle/release/
- /opt/process_release
needs:
- build_google_play
#####################################
# Upload to GCS bucket
.gcp_prep:
stage: upload
image: blockstream/gcloud-docker-tf:1.1.9
cache: []
tags:
- ga
gcp_auth:
extends: .gcp_prep
when: manual
id_tokens:
GITLAB_OIDC_TOKEN:
aud: https://gl.blockstream.io
variables:
POOL_ID: gitlab-2f4bb583
PROVIDER_ID: gitlab
SERVICE_ACCOUNT_EMAIL: green-android-builds-uploader@green-backend.iam.gserviceaccount.com
script:
- echo ${GITLAB_OIDC_TOKEN} > .ci_job_jwt_file
- gcloud iam workload-identity-pools create-cred-config "projects/697214616889/locations/global/workloadIdentityPools/${POOL_ID}/providers/${PROVIDER_ID}"
--service-account="${SERVICE_ACCOUNT_EMAIL}"
--output-file=.gcp_temp_cred.json
--credential-source-file=.ci_job_jwt_file
artifacts:
paths:
- .gcp_temp_cred.json
- .ci_job_jwt_file
expire_in: 1h
gcp_push_production:
extends: .gcp_prep
needs: ["gcp_auth", "production"]
variables:
GCS_BUCKET: green-android-builds
APK_NAME: $CI_PROJECT_NAME-$CI_COMMIT_SHA
before_script:
- gcloud auth login --cred-file=.gcp_temp_cred.json --update-adc
script:
- apk add libqrencode
- echo "Uploading gs://$GCS_BUCKET/$APK_NAME"
- gsutil -m cp -r $CI_PROJECT_DIR/green/build/outputs/apk/productionGoogle/release/*.apk gs://$GCS_BUCKET/$APK_NAME.apk
- echo "https://storage.googleapis.com/$GCS_BUCKET/$APK_NAME.apk"
- qrencode -t UTF8 "https://storage.googleapis.com/$GCS_BUCKET/$APK_NAME.apk"
gcp_push_development:
extends: .gcp_prep
needs: ["gcp_auth", "development"]
variables:
GCS_BUCKET: green-android-builds
APK_NAME: $CI_PROJECT_NAME-$CI_COMMIT_SHA-development
before_script:
- gcloud auth login --cred-file=.gcp_temp_cred.json --update-adc
script:
- apk add libqrencode
- echo "Uploading gs://$GCS_BUCKET/$APK_NAME"
- gsutil -m cp -r $CI_PROJECT_DIR/green/build/outputs/apk/development/release/*.apk gs://$GCS_BUCKET/$APK_NAME.apk
- echo "https://storage.googleapis.com/$GCS_BUCKET/$APK_NAME.apk"
- qrencode -t UTF8 "https://storage.googleapis.com/$GCS_BUCKET/$APK_NAME.apk"
gcp_push_gdk_commit:
extends: .gcp_prep
needs: ["gcp_auth", "gdk_commit"]
variables:
GCS_BUCKET: green-android-builds
APK_NAME: $CI_PROJECT_NAME-$CI_COMMIT_SHA-gdk
before_script:
- gcloud auth login --cred-file=.gcp_temp_cred.json --update-adc
script:
- apk add libqrencode
- echo "Uploading gs://$GCS_BUCKET/$APK_NAME"
- gsutil -m cp -r $CI_PROJECT_DIR/green/build/outputs/apk/productionGoogle/release/*.apk gs://$GCS_BUCKET/$APK_NAME.apk
- echo "https://storage.googleapis.com/$GCS_BUCKET/$APK_NAME.apk"
- qrencode -t UTF8 "https://storage.googleapis.com/$GCS_BUCKET/$APK_NAME.apk"
gcp_push_xcframework:
extends: .gcp_prep
needs: ["gcp_auth", "xcframework"]
variables:
GCS_BUCKET: green-android-builds
XCFRAMEWORK_NAME: green_xcframework-$CI_COMMIT_SHA
before_script:
- gcloud auth login --cred-file=.gcp_temp_cred.json --update-adc
script:
- apk add libqrencode
- echo "Uploading gs://$GCS_BUCKET/${XCFRAMEWORK_NAME}_debug.zip"
- gsutil -m cp -r $CI_PROJECT_DIR/common/build/XCFrameworks/release.zip gs://$GCS_BUCKET/${XCFRAMEWORK_NAME}_debug.zip
- echo "https://storage.googleapis.com/$GCS_BUCKET/${XCFRAMEWORK_NAME}_debug.zip"
- echo "Uploading gs://$GCS_BUCKET/${XCFRAMEWORK_NAME}_release.zip"
- gsutil -m cp -r $CI_PROJECT_DIR/common/build/XCFrameworks/release.zip gs://$GCS_BUCKET/${XCFRAMEWORK_NAME}_release.zip
- echo "https://storage.googleapis.com/$GCS_BUCKET/${XCFRAMEWORK_NAME}_release.zip"