forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFastfile
382 lines (332 loc) · 11.5 KB
/
Fastfile
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
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
require 'ostruct'
skip_docs
opt_out_usage
KEY_GRADLE_APK_PATH = "apkPath"
KEY_S3_APK_PATH = "s3APKPath"
KEY_GRADLE_AAB_PATH = "aabPath"
KEY_IPA_PATH = "ipaPath"
KEY_DSYM_PATH = "dsymPath"
# Export environment variables to GITHUB_ENV
# If there's no GITHUB_ENV file set in the env, then this is a no-op
def exportEnvVars(env_vars)
github_env_path = ENV['GITHUB_ENV']
if github_env_path && File.exist?(github_env_path)
puts "Saving environment variables in GITHUB_ENV..."
File.open(github_env_path, "a") do |file|
env_vars.each do |key, value|
puts "#{key}=#{value}"
file.puts "#{key}=#{value}"
end
end
end
end
def setGradleOutputsInEnv()
puts "Saving Android build outputs in env..."
env_vars = {
KEY_GRADLE_APK_PATH => lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
}
if lane_context.key?(SharedValues::GRADLE_AAB_OUTPUT_PATH)
env_vars[KEY_GRADLE_AAB_PATH] = lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]
end
exportEnvVars(env_vars)
end
def setIOSBuildOutputsInEnv()
puts "Saving iOS build outputs in env..."
exportEnvVars({
KEY_IPA_PATH => lane_context[SharedValues::IPA_OUTPUT_PATH],
KEY_DSYM_PATH => lane_context[SharedValues::DSYM_OUTPUT_PATH],
})
end
platform :android do
desc "Generate a production AAB"
lane :build do
ENV["ENVFILE"]=".env.production"
gradle(
project_dir: './android',
task: 'bundle',
flavor: 'Production',
build_type: 'Release',
)
setGradleOutputsInEnv()
end
desc "Generate a new local APK"
lane :build_local do
ENV["ENVFILE"]=".env.production"
gradle(
project_dir: './android',
task: 'assemble',
flavor: 'Production',
build_type: 'Release',
)
setGradleOutputsInEnv()
end
desc "Generate a new local APK for e2e testing"
lane :build_e2e do
ENV["ENVFILE"]="tests/e2e/.env.e2e"
ENV["ENTRY_FILE"]="src/libs/E2E/reactNativeLaunchingTest.ts"
ENV["E2E_TESTING"]="true"
gradle(
project_dir: './android',
task: ':app:assemble',
flavor: 'e2e',
build_type: 'Release',
)
setGradleOutputsInEnv()
end
lane :build_e2eDelta do
ENV["ENVFILE"]="tests/e2e/.env.e2edelta"
ENV["ENTRY_FILE"]="src/libs/E2E/reactNativeLaunchingTest.ts"
ENV["E2E_TESTING"]="true"
gradle(
project_dir: './android',
task: ':app:assemble',
flavor: 'e2edelta',
build_type: 'Release',
)
setGradleOutputsInEnv()
end
desc "Build AdHoc testing build"
lane :build_adhoc do
ENV["ENVFILE"]=".env.adhoc"
gradle(
project_dir: './android',
task: 'assemble',
flavor: 'Adhoc',
build_type: 'Release',
)
setGradleOutputsInEnv()
end
desc "Upload build to S3"
lane :upload_s3 do
puts "APK path: #{ENV[KEY_GRADLE_APK_PATH]}"
aws_s3(
access_key: ENV['S3_ACCESS_KEY'],
secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET'],
region: ENV['S3_REGION'],
apk: ENV[KEY_GRADLE_APK_PATH],
app_directory: "android/#{ENV['PULL_REQUEST_NUMBER']}",
)
puts "Saving S3 outputs in env..."
exportEnvVars({
KEY_S3_APK_PATH => lane_context[SharedValues::S3_HTML_OUTPUT_PATH],
})
end
desc "Upload app to Google Play for internal testing"
lane :upload_google_play_internal do
# Google is very unreliable, so we retry a few times
ENV["SUPPLY_UPLOAD_MAX_RETRIES"]="5"
upload_to_play_store(
package_name: "com.expensify.chat",
json_key: './android/app/android-fastlane-json-key.json',
aab: ENV[KEY_GRADLE_AAB_PATH],
track: 'internal',
rollout: '1.0'
)
end
desc "Deploy app to Google Play production"
lane :upload_google_play_production do
# Google is very unreliable, so we retry a few times
ENV["SUPPLY_UPLOAD_MAX_RETRIES"]="5"
google_play_track_version_codes(
package_name: "com.expensify.chat",
json_key: './android/app/android-fastlane-json-key.json',
track: 'internal'
)
upload_to_play_store(
package_name: "com.expensify.chat",
json_key: './android/app/android-fastlane-json-key.json',
version_code: ENV["VERSION"].to_i,
track: 'internal',
track_promote_to: 'production',
rollout: '1.0',
skip_upload_apk: true,
skip_upload_aab: true,
skip_upload_metadata: true,
skip_upload_changelogs: true,
skip_upload_images: true,
skip_upload_screenshots: true
)
end
end
def setupIOSSigningCertificate()
require 'securerandom'
keychain_password = SecureRandom.uuid
create_keychain(
name: "ios-build.keychain",
password: keychain_password,
default_keychain: "true",
unlock: "true",
timeout: "3600",
add_to_search_list: "true"
)
import_certificate(
certificate_path: "./ios/Certificates.p12",
keychain_name: "ios-build.keychain",
keychain_password: keychain_password
)
end
platform :ios do
desc "Build an iOS production build"
lane :build do
ENV["ENVFILE"]=".env.production"
setupIOSSigningCertificate()
install_provisioning_profile(
path: "./ios/NewApp_AppStore.mobileprovision"
)
install_provisioning_profile(
path: "./ios/NewApp_AppStore_Notification_Service.mobileprovision"
)
build_app(
workspace: "./ios/NewExpensify.xcworkspace",
scheme: "New Expensify",
output_name: "New Expensify.ipa",
export_options: {
provisioningProfiles: {
"com.chat.expensify.chat" => "(NewApp) AppStore",
"com.chat.expensify.chat.NotificationServiceExtension" => "(NewApp) AppStore: Notification Service",
},
manageAppVersionAndBuildNumber: false
}
)
setIOSBuildOutputsInEnv()
end
desc "Build an unsigned iOS production build"
lane :build_unsigned do
ENV["ENVFILE"]=".env.production"
build_app(
workspace: "./ios/NewExpensify.xcworkspace",
scheme: "New Expensify"
)
setIOSBuildOutputsInEnv()
end
desc "Build AdHoc app for testing"
lane :build_adhoc do
ENV["ENVFILE"]=".env.adhoc"
setupIOSSigningCertificate()
install_provisioning_profile(
path: "./ios/NewApp_AdHoc.mobileprovision"
)
install_provisioning_profile(
path: "./ios/NewApp_AdHoc_Notification_Service.mobileprovision"
)
build_app(
workspace: "./ios/NewExpensify.xcworkspace",
skip_profile_detection: true,
scheme: "New Expensify AdHoc",
export_method: "ad-hoc",
export_options: {
method: "ad-hoc",
provisioningProfiles: {
"com.expensify.chat.adhoc" => "(NewApp) AdHoc",
"com.expensify.chat.adhoc.NotificationServiceExtension" => "(NewApp) AdHoc: Notification Service",
},
manageAppVersionAndBuildNumber: false
}
)
setIOSBuildOutputsInEnv()
end
desc "Upload app to S3"
lane :upload_s3 do
puts "IPA path: #{ENV[KEY_IPA_PATH]}"
aws_s3(
access_key: ENV['S3_ACCESS_KEY'],
secret_access_key: ENV['S3_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET'],
region: ENV['S3_REGION'],
ipa: ENV[KEY_IPA_PATH],
app_directory: "ios/#{ENV['PULL_REQUEST_NUMBER']}",
)
sh("echo '{\"ipa_path\": \"#{lane_context[SharedValues::S3_IPA_OUTPUT_PATH]}\",\"html_path\": \"#{lane_context[SharedValues::S3_HTML_OUTPUT_PATH]}\"}' > ../ios_paths.json")
end
desc "Upload app to TestFlight"
lane :upload_testflight do
upload_to_testflight(
api_key_path: "./ios/ios-fastlane-json-key.json",
distribute_external: true,
notify_external_testers: true,
changelog: "Thank you for beta testing New Expensify, this version includes bug fixes and improvements.",
groups: ["Beta"],
demo_account_required: true,
beta_app_review_info: {
contact_email: ENV["APPLE_CONTACT_EMAIL"],
contact_first_name: "Andrew",
contact_last_name: "Gable",
contact_phone: ENV["APPLE_CONTACT_PHONE"],
demo_account_name: ENV["APPLE_DEMO_EMAIL"],
demo_account_password: ENV["APPLE_DEMO_PASSWORD"],
notes: "1. In the Expensify app, enter the email '[email protected]'. This will trigger a sign-in link to be sent to '[email protected]'
2. Navigate to https://account.proton.me/login, log into Proton Mail using '[email protected]' as email and the password associated with '[email protected]', provided above
3. Once logged into Proton Mail, navigate to your inbox and locate the email triggered in step 1. The email subject should be 'Your magic sign-in link for Expensify'
4. Open the email and copy the 6-digit sign-in code provided within
5. Return to the Expensify app and enter the copied 6-digit code in the designated login field"
}
)
puts "dsym path: #{ENV[KEY_DSYM_PATH]}"
upload_symbols_to_crashlytics(
app_id: "1:921154746561:ios:216bd10ccc947659027c40",
dsym_path: ENV[KEY_DSYM_PATH],
gsp_path: "./ios/GoogleService-Info.plist",
binary_path: "./ios/Pods/FirebaseCrashlytics/upload-symbols"
)
end
desc "Submit app to App Store Review"
lane :submit_for_review do
deliver(
api_key_path: "./ios/ios-fastlane-json-key.json",
# Skip HTMl report verification
force: true,
# VERSION will be set to the full build_number e.g. '1.0.92.0'
build_number: ENV["VERSION"],
# app_version needs to be set to the short version, without the last digit e.g. '1.0.92'
app_version: ENV["VERSION"].rpartition(".")[0],
# We want to submit the version for Apple to review
submit_for_review: true,
# We want to release the app as soon as it's approved
automatic_release: true,
# We need to upload metadata to upload the release notes which is required for rach new version
skip_metadata: false,
# We do not want to upload any screenshots
skip_screenshots: true,
# We do not have any binary to upload as it's already in TestFlight
skip_binary_upload: true,
# Reject the current build if there is one in review
reject_if_possible: true,
# We do not want to reset the ratings
reset_ratings: false,
# Precheck cannot check for in app purchases with the API key we use
precheck_include_in_app_purchases: false,
submission_information: {
# We currently do not use idfa: https://developer.apple.com/app-store/user-privacy-and-data-use/
add_id_info_uses_idfa: false,
# We do not need any additional compliance
export_compliance_compliance_required: false,
# We do not use any encrpytion
export_compliance_encryption_updated: false,
export_compliance_app_type: nil,
export_compliance_uses_encryption: false,
export_compliance_is_exempt: false,
export_compliance_contains_third_party_cryptography: false,
export_compliance_contains_proprietary_cryptography: false,
# We do not show any third party content
content_rights_contains_third_party_content: false,
# Indicate that our key has admin permissions
content_rights_has_rights: true
},
release_notes: {
'en-US' => "Improvements and bug fixes"
}
)
end
end