forked from expo/expo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
541 lines (520 loc) · 18.8 KB
/
config.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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
version: 2.1
parameters:
release:
type: boolean
default: false
release_google:
type: boolean
default: false
release_apk:
type: boolean
default: false
release_simulator:
type: boolean
default: false
shell_ios:
type: boolean
default: false
shell_android:
type: boolean
default: false
expo_client:
type: boolean
default: false
orbs:
job-status-change: expo/[email protected]
slack-job-status-notification: expo/[email protected]
shallow-checkout: expo/[email protected]
commands:
skip_unless_changed:
parameters:
workflow_name:
type: string
paths:
type: string
steps:
- run:
name: Skip job if no relevant changes since last successful build on branch
command: |
export GIT_PAGER=cat # Prevents git commands hanging on mac executors
if [ "$CIRCLE_BRANCH" = "" ]; then
echo "Can't determine branch. Continuing the job."
else
echo "Looking for previous successful ${CIRCLE_JOB} jobs for branch ${CIRCLE_BRANCH}"
LAST_SUCCESSFUL_COMMIT_ON_BRANCH=$(bin/circle-last-successful-commit "github/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" "<< parameters.workflow_name >>/${CIRCLE_JOB}" "${CIRCLE_BRANCH}" || true)
GIT_BASE_REVISION=<< pipeline.git.base_revision >>
if [[ "${LAST_SUCCESSFUL_COMMIT_ON_BRANCH}" == "" ]]; then
echo "No previous successful job detected for branch $CIRCLE_BRANCH"
echo "The job will be skipped unless this branch introduces relevant changes."
else
echo "Previous successful build found for commit $LAST_SUCCESSFUL_COMMIT_ON_BRANCH"
if git show --pretty=%H -q $LAST_SUCCESSFUL_COMMIT_ON_BRANCH; then
GIT_BASE_REVISION=$LAST_SUCCESSFUL_COMMIT_ON_BRANCH
else
echo "Commit not found in repo, it might have been rebased out of the branch."
fi
fi
if [[ ${GIT_BASE_REVISION} == "" ]]; then
# If a job has never been run on master before, maybe this could happen
echo "No base revision found. Continuing the job."
exit 0
fi
echo "Checking for changes since $GIT_BASE_REVISION touching circle config or << parameters.paths >>:"
if git log --name-status --exit-code --format=oneline "$GIT_BASE_REVISION..$CIRCLE_SHA1" -- .circleci/config.yml << parameters.paths >>; then
echo "No changes found in watched paths. Ending job."
circleci-agent step halt
else
echo "Changes found in watched paths. Continuing the job."
fi
fi
install_yarn:
steps:
- run: curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
- run: curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
- run: echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- run: sudo apt update && sudo apt install yarn
setup_ruby:
steps:
- run:
name: install chruby if necessary
command: |
if ! which chruby > /dev/null; then
VERSION=0.3.9
curl --silent --location "https://github.com/postmodern/chruby/archive/v$VERSION.tar.gz" --output chruby.tar.gz
tar -xzvf chruby.tar.gz
rm chruby.tar.gz
cd "chruby-$VERSION"
sudo make install
echo "source /usr/local/share/chruby/chruby.sh" >> $BASH_ENV
fi
- restore_cache:
key: ruby-v1-{{ arch }}-{{ checksum ".ruby-version" }}
- run:
name: install ruby if necessary
command: |
if ! chruby $(cat .ruby-version); then
VERSION=0.7.0
curl --silent --location "https://github.com/postmodern/ruby-install/archive/v$VERSION.tar.gz" --output ruby-install.tar.gz
tar -xzvf ruby-install.tar.gz
rm ruby-install.tar.gz
"ruby-install-$VERSION/bin/ruby-install" --no-reinstall ruby $(cat .ruby-version)
rm -r "ruby-install-$VERSION"
fi
- save_cache:
key: ruby-v1-{{ arch }}-{{ checksum ".ruby-version" }}
paths:
- ~/.rubies
- run: echo "chruby $(cat .ruby-version)" >> $BASH_ENV
bundle_install:
steps:
- setup_ruby
# replicate direnv "layout ruby"
- run: echo 'export BUNDLE_BIN=$CIRCLE_WORKING_DIRECTORY/.direnv/bin' >> $BASH_ENV
- run: echo 'export GEM_HOME=$CIRCLE_WORKING_DIRECTORY/.direnv/ruby' >> $BASH_ENV
- run: mkdir -p $BUNDLE_BIN; mkdir -p $GEM_HOME
- run: echo 'export PATH=$PATH:$BUNDLE_BIN:$GEM_HOME/bin' >> $BASH_ENV
- restore_cache:
key: gems-v1-{{ arch }}-{{ checksum "Gemfile.lock" }}
- run: gem install bundler -v=2.1.4
- run: bundle install
- save_cache:
key: gems-v1-{{ arch }}-{{ checksum "Gemfile.lock" }}
paths:
- .direnv/ruby
setup:
steps:
- checkout
- run: echo 'export PATH=$PATH:$CIRCLE_WORKING_DIRECTORY/bin' >> $BASH_ENV
- run: echo '--frozen-lockfile true' >> ~/.yarnrc
decrypt_secrets_if_possible:
steps:
- run:
name: Decrypt secrets
command: |
if [[ ${EXPO_GIT_CRYPT_KEY_BASE64:-unset} = unset ]]; then
echo 'git-crypt key not present in environment' && exit 0
fi
if brew --version; then
brew install git-crypt
else
sudo apt-get install git-crypt
fi
git crypt unlock <(echo $EXPO_GIT_CRYPT_KEY_BASE64 | base64 --decode)
update_submodules:
steps:
- run:
name: Update submodules
command: git submodule update --init
fetch_cocoapods_specs:
steps:
- run:
name: Fetch CocoaPods
command: curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
git_lfs_pull:
steps:
- restore_cache:
keys:
- gitlfs-{{ arch }}
- gitlfs
- run:
name: Pull Git LFS files
command: git lfs pull
- save_cache:
key: gitlfs-{{ arch }}
paths:
# Save the LFS cache directory to save GitHub bandwidth
- .git/lfs
restore_yarn_cache:
parameters:
working_directory:
type: string
default: .
steps:
- restore_cache:
key: yarn-v1-{{ arch }}-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
save_yarn_cache:
parameters:
working_directory:
type: string
default: .
steps:
- save_cache:
key: yarn-v1-{{ arch }}-{{ checksum "<< parameters.working_directory >>/yarn.lock" }}
paths:
- /usr/local/share/.cache/yarn
- ~/Library/Caches/Yarn
restore_gradle_cache:
steps:
- restore_cache:
key: jars-v2-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}
save_gradle_cache:
steps:
- save_cache:
key: jars-v2-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}
paths:
- ~/.gradle
yarn:
parameters:
command:
type: string
default: install
working_directory:
type: string
max_tries:
type: integer
default: 1
steps:
- run:
name: yarn << parameters.command >> (<< parameters.working_directory >>)
working_directory: << parameters.working_directory >>
command: for i in {1..<< parameters.max_tries >>}; do ((i > 1)) && sleep 5; yarn << parameters.command >> && break; done
yarn_install:
parameters:
working_directory:
type: string
steps:
- yarn:
command: 'install'
working_directory: << parameters.working_directory >>
max_tries: 5
yarn_restore_and_install:
parameters:
working_directory:
type: string
steps:
- restore_yarn_cache:
working_directory: << parameters.working_directory >>
- yarn_install:
working_directory: << parameters.working_directory >>
- save_yarn_cache:
working_directory: << parameters.working_directory >>
executors:
android:
docker:
- image: circleci/android:api-29-ndk
resource_class: xlarge
js:
docker:
- image: circleci/node:lts-buster
resource_class: small
mac:
macos: # https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions
xcode: '11.4.0'
working_directory: /Users/distiller/project
environment:
BASH_ENV: /Users/distiller/.bash_profile
# Homebrew settings
HOMEBREW_NO_INSTALL_CLEANUP: 1
HOMEBREW_NO_AUTO_UPDATE: 1
# fastlane complains if these are not set
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
FASTLANE_SKIP_UPDATE_CHECK: 1
FASTLANE_DISABLE_COLORS: 1
CI: 1
# Prevent automatic download of LFS files
GIT_LFS_SKIP_SMUDGE: 1
workflows:
release_simulator:
when: << pipeline.parameters.release_simulator >>
jobs:
- client_ios
- client_ios_simulator_release:
requires:
- client_ios
release_google:
when: << pipeline.parameters.release_google >>
jobs:
- client_android
- client_android_release_google_play:
requires:
- client_android
release_apk:
when: << pipeline.parameters.release_apk >>
jobs:
- client_android
- client_android_apk_release:
requires:
- client_android
shell_app_ios:
when: << pipeline.parameters.shell_ios >>
jobs:
- shell_app_ios_build:
upload: true
shell_app_android:
when: << pipeline.parameters.shell_android >>
jobs:
- shell_app_android_build
expo_client_build:
when: << pipeline.parameters.expo_client >>
jobs:
- expo_client_build
jobs:
client_ios:
executor: mac
steps:
- setup
- skip_unless_changed:
workflow_name: client
paths: tools secrets ios fastlane Gemfile .ruby-version
- update_submodules
- git_lfs_pull
- decrypt_secrets_if_possible
- run:
name: Generate dynamic macros
command: expotools ios-generate-dynamic-macros
- bundle_install
- run:
name: Build
command: fastlane ios create_simulator_build
- persist_to_workspace:
root: ios
paths:
- simulator-build
- store_artifacts:
path: ~/Library/Logs/fastlane/
- job-status-change/status
- slack-job-status-notification/notify:
only_for_branches: master sdk-*
slack_webhook: $SLACK_IOS_WEBHOOK
client_ios_simulator_release:
executor: mac
steps:
- setup
- update_submodules
- git_lfs_pull
- decrypt_secrets_if_possible
- yarn_restore_and_install:
working_directory: ~/project/tools
- attach_workspace:
at: ios/simulator-build
- run: expotools client-build --platform ios --release
expo_client_build:
executor: mac
steps:
- setup
- update_submodules
- git_lfs_pull
- fetch_cocoapods_specs
- bundle_install
- run:
name: Generate dynamic macros
# Remove GoogleServices-Info because it has been stripped of all our secret keys
# Will be generated later in the build process if the user provides their own ios.googleServicesFile
command: expotools ios-generate-dynamic-macros --skip-template=GoogleService-Info.plist
- run: brew install awscli
- run:
name: Build Expo Client and upload tarball
command: |
export TARBALL=ios-expo-client-$CIRCLE_SHA1.tar.gz
fastlane ios create_expo_client_build
tar \
-C ~/project \
-zcf "/tmp/$TARBALL" \
expo-client-build/Exponent.xcarchive \
ios
~/project/bin/aws s3 cp --acl public-read "/tmp/$TARBALL" s3://exp-artifacts
- run:
name: Expo Client shell app url
command: echo "Expo Client shell app tarball uploaded to s3://exp-artifacts/ios-expo-client-$CIRCLE_SHA1.tar.gz"
shell_app_ios_build:
executor: mac
parameters:
upload:
type: boolean
default: true
steps:
- setup
- update_submodules
- git_lfs_pull
- fetch_cocoapods_specs
- run:
name: Generate dynamic macros
command: expotools ios-generate-dynamic-macros
- run: npm install gulp-cli -g
- run:
name: Build iOS shell app for real devices
no_output_timeout: 30m
command: expotools ios-shell-app --action build --type archive --verbose true --skipRepoUpdate --shellAppSdkVersion UNVERSIONED
- run:
name: Build iOS shell app for simulators
no_output_timeout: 30m
command: expotools ios-shell-app --action build --type simulator --verbose true --skipRepoUpdate --shellAppSdkVersion UNVERSIONED
- when:
condition: << parameters.upload >>
steps:
- run: brew install awscli
- run:
name: Package and upload release tarball
working_directory: ~/project
no_output_timeout: 40m
command: |
export TARBALL=ios-shell-builder-sdk-latest-$CIRCLE_SHA1.tar.gz
tar \
-zcf "/tmp/$TARBALL" \
package.json \
exponent-view-template \
shellAppBase-builds \
shellAppWorkspaces \
ios
~/project/bin/aws s3 cp --acl public-read "/tmp/$TARBALL" s3://exp-artifacts
echo "Release tarball uploaded to s3://exp-artifacts/$TARBALL"
echo "You can deploy this by updating or creating a new file in https://github.com/expo/turtle/tree/master/shellTarballs/ios"
echo "Then follow the deployment instructions: https://github.com/expo/turtle-deploy"
shell_app_android_build:
executor: android
steps:
- setup
- run: echo 'export S3_URI=s3://exp-artifacts/android-shell-builder-$CIRCLE_SHA1.tar.gz' >> $BASH_ENV
- install_yarn
- yarn_restore_and_install:
working_directory: ~/project/tools
- run:
name: Check that Android packages are up-to-date
command: expotools check-android-packages
- run: sudo apt-get install awscli
- run: |
aws s3 ls $S3_URI || {
./buildAndroidTarballLocally.sh # TODO: put in fastlane?
aws s3 cp --acl public-read artifacts/android-shell-builder.tar.gz $S3_URI
}
echo "Release tarball uploaded to $S3_URI"
echo "You can deploy this by updating or creating a new file in https://github.com/expo/turtle/tree/master/shellTarballs/android"
echo "Then follow the deployment instructions: https://github.com/expo/turtle-deploy"
# Disabled until further notice
# See https://exponent-internal.slack.com/archives/C1QNF5L3C/p1576852692010900
# android_test_suite:
# executor: android
# steps:
# - setup
# - guard_sdk_tests
# - update_submodules
# - yarn_install:
# working_directory: ~/expo # need jsc-android dependency in expokit-npm-package
# - yarn_install:
# working_directory: ~/expo/tools-public
# - restore_gradle_cache
# - run:
# name: Build APK, upload to Device Farm, follow device logs
# command: |
# nix-shell android/shell.nix --pure \
# --keep AWS_ACCESS_KEY_ID \
# --keep AWS_SECRET_ACCESS_KEY \
# --keep SSL_CERT_FILE \
# --keep FASTLANE_SKIP_UPDATE_CHECK \
# --keep FASTLANE_DISABLE_COLORS \
# --keep CI \
# --run "fastlane android devicefarm"
# - save_gradle_cache
client_android:
executor: android
steps:
- setup
- skip_unless_changed:
workflow_name: client
paths: secrets android fastlane Gemfile .ruby-version package.json yarn.lock
- update_submodules
- install_yarn
- yarn_install:
working_directory: ~/project # need jsc-android dependency in expokit-npm-package
- restore_gradle_cache
- decrypt_secrets_if_possible
- bundle_install
- run:
name: Decode release keystore
command: echo $ANDROID_KEYSTORE_B64 | base64 -d > android/app/release-key.jks
- run: fastlane android build build_type:Release
- save_gradle_cache
- persist_to_workspace:
root: android/app/build/outputs
paths:
- apk
- store_artifacts:
path: ~/project/android/app/build/outputs/apk
- store_artifacts: # daemon logs for debugging crashes
path: ~/.gradle/daemon
- job-status-change/status
- slack-job-status-notification/notify:
only_for_branches: master sdk-*
slack_webhook: $SLACK_ANDROID_WEBHOOK
client_android_apk_release:
executor: js
steps:
- setup
- update_submodules
- decrypt_secrets_if_possible
- yarn_restore_and_install:
working_directory: ~/expo/tools
- attach_workspace:
at: android/app/build/outputs/apk
- run: expotools client-build --platform android --release
client_android_release_google_play:
executor: android
steps:
- setup
- attach_workspace:
at: android/app/build/outputs/apk
- bundle_install
- run:
name: Decode release keystore
command: echo $ANDROID_KEYSTORE_B64 | base64 -d > android/app/release-key.jks
- run:
name: Upload APK to Google Play and release to production
working_directory: ~/project
command: fastlane android prod_release
# Disabled until further notice
# See https://exponent-internal.slack.com/archives/C1QNF5L3C/p1576852692010900
# test_suite_publish:
# executor: nix
# steps:
# - setup
# - conditionally_halt:
# # Exclude .git/, node_modules,THIRD-PARTY-LICENSES, LICENSE, docs/, guides/, template-files/, templates/, native-component-list/, bare-expo/, and every `.md` file
# exclude: '^(.*)(\/(.git\/|LICENSE|THIRD-PARTY-LICENSES|node_modules|docs|guides|scripts|template-files|templates|native-component-list|bare-expo).*|\.md$)'
# search_depth: 1
# - update_submodules
# - decrypt_secrets_if_possible
# - run:
# name: Publish
# working_directory: ~/expo/apps/test-suite
# command: ./publish.sh