@@ -24,6 +24,11 @@ DERIVED_DATA_DIR = File.join(FASTLANE_DIR, 'DerivedData')
2424SCREENSHOTS_DIR = File . join ( FASTLANE_DIR , 'screenshots' )
2525FASTLANE_METADATA_FOLDER = File . join ( FASTLANE_DIR , 'metadata' )
2626WORKSPACE_PATH = File . join ( PROJECT_ROOT_FOLDER , 'WooCommerce.xcworkspace' )
27+
28+ # Firebase App Distribution
29+ FIREBASE_APP_ID = '1:124902176124:ios:02259de1e7c42b291620f9'
30+ FIREBASE_TESTERS_GROUP = 'woocommerce-ios---prototype-builds'
31+
2732BUILDKITE_RELEASE_PIPELINE = 'release-builds.yml'
2833IOS_LOCALES = %w[ ar-SA de-DE en-US es-ES fr-FR he id it ja ko nl-NL pt-BR ru sv tr zh-Hans zh-Hant ] . freeze
2934SIMULATOR_VERSION = '18.1' # For screenshots
@@ -51,7 +56,7 @@ MAIN_BUNDLE_IDENTIFIERS = [
5156] . freeze
5257
5358ALPHA_VERSION_BUNDLE_IDENTIFIER = 'com.automattic.alpha.woocommerce'
54- # Registered in our Enterprise account, for App Center / Prototype Builds
59+ # Registered in our Enterprise account, for Prototype Builds
5560ALPHA_BUNDLE_IDENTIFIERS = MAIN_BUNDLE_IDENTIFIERS . map do |id |
5661 id . gsub ( APP_STORE_VERSION_BUNDLE_IDENTIFIER , ALPHA_VERSION_BUNDLE_IDENTIFIER )
5762end . freeze
@@ -738,13 +743,17 @@ platform :ios do
738743
739744 build_for_prototype_build
740745
741- appcenter_upload (
742- api_token : get_required_env ( 'APPCENTER_API_TOKEN' ) ,
743- owner_name : 'automattic' ,
744- owner_type : 'organization' ,
745- app_name : 'WooCommerce-Installable-Builds' ,
746- destinations : 'Collaborators' ,
747- notify_testers : false
746+ release_notes = <<~NOTES
747+ Pull Request: ##{ pull_request_number || 'N/A' }
748+ Branch: `#{ ENV . fetch ( 'BUILDKITE_BRANCH' , 'N/A' ) } `
749+ Commit: #{ ENV . fetch ( 'BUILDKITE_COMMIT' , 'N/A' ) [ 0 ...7 ] }
750+ NOTES
751+
752+ firebase_app_distribution (
753+ app : FIREBASE_APP_ID ,
754+ service_credentials_json_data : get_required_env ( 'FIREBASE_APP_DISTRIBUTION_ACCOUNT_KEY' ) ,
755+ release_notes : release_notes ,
756+ groups : FIREBASE_TESTERS_GROUP
748757 )
749758
750759 sentry_upload_dsym (
@@ -754,21 +763,13 @@ platform :ios do
754763 dsym_path : './build/WooCommerce.app.dSYM.zip'
755764 )
756765
757- # The build code used in the Enterprise build has a different format that the App Store one.
758- # We cannot use the standard build_code_current method but have to read it directly.
759- build_code = Xcodeproj ::Config . new ( File . new ( PUBLIC_CONFIG_FILE ) ) . to_hash [ BUILD_CODE_KEY ]
760- UI . message ( "Successfully built and uploaded prototype build `#{ build_code } ` to App Center." )
761-
762- return if ENV [ 'BUILDKITE_PULL_REQUEST' ] . nil?
766+ next if pull_request_number . nil?
763767
764768 # PR Comment
765- comment_body = prototype_build_details_comment (
766- app_display_name : 'WooCommerce iOS' ,
767- app_center_org_name : 'automattic'
768- )
769+ comment_body = prototype_build_details_comment ( app_display_name : 'WooCommerce iOS Prototype' )
769770 comment_on_pr (
770771 project : GITHUB_REPO ,
771- pr_number : Integer ( ENV . fetch ( 'BUILDKITE_PULL_REQUEST' ) ) ,
772+ pr_number : pull_request_number ,
772773 reuse_identifier : 'prototype-build-link' ,
773774 body : comment_body
774775 )
@@ -778,19 +779,15 @@ platform :ios do
778779 lane :build_for_prototype_build do |fetch_code_signing : true |
779780 update_certs_and_profiles_enterprise if fetch_code_signing
780781
781- # Get the current build version, and update it if needed
782- versions = Xcodeproj ::Config . new ( File . new ( PUBLIC_CONFIG_FILE ) ) . to_hash
783- build_number = generate_prototype_build_number
784- UI . message ( "Updating build version to #{ build_number } " )
785- versions [ BUILD_CODE_KEY ] = build_number
786- new_config = Xcodeproj ::Config . new ( versions )
787- new_config . save_as ( Pathname . new ( PUBLIC_CONFIG_FILE ) )
782+ build_number = ENV . fetch ( 'BUILDKITE_BUILD_NUMBER' , '0' )
783+ pr_or_branch = pull_request_number &.then { |num | "PR ##{ num } " } || ENV . fetch ( 'BUILDKITE_BRANCH' , nil )
788784
789785 gym (
790786 scheme : 'WooCommerce Alpha' ,
791787 workspace : WORKSPACE_PATH ,
792788 export_method : 'enterprise' ,
793789 clean : true ,
790+ xcargs : { BUILD_CODE_KEY => build_number , 'VERSION_SHORT' => pr_or_branch } . compact ,
794791 output_directory : 'build' ,
795792 export_team_id : get_required_env ( 'INT_EXPORT_TEAM_ID' ) ,
796793 export_options : {
@@ -1329,25 +1326,6 @@ lane :test_without_building do |options|
13291326 UI . user_error! ( "Tests failed with #{ tests_result [ :number_of_failures_excluding_retries ] } failures." ) if tests_result [ :number_of_failures_excluding_retries ] . positive?
13301327end
13311328
1332- # -----------------------------------------------------------------------------------
1333- # Generates Prototype Build Version Numbers in a Buildkite-specific way
1334- # -----------------------------------------------------------------------------------
1335- def generate_prototype_build_number
1336- if ENV . key? ( 'BUILDKITE' )
1337- commit = ENV . fetch ( 'BUILDKITE_COMMIT' ) [ 0 , 7 ]
1338- branch = ENV . fetch ( 'BUILDKITE_BRANCH' )
1339- pr_num = ENV . fetch ( 'BUILDKITE_PULL_REQUEST' )
1340-
1341- pr_num == 'false' ? "#{ branch } -#{ commit } " : "pr#{ pr_num } -#{ commit } "
1342- else
1343- repo = Git . open ( PROJECT_ROOT_FOLDER )
1344- commit = repo . current_branch
1345- branch = repo . revparse ( 'HEAD' ) [ 0 , 7 ]
1346-
1347- "#{ branch } -#{ commit } "
1348- end
1349- end
1350-
13511329# -----------------------------------------------------------------------------------
13521330# Raises an error if Sentry is not installed
13531331# -----------------------------------------------------------------------------------
@@ -1495,13 +1473,6 @@ def prompt_user_for_app_store_connect_credentials
14951473 ENV [ 'FASTLANE_USER' ] = CredentialsManager ::AccountManager . new . user
14961474end
14971475
1498- def override_default_release_branch ( version )
1499- success = Fastlane ::Helper ::GitHelper . checkout_and_pull ( release : version )
1500- UI . user_error! ( "Release branch for version #{ version } doesn't exist. Abort." ) unless success
1501-
1502- UI . message ( "Checked out branch `#{ git_branch } ` as requested by user.\n " )
1503- end
1504-
15051476# https://buildkite.com/docs/test-analytics/ci-environments
15061477TEST_ANALYTICS_ENVIRONMENT = %w[
15071478 BUILDKITE_ANALYTICS_TOKEN
@@ -1517,6 +1488,13 @@ TEST_ANALYTICS_ENVIRONMENT = %w[
15171488# -----------------------------------------------------------------------------------
15181489# Release Management Utils
15191490# -----------------------------------------------------------------------------------
1491+
1492+ def pull_request_number
1493+ # Buildkite sets this env var to the PR number if on a PR, but to 'false' (and not nil) if not on a PR
1494+ pr_num = ENV . fetch ( 'BUILDKITE_PULL_REQUEST' , 'false' )
1495+ pr_num == 'false' ? nil : Integer ( pr_num )
1496+ end
1497+
15201498def create_backmerge_pr
15211499 version = release_version_current
15221500
0 commit comments