@@ -5,12 +5,26 @@ default_platform(:ios)
55platform :ios do
66 # Helper method to get App Store Connect API key
77 private_lane :get_api_key do
8- # Read the key content directly
9- key_content = File . read ( ENV [ "APP_STORE_CONNECT_API_KEY_KEY" ] )
8+ # Check if running in CI or local
9+ if ENV [ "APP_STORE_CONNECT_API_KEY_KEY" ]
10+ # CI environment with key file path
11+ key_content = File . read ( ENV [ "APP_STORE_CONNECT_API_KEY_KEY" ] )
12+ elsif ENV [ "APP_STORE_CONNECT_API_KEY_CONTENT" ]
13+ # Local environment with key content directly
14+ key_content = ENV [ "APP_STORE_CONNECT_API_KEY_CONTENT" ]
15+ else
16+ # Try to read from standard location
17+ key_path = File . expand_path ( "~/.appstoreconnect/private_keys/AuthKey_#{ ENV [ "APP_STORE_CONNECT_KEY_ID" ] } .p8" )
18+ if File . exist? ( key_path )
19+ key_content = File . read ( key_path )
20+ else
21+ UI . user_error! ( "App Store Connect API key not found. Please set APP_STORE_CONNECT_API_KEY_CONTENT environment variable or place the key at #{ key_path } " )
22+ end
23+ end
1024
1125 app_store_connect_api_key (
12- key_id : ENV [ "APP_STORE_CONNECT_API_KEY_KEY_ID" ] ,
13- issuer_id : ENV [ "APP_STORE_CONNECT_API_KEY_ISSUER_ID" ] ,
26+ key_id : ENV [ "APP_STORE_CONNECT_KEY_ID" ] || ENV [ " APP_STORE_CONNECT_API_KEY_KEY_ID"] ,
27+ issuer_id : ENV [ "APP_STORE_CONNECT_ISSUER_ID" ] || ENV [ " APP_STORE_CONNECT_API_KEY_ISSUER_ID"] ,
1428 key_content : key_content ,
1529 in_house : false
1630 )
@@ -58,28 +72,33 @@ platform :ios do
5872 # Get the build number to distribute (optional)
5973 build_number = options [ :build_number ]
6074
61- if build_number
62- # Distribute specific build
63- distribute_build (
64- api_key : api_key ,
65- build_number : build_number ,
66- groups : [ "Beta Testers" ] ,
67- notify_external_testers : true ,
68- uses_non_exempt_encryption : false ,
69- submit_beta_review : true
70- )
71- else
72- # Wait for latest build to process and distribute
75+ begin
76+ # Distribute to beta testers
7377 testflight (
7478 api_key : api_key ,
79+ app_identifier : "v2er.app" ,
7580 skip_submission : false ,
7681 distribute_external : true ,
77- groups : [ "Beta Testers " ] ,
82+ groups : [ "External " ] , # Default external tester group
7883 notify_external_testers : true ,
7984 uses_non_exempt_encryption : false ,
8085 submit_beta_review : true ,
81- wait_for_uploaded_build : true
86+ wait_for_uploaded_build : true ,
87+ beta_app_review_info : {
88+ contact_email : "support@v2er.app" ,
89+ contact_first_name : "V2er" ,
90+ contact_last_name : "Support" ,
91+ contact_phone : "+1234567890" ,
92+ demo_account_name : "" ,
93+ demo_account_password : "" ,
94+ notes : "This is a V2EX forum client app. No special account needed for testing."
95+ }
8296 )
97+
98+ UI . success ( "✅ Successfully distributed build to beta testers!" )
99+ rescue => e
100+ UI . error ( "Failed to distribute: #{ e . message } " )
101+ UI . message ( "You may need to manually distribute the build in App Store Connect" )
83102 end
84103 end
85104
0 commit comments