1
1
# frozen_string_literal: true
2
2
3
+ # Sentry
3
4
SENTRY_ORG_SLUG = 'a8c'
4
5
SENTRY_PROJECT_SLUG_WORDPRESS = 'wordpress-ios'
5
6
SENTRY_PROJECT_SLUG_JETPACK = 'jetpack-ios'
6
- APPCENTER_OWNER_NAME = 'automattic'
7
- APPCENTER_OWNER_TYPE = 'organization'
7
+
8
+ # Prototype Builds in Firebase App Distribution
9
+ PROTOTYPE_BUILD_XCODE_CONFIGURATION = 'Release-Alpha'
10
+ FIREBASE_APP_CONFIG_WORDPRESS = {
11
+ app_name : 'WordPress' ,
12
+ app_icon : ':wordpress:' , # Use Buildkite emoji
13
+ app_id : '1:124902176124:ios:ff9714d0b53aac821620f9' ,
14
+ testers_group : 'wordpress-ios---prototype-builds'
15
+ } . freeze
16
+ FIREBASE_APP_CONFIG_JETPACK = {
17
+ app_name : 'Jetpack' ,
18
+ app_icon : ':jetpack:' , # Use Buildkite emoji
19
+ app_id : '1:124902176124:ios:121c494b82f283ec1620f9' ,
20
+ testers_group : 'jetpack-ios---prototype-builds'
21
+ } . freeze
22
+
8
23
CONCURRENT_SIMULATORS = 2
9
24
10
25
# Shared options to use when invoking `build_app` (`gym`).
251
266
)
252
267
end
253
268
254
- # Builds the WordPress app for a Prototype Build ("WordPress Alpha" scheme), and uploads it to App Center
269
+ # Builds the WordPress app for a Prototype Build ("WordPress Alpha" scheme), and uploads it to Firebase App Distribution
255
270
#
256
271
# @called_by CI
257
272
#
264
279
build_and_upload_prototype_build (
265
280
scheme : 'WordPress Alpha' ,
266
281
output_app_name : 'WordPress Alpha' ,
267
- appcenter_app_name : 'WPiOS-One-Offs' ,
268
- app_icon : ':wordpress:' , # Use Buildkite emoji
282
+ firebase_app_config : FIREBASE_APP_CONFIG_WORDPRESS ,
269
283
sentry_project_slug : SENTRY_PROJECT_SLUG_WORDPRESS ,
270
284
app_identifier : 'org.wordpress.alpha'
271
285
)
272
286
end
273
287
274
- # Builds the Jetpack app for a Prototype Build ("Jetpack" scheme), and uploads it to App Center
288
+ # Builds the Jetpack app for a Prototype Build ("Jetpack" scheme), and uploads it to Firebase App Distribution
275
289
#
276
290
# @called_by CI
277
291
#
284
298
build_and_upload_prototype_build (
285
299
scheme : 'Jetpack' ,
286
300
output_app_name : 'Jetpack Alpha' ,
287
- appcenter_app_name : 'jetpack-installable-builds' ,
288
- app_icon : ':jetpack:' , # Use Buildkite emoji
301
+ firebase_app_config : FIREBASE_APP_CONFIG_JETPACK ,
289
302
sentry_project_slug : SENTRY_PROJECT_SLUG_JETPACK ,
290
303
app_identifier : 'com.jetpack.alpha'
291
304
)
@@ -327,28 +340,19 @@ def generate_prototype_build_number
327
340
end
328
341
end
329
342
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.
343
+ # 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
344
#
332
- # rubocop:disable Metrics/AbcSize
333
- # 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 :)
335
- configuration = 'Release-Alpha'
336
-
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 ) )
345
+ def build_and_upload_prototype_build ( scheme :, output_app_name :, firebase_app_config :, sentry_project_slug :, app_identifier :)
346
+ build_number = ENV . fetch ( 'BUILDKITE_BUILD_NUMBER' , '0' )
347
+ pr_or_branch = ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , nil ) &.then { |num | "PR ##{ num } " } || ENV . fetch ( 'BUILDKITE_BRANCH' , nil )
345
348
346
349
# Build
347
350
build_app (
348
351
scheme : scheme ,
349
352
workspace : WORKSPACE_PATH ,
350
- configuration : configuration ,
353
+ configuration : PROTOTYPE_BUILD_XCODE_CONFIGURATION ,
351
354
clean : true ,
355
+ xcargs : { VERSION_LONG : build_number , VERSION_SHORT : pr_or_branch } . compact ,
352
356
output_directory : BUILD_PRODUCTS_PATH ,
353
357
output_name : output_app_name ,
354
358
derived_data_path : DERIVED_DATA_PATH ,
@@ -357,21 +361,8 @@ def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_na
357
361
export_options : { **COMMON_EXPORT_OPTIONS , method : 'enterprise' }
358
362
)
359
363
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
364
+ upload_build_to_firebase_app_distribution (
365
+ firebase_app_config : firebase_app_config
375
366
)
376
367
377
368
# Upload dSYMs to Sentry
@@ -388,33 +379,7 @@ def build_and_upload_prototype_build(scheme:, output_app_name:, appcenter_app_na
388
379
build_version : build_number ,
389
380
app_identifier : app_identifier
390
381
)
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
382
end
416
- # rubocop:enable Metrics/AbcSize
417
- # rubocop:enable Metrics/ParameterLists
418
383
419
384
def inject_buildkite_analytics_environment ( xctestrun_path :)
420
385
require 'plist'
@@ -467,23 +432,39 @@ def send_slack_message(message:, channel: '#build-and-ship')
467
432
)
468
433
end
469
434
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 ,
435
+ # Uploads a build to Firebase App Distribution and post the corresponding PR comment
436
+ #
437
+ # @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
438
+ # Typically one of FIREBASE_APP_CONFIG_WORDPRESS or FIREBASE_APP_CONFIG_JETPACK
439
+ #
440
+ def upload_build_to_firebase_app_distribution ( firebase_app_config :)
441
+ release_notes = <<~NOTES
442
+ Pull Request: ##{ ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , 'N/A' ) }
443
+ Branch: `#{ ENV . fetch ( 'BUILDKITE_BRANCH' , 'N/A' ) } `
444
+ Commit: #{ ENV . fetch ( 'BUILDKITE_COMMIT' , 'N/A' ) [ 0 ...7 ] }
445
+ NOTES
446
+
447
+ firebase_app_distribution (
448
+ app : firebase_app_config [ :app_id ] ,
449
+ service_credentials_json_data : get_required_env ( 'FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY' ) ,
484
450
release_notes : release_notes ,
485
- destinations : distribute_to_everyone ? '*' : 'Collaborators' ,
486
- notify_testers : false
451
+ groups : firebase_app_config [ :testers_group ]
452
+ )
453
+
454
+ return if ENV [ 'BUILDKITE_PULL_REQUEST' ] . nil?
455
+
456
+ # PR Comment
457
+ comment_body = prototype_build_details_comment (
458
+ app_display_name : firebase_app_config [ :app_name ] ,
459
+ app_icon : firebase_app_config [ :app_icon ] ,
460
+ metadata : { Configuration : PROTOTYPE_BUILD_XCODE_CONFIGURATION } ,
461
+ fold : true
462
+ )
463
+ comment_on_pr (
464
+ project : GITHUB_REPO ,
465
+ pr_number : Integer ( ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , nil ) ) ,
466
+ reuse_identifier : "prototype-build-link-#{ firebase_app_config [ :app_id ] } " ,
467
+ body : comment_body
487
468
)
488
469
end
489
470
0 commit comments