3
3
SENTRY_ORG_SLUG = 'a8c'
4
4
SENTRY_PROJECT_SLUG_WORDPRESS = 'wordpress-ios'
5
5
SENTRY_PROJECT_SLUG_JETPACK = 'jetpack-ios'
6
- APPCENTER_OWNER_NAME = 'automattic'
7
- APPCENTER_OWNER_TYPE = 'organization'
6
+
7
+ FIREBASE_APP_CONFIG_WORDPRESS = {
8
+ app_name : 'WordPress' ,
9
+ app_icon : ':wordpress:' , # Use Buildkite emoji
10
+ app_id : '1:124902176124:ios:ff9714d0b53aac821620f9' ,
11
+ testers_group : 'wordpress-ios---prototype-builds'
12
+ } . freeze
13
+
14
+ FIREBASE_APP_CONFIG_JETPACK = {
15
+ app_name : 'Jetpack' ,
16
+ app_icon : ':jetpack:' , # Use Buildkite emoji
17
+ app_id : '1:124902176124:ios:121c494b82f283ec1620f9' ,
18
+ testers_group : 'jetpack-ios---prototype-builds' ,
19
+ } . freeze
20
+
8
21
CONCURRENT_SIMULATORS = 2
9
22
10
23
# Shared options to use when invoking `build_app` (`gym`).
251
264
)
252
265
end
253
266
254
- # Builds the WordPress app for a Prototype Build ("WordPress Alpha" scheme), and uploads it to App Center
267
+ # Builds the WordPress app for a Prototype Build ("WordPress Alpha" scheme), and uploads it to Firebase App Distribution
255
268
#
256
269
# @called_by CI
257
270
#
264
277
build_and_upload_prototype_build (
265
278
scheme : 'WordPress Alpha' ,
266
279
output_app_name : 'WordPress Alpha' ,
267
- appcenter_app_name : 'WPiOS-One-Offs' ,
268
- app_icon : ':wordpress:' , # Use Buildkite emoji
280
+ firebase_app_config : FIREBASE_APP_CONFIG_WORDPRESS ,
269
281
sentry_project_slug : SENTRY_PROJECT_SLUG_WORDPRESS ,
270
282
app_identifier : 'org.wordpress.alpha'
271
283
)
272
284
end
273
285
274
- # Builds the Jetpack app for a Prototype Build ("Jetpack" scheme), and uploads it to App Center
286
+ # Builds the Jetpack app for a Prototype Build ("Jetpack" scheme), and uploads it to Firebase App Distribution
275
287
#
276
288
# @called_by CI
277
289
#
284
296
build_and_upload_prototype_build (
285
297
scheme : 'Jetpack' ,
286
298
output_app_name : 'Jetpack Alpha' ,
287
- appcenter_app_name : 'jetpack-installable-builds' ,
288
- app_icon : ':jetpack:' , # Use Buildkite emoji
299
+ firebase_app_config : FIREBASE_APP_CONFIG_JETPACK ,
289
300
sentry_project_slug : SENTRY_PROJECT_SLUG_JETPACK ,
290
301
app_identifier : 'com.jetpack.alpha'
291
302
)
@@ -327,28 +338,23 @@ def generate_prototype_build_number
327
338
end
328
339
end
329
340
330
- # Builds a Prototype Build for WordPress or Jetpack, then uploads it to App Center and comment with a link to it on the PR.
341
+ # Builds a Prototype Build for WordPress or Jetpack, then uploads it to Firebase App Distribution and comment with a link to it on the PR.
331
342
#
332
343
# rubocop:disable Metrics/AbcSize
333
344
# rubocop:disable Metrics/ParameterLists
334
- def build_and_upload_prototype_build ( scheme :, output_app_name :, appcenter_app_name : , app_icon :, sentry_project_slug :, app_identifier :)
345
+ def build_and_upload_prototype_build ( scheme :, output_app_name :, firebase_app_config :, sentry_project_slug :, app_identifier :)
335
346
configuration = 'Release-Alpha'
336
347
337
- # Get the current build version, and update it if needed
338
- version_config_path = File . join ( PROJECT_ROOT_FOLDER , 'config' , 'Version.public.xcconfig' )
339
- versions = Xcodeproj ::Config . new ( File . new ( version_config_path ) ) . to_hash
340
- build_number = generate_prototype_build_number
341
- UI . message ( "Updating build version to #{ build_number } " )
342
- versions [ 'VERSION_LONG' ] = build_number
343
- new_config = Xcodeproj ::Config . new ( versions )
344
- new_config . save_as ( Pathname . new ( version_config_path ) )
348
+ build_number = ENV . fetch ( 'BUILDKITE_BUILD_NUMBER' , '0' )
349
+ pr_or_branch = ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , nil ) &.then { |num | "PR ##{ num } " } || ENV . fetch ( 'BUILDKITE_BRANCH' , nil )
345
350
346
351
# Build
347
352
build_app (
348
353
scheme : scheme ,
349
354
workspace : WORKSPACE_PATH ,
350
355
configuration : configuration ,
351
356
clean : true ,
357
+ xcargs : { VERSION_LONG : build_number , VERSION_SHORT : pr_or_branch } . compact ,
352
358
output_directory : BUILD_PRODUCTS_PATH ,
353
359
output_name : output_app_name ,
354
360
derived_data_path : DERIVED_DATA_PATH ,
@@ -357,21 +363,8 @@ def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_na
357
363
export_options : { **COMMON_EXPORT_OPTIONS , method : 'enterprise' }
358
364
)
359
365
360
- # Upload to App Center
361
- commit = ENV . fetch ( 'BUILDKITE_COMMIT' , 'Unknown' )
362
- pr = ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , nil )
363
- release_notes = <<~NOTES
364
- - Branch: `#{ ENV . fetch ( 'BUILDKITE_BRANCH' , 'Unknown' ) } `\n
365
- - Commit: [#{ commit [ 0 ...7 ] } ](https://github.com/#{ GITHUB_REPO } /commit/#{ commit } )\n
366
- - Pull Request: [##{ pr } ](https://github.com/#{ GITHUB_REPO } /pull/#{ pr } )\n
367
- NOTES
368
-
369
- upload_build_to_app_center (
370
- name : appcenter_app_name ,
371
- file : lane_context [ SharedValues ::IPA_OUTPUT_PATH ] ,
372
- dsym : lane_context [ SharedValues ::DSYM_OUTPUT_PATH ] ,
373
- release_notes : release_notes ,
374
- distribute_to_everyone : false
366
+ upload_build_to_firebase_app_distribution (
367
+ firebase_app_config : FIREBASE_APP_CONFIG_WORDPRESS
375
368
)
376
369
377
370
# Upload dSYMs to Sentry
@@ -388,30 +381,6 @@ def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_na
388
381
build_version : build_number ,
389
382
app_identifier : app_identifier
390
383
)
391
-
392
- # Post PR Comment
393
- comment_body = prototype_build_details_comment (
394
- app_display_name : output_app_name ,
395
- app_icon : app_icon ,
396
- app_center_org_name : APPCENTER_OWNER_NAME ,
397
- metadata : { Configuration : configuration } ,
398
- fold : true
399
- )
400
-
401
- comment_on_pr (
402
- project : GITHUB_REPO ,
403
- pr_number : Integer ( ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , nil ) ) ,
404
- reuse_identifier : "prototype-build-link-#{ appcenter_app_name } " ,
405
- body : comment_body
406
- )
407
-
408
- # Attach version information as Buildkite metadata and annotation
409
- appcenter_id = lane_context . dig ( SharedValues ::APPCENTER_BUILD_INFORMATION , 'id' )
410
- metadata = versions . merge ( build_type : 'Prototype' , 'appcenter:id' : appcenter_id )
411
- buildkite_metadata ( set : metadata )
412
- appcenter_install_url = "https://install.appcenter.ms/orgs/#{ APPCENTER_OWNER_NAME } /apps/#{ appcenter_app_name } /releases/#{ appcenter_id } "
413
- list = metadata . map { |k , v | " - **#{ k } **: #{ v } " } . join ( "\n " )
414
- buildkite_annotate ( context : "appcenter-info-#{ output_app_name } " , style : 'info' , message : "#{ output_app_name } [App Center Build](#{ appcenter_install_url } ) Info:\n \n #{ list } " )
415
384
end
416
385
# rubocop:enable Metrics/AbcSize
417
386
# rubocop:enable Metrics/ParameterLists
@@ -467,23 +436,39 @@ def send_slack_message(message:, channel: '#build-and-ship')
467
436
)
468
437
end
469
438
470
- def upload_build_to_app_center (
471
- name :,
472
- file :,
473
- dsym :,
474
- release_notes :,
475
- distribute_to_everyone :
476
- )
477
- appcenter_upload (
478
- api_token : get_required_env ( 'APPCENTER_API_TOKEN' ) ,
479
- owner_name : APPCENTER_OWNER_NAME ,
480
- owner_type : APPCENTER_OWNER_TYPE ,
481
- app_name : name ,
482
- file : file ,
483
- dsym : dsym ,
439
+ # Uploads a build to Firebase App Distribution and post the corresponding PR comment
440
+ #
441
+ # @param [Hash<Symbol, String>] firebase_app_config A hash with the app name as the key and the Firebase app ID and testers group as the value
442
+ # Typically one of FIREBASE_APP_CONFIG_WORDPRESS or FIREBASE_APP_CONFIG_JETPACK
443
+ #
444
+ def upload_build_to_firebase_app_distribution ( firebase_app_config :)
445
+ release_notes = <<~NOTES
446
+ Pull Request: ##{ ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , 'N/A' ) }
447
+ Branch: `#{ ENV . fetch ( 'BUILDKITE_BRANCH' , 'N/A' ) } `
448
+ Commit: #{ ENV . fetch ( 'BUILDKITE_COMMIT' , 'N/A' ) [ 0 ...7 ] }
449
+ NOTES
450
+
451
+ firebase_app_distribution (
452
+ app : firebase_app_config [ :app_id ] ,
453
+ service_credentials_json_data : get_required_env ( 'FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY' ) ,
484
454
release_notes : release_notes ,
485
- destinations : distribute_to_everyone ? '*' : 'Collaborators' ,
486
- notify_testers : false
455
+ groups : firebase_app_config [ :testers_group ]
456
+ )
457
+
458
+ return if ENV [ 'BUILDKITE_PULL_REQUEST' ] . nil?
459
+
460
+ # PR Comment
461
+ comment_body = prototype_build_details_comment (
462
+ app_display_name : firebase_app_config [ :app_name ] ,
463
+ app_icon : firebase_app_config [ :app_icon ] ,
464
+ metadata : { Configuration : configuration } ,
465
+ fold : true
466
+ )
467
+ comment_on_pr (
468
+ project : GITHUB_REPO ,
469
+ pr_number : Integer ( ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , nil ) ) ,
470
+ reuse_identifier : "prototype-build-link-#{ firebase_app_config [ :app_id ] } " ,
471
+ body : comment_body
487
472
)
488
473
end
489
474
0 commit comments