Skip to content

Commit b799c6f

Browse files
committed
fix: improve TestFlight beta distribution configuration
- Handle missing API key gracefully for local environments - Use default 'External' group for testers - Add beta app review information - Add error handling for distribution failures - Support both CI and local environments
1 parent cd1f561 commit b799c6f

File tree

2 files changed

+109
-18
lines changed

2 files changed

+109
-18
lines changed

fastlane/Fastfile

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ default_platform(:ios)
55
platform :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

fastlane/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
fastlane documentation
2+
----
3+
4+
# Installation
5+
6+
Make sure you have the latest version of the Xcode command line tools installed:
7+
8+
```sh
9+
xcode-select --install
10+
```
11+
12+
For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
13+
14+
# Available Actions
15+
16+
## iOS
17+
18+
### ios sync_certificates
19+
20+
```sh
21+
[bundle exec] fastlane ios sync_certificates
22+
```
23+
24+
Sync certificates and provisioning profiles
25+
26+
### ios distribute_beta
27+
28+
```sh
29+
[bundle exec] fastlane ios distribute_beta
30+
```
31+
32+
Distribute existing build to beta testers
33+
34+
### ios beta
35+
36+
```sh
37+
[bundle exec] fastlane ios beta
38+
```
39+
40+
Build and upload to TestFlight
41+
42+
### ios release
43+
44+
```sh
45+
[bundle exec] fastlane ios release
46+
```
47+
48+
Submit to App Store Review
49+
50+
### ios create_app_version
51+
52+
```sh
53+
[bundle exec] fastlane ios create_app_version
54+
```
55+
56+
Create a new version on App Store Connect
57+
58+
### ios download_metadata
59+
60+
```sh
61+
[bundle exec] fastlane ios download_metadata
62+
```
63+
64+
Download metadata from App Store Connect
65+
66+
----
67+
68+
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
69+
70+
More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
71+
72+
The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).

0 commit comments

Comments
 (0)