-
Notifications
You must be signed in to change notification settings - Fork 16
/
bitrise.yml
416 lines (385 loc) · 16.4 KB
/
bitrise.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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
format_version: "4"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: react-native
app:
envs:
- PROJECT_LOCATION: android
- MODULE: app
opts:
is_expand: false
- VARIANT: ""
opts:
is_expand: false
- BITRISE_PROJECT_PATH: ios/mapeo.xcodeproj
opts:
is_expand: false
- BITRISE_SCHEME: mapeo
opts:
is_expand: false
- BITRISE_EXPORT_METHOD: ad-hoc
opts:
is_expand: false
workflows:
deploy-release:
description: Deploy release builds
before_run:
- primary
envs:
- GRADLE_TASKS: assembleAppRelease assembleAppIntel assembleAppUniversal assembleIccaRelease assembleQaRelease -x bundleAppReleaseJsAndAssets -x bundleAppIntelJsAndAssets -x bundleAppUniversalJsAndAssets -x bundleIccaReleaseJsAndAssets -x bundleQaReleaseJsAndAssets
opts:
is_expand: false
steps:
title: Rename APKs
inputs:
- content: |
#!/usr/bin/env bash
# Renames the apks with the current datetime and a
# reference the git commit and the bitrise build slug
set -eE -o pipefail
shopt -s extdebug
# Split the path_list variable by | into an array
IFS='|' read -r -a paths <<< "$BITRISE_APK_PATH_LIST"
new_paths=()
for path in "${paths[@]}"
do
# Just the path portion
dir="${path%/*}"
# Just the filename
filename="${path##*/}"
# Add version name
filename="${filename/mapeo-/mapeo-v$ANDROID_VERSION_NAME-}"
# Uppercase flavor or remove
filename="${filename/-qa-/-QA-}"
filename="${filename/-icca-/-ICCA-}"
filename="${filename/-app-/-}"
filename="${filename/-release/}"
# Construct path with new filename
new_path="${dir}/${filename}"
mv "$path" "$new_path"
echo "Moved ${path} --> ${new_path}"
new_paths+=("$new_path")
done
# Join the path_list array into a string separated by | char
IFS='|' eval 'NEW_APK_PATH_LIST="${new_paths[*]}"'
# Save the variable to the env so it is accessible in other build steps
envman add --key BITRISE_APK_PATH_LIST --value "$NEW_APK_PATH_LIST"
- [email protected]: {}
title: Set APK path variables
inputs:
- content: |
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
echo "SOURCE_DIR = ${BITRISE_SOURCE_DIR}"
RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep -E mapeo-v[0-9]+\.[0-9]+\.[0-9]+\.apk)
UNIVERSAL_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*-universal\.apk)
ICCA_RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*-ICCA\.apk)
INTEL_RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*-intel\.apk)
QA_RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*-QA\.apk)
envman add --key RELEASE_APK_PATH --value "$RELEASE_APK_PATH"
envman add --key UNIVERSAL_APK_PATH --value "$UNIVERSAL_APK_PATH"
envman add --key ICCA_RELEASE_APK_PATH --value "$ICCA_RELEASE_APK_PATH"
envman add --key INTEL_RELEASE_APK_PATH --value "$INTEL_RELEASE_APK_PATH"
envman add --key QA_RELEASE_APK_PATH --value "$QA_RELEASE_APK_PATH"
title: Upload APK for Arm
inputs:
- aws_access_key: $AWS_ACCESS_KEY_ID
- aws_secret_key: $AWS_SECRET_ACCESS_KEY
- bucket_name: $AWS_S3_BUCKET_NAME
- path_in_bucket: release/v${VERSION_NAME}
- file_path: $RELEASE_APK_PATH
title: Update download URL for release
inputs:
- content: |-
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
node ./scripts/gh-pages-redirect.js /latest https://mapeo-apks.s3.amazonaws.com/release/v${VERSION_NAME}/${RELEASE_APK_PATH##*/}
title: Upload universal (all ABIs) APK
is_skippable: true
inputs:
- aws_access_key: $AWS_ACCESS_KEY_ID
- aws_secret_key: $AWS_SECRET_ACCESS_KEY
- bucket_name: $AWS_S3_BUCKET_NAME
- path_in_bucket: release/v${VERSION_NAME}
- file_path: $UNIVERSAL_APK_PATH
title: Upload APK for ICCA (Arm)
is_skippable: true
inputs:
- aws_access_key: $AWS_ACCESS_KEY_ID
- aws_secret_key: $AWS_SECRET_ACCESS_KEY
- bucket_name: $AWS_S3_BUCKET_NAME
- path_in_bucket: release-ICCA
- file_path: $ICCA_RELEASE_APK_PATH
title: Update download URL for ICCA
is_skippable: true
inputs:
- content: |-
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
node ./scripts/gh-pages-redirect.js /icca/latest https://mapeo-apks.s3.amazonaws.com/release-ICCA/${ICCA_RELEASE_APK_PATH##*/}
inputs:
- username: $GITHUB_USERNAME
- name: $BITRISE_GIT_TAG
- draft: "no"
- files_to_upload: $RELEASE_APK_PATH
- body: See [changelog](https://github.com/digidem/mapeo-mobile/blob/develop/CHANGELOG.md) for a detailed list of changes
- api_token: $GITHUB_TOKEN
inputs:
- service_account_json_key_path: $BITRISEIO_SERVICE_ACCOUNT_JSON_KEY_URL
- track: $GOOGLE_PLAY_TRACK
- app_path: $RELEASE_APK_PATH|$INTEL_RELEASE_APK_PATH
- package_name: $GOOGLE_PLAY_PACKAGE_NAME
meta:
bitrise.io: null
stack: linux-docker-android
deploy-release-candidate:
description: Deploy beta versions for testing
before_run:
- primary
envs:
- GRADLE_TASKS: assembleAppRelease assembleIccaRelease assembleQaRelease -x bundleAppReleaseJsAndAssets -x bundleIccaReleaseJsAndAssets -x bundleQaReleaseJsAndAssets
opts:
is_expand: false
steps:
title: Rename APKs
inputs:
- content: |
#!/usr/bin/env bash
# Renames the apks with the current datetime and a
# reference the git commit and the bitrise build slug
set -eE -o pipefail
shopt -s extdebug
# Split the path_list variable by | into an array
IFS='|' read -r -a paths <<< "$BITRISE_APK_PATH_LIST"
new_paths=()
for path in "${paths[@]}"
do
# Just the path portion
dir="${path%/*}"
# Just the filename
filename="${path##*/}"
# Add version name
filename="${filename/mapeo-/mapeo-v$ANDROID_VERSION_NAME.$BITRISE_BUILD_NUMBER-}"
# Uppercase flavor or remove
filename="${filename/-qa-/-QA-}"
filename="${filename/-icca-/-ICCA-}"
filename="${filename/-app-/-}"
filename="${filename/-release/}"
# Construct path with new filename
new_path="${dir}/${filename}"
mv "$path" "$new_path"
echo "Moved ${path} --> ${new_path}"
new_paths+=("$new_path")
done
# Join the path_list array into a string separated by |
IFS='|' eval 'NEW_APK_PATH_LIST="${new_paths[*]}"'
# Save the variable to the env so it is accessible in other build steps
envman add --key BITRISE_APK_PATH_LIST --value "$NEW_APK_PATH_LIST"
title: Set APK path variables
inputs:
- content: |
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*[0-9]\.apk)
QA_RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*QA\.apk)
ICCA_RELEASE_APK_PATH=$(echo -n "${BITRISE_APK_PATH_LIST//|/$'\n'}" | grep mapeo-.*ICCA\.apk)
envman add --key RELEASE_APK_PATH --value "$RELEASE_APK_PATH"
envman add --key QA_RELEASE_APK_PATH --value "$QA_RELEASE_APK_PATH"
envman add --key ICCA_RELEASE_APK_PATH --value "$ICCA_RELEASE_APK_PATH"
- [email protected]: {}
title: Upload QA variant
is_skippable: true
inputs:
- aws_access_key: $AWS_ACCESS_KEY_ID
- aws_secret_key: $AWS_SECRET_ACCESS_KEY
- bucket_name: $AWS_S3_BUCKET_NAME
- path_in_bucket: release-candidates/v${VERSION_NAME}
- file_path: $QA_RELEASE_APK_PATH
title: Upload Release variant
is_skippable: true
inputs:
- aws_access_key: $AWS_ACCESS_KEY_ID
- aws_secret_key: $AWS_SECRET_ACCESS_KEY
- bucket_name: $AWS_S3_BUCKET_NAME
- path_in_bucket: release-candidates/v${VERSION_NAME}
- file_path: $RELEASE_APK_PATH
title: Upload ICCA variant
is_skippable: true
inputs:
- aws_access_key: $AWS_ACCESS_KEY_ID
- aws_secret_key: $AWS_SECRET_ACCESS_KEY
- bucket_name: $AWS_S3_BUCKET_NAME
- path_in_bucket: release-candidates/v${VERSION_NAME}
- file_path: $ICCA_RELEASE_APK_PATH
meta:
bitrise.io: null
stack: linux-docker-android
noop: {}
primary:
description: Build Android apk & aab
steps:
- cache-pull@2: {}
inputs:
- node_version: " "
title: Update npm
inputs:
- command: install -g --force npm@^6.13
title: npm ci
inputs:
- npm_version: ""
- command: ci
title: Download Release keystore
run_if: '{{getenv "BITRISEIO_ANDROID_KEYSTORE_URL" | ne ""}}'
inputs:
- destination: $PROJECT_LOCATION/app/mapeo-release-key.keystore
- source: $BITRISEIO_ANDROID_KEYSTORE_URL
title: Create .env file
inputs:
- content: |
#!/bin/bash
echo "MAPBOX_ACCESS_TOKEN=$MAPBOX_ACCESS_TOKEN" >> .env
title: Update SDK components
inputs:
- content: |
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
ANDROID_NDK_VERSION='21.4.7075529'
echo '### User Sources for Android SDK Manager' > $HOME/.android/repositories.cfg
yes | sdkmanager --licenses
sdkmanager --update | grep -v = || true
# Remove NDK r22 (can cause builds to fail)
rm -rf $ANDROID_HOME/ndk/22*
sdkmanager --install "ndk;${ANDROID_NDK_VERSION}"
echo "Updated to latest SDK:"
sdkmanager --list
echo "Downloading correct cmake version"
rm -rf /usr/local/share/android-sdk/cmdline-tools/latest/
mkdir /usr/local/share/android-sdk/cmdline-tools/latest/
mkdir /usr/local/share/android-sdk/cmdline-tools/latest/bin/
ln -s /usr/local/share/android-sdk/cmdline-tools/cmdline-tools/bin/sdkmanager /usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager
/usr/local/share/android-sdk/cmdline-tools/latest/bin/sdkmanager --licenses
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "cmake;3.10.2.4988404"
echo "cmake;3.10.2.4988404 downloaded"
title: Build nodejs backend
inputs:
- file_path: scripts/build-backend.sh
title: Build translations
inputs:
- npm_version: ""
- command: run build:translations
title: Set version name & code
inputs:
- content: |
#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
VERSION_NAME=`node -p "require('./package.json').version"`
if [[ "$BITRISE_GIT_BRANCH" == "deploy" || -n "$BITRISE_GIT_TAG" ]]; then
# This is a push to deploy event or a tag event
# Pushing a tag to Github for some reason triggers this workflow with $BITRISE_GIT_BRANCH set to master
ANDROID_VERSION_NAME="${VERSION_NAME}"
elif [[ "${BITRISE_GIT_BRANCH%/*}" == "release" || "${BITRISE_GIT_BRANCH%/*}" == "hotfix" ]]; then
# This is a push to a branch matching `release/*`, so we build a release candidate
ANDROID_VERSION_NAME="${VERSION_NAME}-RC"
if [ -n "${BITRISE_GIT_COMMIT}" ]; then
ANDROID_VERSION_NAME+="+${BITRISE_GIT_COMMIT:0:7}"
fi
else
# This is an internal build
ANDROID_VERSION_NAME="${VERSION_NAME}"
if [ -n "${BITRISE_PULL_REQUEST}" ]; then
ANDROID_VERSION_NAME+="-PR${BITRISE_PULL_REQUEST}"
else
ANDROID_VERSION_NAME+="-internal"
fi
if [ -n "${BITRISE_GIT_COMMIT}" ]; then
ANDROID_VERSION_NAME+="+${BITRISE_GIT_COMMIT:0:7}"
fi
fi
envman add --key VERSION_NAME --value $VERSION_NAME
envman add --key ANDROID_VERSION_NAME --value $ANDROID_VERSION_NAME
envman add --key ANDROID_VERSION_CODE --value $BITRISE_BUILD_NUMBER
title: Prepare JS bundles
inputs:
- runner: /usr/bin/env node
- file_path: scripts/prepare-js-bundles-android.js
is_always_run: true
inputs:
- is_create_path: "false"
- path: $PROJECT_LOCATION
inputs:
- gradlew_path: ./gradlew
- app_file_exclude_filter: |-
*unaligned.apk
*Test*.apk
mapeo-debug*.apk
fake.apk
- cache_level: all
- gradle_task: $GRADLE_TASKS
inputs:
- is_create_path: "false"
- path: ..
- cache-push@2: {}
- script@1:
title: Check APK assets
inputs:
- content: |
#!/usr/bin/env bash
# fail if any commands fails
set -e
# make pipelines' return status equal the last command to exit with a non-zero status, or zero if all commands exit successfully
set -o pipefail
# debug log
shopt -s extdebug
# Split the path_list variable by | into an array
IFS='|' read -r -a paths <<< "$BITRISE_APK_PATH_LIST"
for path in "${paths[@]}"
do
node scripts/check-apk-assets.js "${path}"
done
meta:
bitrise.io: null
stack: linux-docker-android