@@ -5,12 +5,26 @@ default_platform(:ios)
5
5
platform :ios do
6
6
# Helper method to get App Store Connect API key
7
7
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
10
24
11
25
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"] ,
14
28
key_content : key_content ,
15
29
in_house : false
16
30
)
@@ -58,28 +72,33 @@ platform :ios do
58
72
# Get the build number to distribute (optional)
59
73
build_number = options [ :build_number ]
60
74
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
73
77
testflight (
74
78
api_key : api_key ,
79
+ app_identifier : "v2er.app" ,
75
80
skip_submission : false ,
76
81
distribute_external : true ,
77
- groups : [ "Beta Testers " ] ,
82
+ groups : [ "External " ] , # Default external tester group
78
83
notify_external_testers : true ,
79
84
uses_non_exempt_encryption : false ,
80
85
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
+ }
82
96
)
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" )
83
102
end
84
103
end
85
104
0 commit comments