From 8f29b15feee4ac722e94a599c388bae3b9fbb352 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 19 Jul 2026 20:12:32 +0200 Subject: [PATCH] Distribute TestFlight builds to all beta groups automatically --- .github/workflows/release.yml | 1 - fastlane/Fastfile | 25 +++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bdaa78c6..4515454b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,6 @@ env: GIT_AUTHORIZATION: ${{ secrets.GIT_AUTHORIZATION }} MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} CERTIFICATES_GIT_URL: ${{ secrets.CERTIFICATES_GIT_URL }} - TESTFLIGHT_EXTERNAL_GROUPS: ${{ secrets.TESTFLIGHT_EXTERNAL_GROUPS }} jobs: determine_build_number: diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 0dda5695..654d66d4 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -10,7 +10,6 @@ TEMP_KEYCHAIN_USER = ENV['TEMP_KEYCHAIN_USER'] TEMP_KEYCHAIN_PASSWORD = ENV['TEMP_KEYCHAIN_PASSWORD'] DEVELOPER_APP_IDENTIFIER = ENV['DEVELOPER_APP_IDENTIFIER'] GIT_AUTHORIZATION = ENV['GIT_AUTHORIZATION'] -TESTFLIGHT_EXTERNAL_GROUPS = ENV['TESTFLIGHT_EXTERNAL_GROUPS'] XCODEPROJ = "#{APP_NAME}.xcodeproj" SCHEME = APP_NAME @@ -35,6 +34,18 @@ def ensure_temp_keychain(name, password) create_temp_keychain(name, password) end +# Beta groups are managed in App Store Connect; fetching them at upload time +# means new groups get builds without touching CI config. +def all_testflight_group_names(api_key) + Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.from(hash: api_key) + app = Spaceship::ConnectAPI::App.find(DEVELOPER_APP_IDENTIFIER) + UI.user_error!("App #{DEVELOPER_APP_IDENTIFIER} not found on App Store Connect") if app.nil? + groups = app.get_beta_groups.map(&:name) + UI.user_error!("No TestFlight beta groups found for #{DEVELOPER_APP_IDENTIFIER}") if groups.empty? + UI.message("Distributing build to TestFlight groups: #{groups.join(', ')}") + groups +end + add_extra_platforms(platforms: [:tvos]) before_all do @@ -148,7 +159,9 @@ platform :ios do upload_to_testflight( api_key: api_key, ipa: lane_context[SharedValues::IPA_OUTPUT_PATH], - changelog: changelog + changelog: changelog, + distribute_external: true, + groups: all_testflight_group_names(api_key) ) end end @@ -220,7 +233,9 @@ platform :tvos do upload_to_testflight( api_key: api_key, ipa: lane_context[SharedValues::IPA_OUTPUT_PATH], - changelog: changelog + changelog: changelog, + distribute_external: true, + groups: all_testflight_group_names(api_key) ) end end @@ -284,7 +299,9 @@ platform :mac do upload_to_testflight( api_key: api_key, pkg: lane_context[SharedValues::PKG_OUTPUT_PATH], - changelog: changelog + changelog: changelog, + distribute_external: true, + groups: all_testflight_group_names(api_key) ) end