Skip to content

Commit b90d6b8

Browse files
mokagioclaude
andauthored
Remove unused env vars from fastlane tooling (#25771)
* Add helper to read build settings from xcconfig Wraps `Xcodeproj::Config` with the error handling its raw API lacks: a missing file, a missing key, and a key set to an empty value all raise rather than silently yielding `nil`. Uses `to_hash` rather than `attributes`, since the latter only sees the settings assigned in the file itself, not those it pulls in via `#include`. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Read the internal team ID from xcconfig `INT_EXPORT_TEAM_ID` duplicated a value the project already declares: enterprise and prototype builds use the `Release-Alpha` configuration, whose `DEVELOPMENT_TEAM` is set in `config/Common.alpha.xcconfig`. Reading it from there removes one secret from the environment the tooling needs to be handed. Note the value also lives in `project.env` in the `mobile-secrets` repository, where it now has no consumer. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Read the external team ID from xcconfig Same reasoning as the internal team ID in the previous commit: `EXT_EXPORT_TEAM_ID` duplicated the `DEVELOPMENT_TEAM` that `config/Common.release.xcconfig` already declares for the App Store builds, which use the `Release` configuration. With both gone, `project.env` no longer has to carry either team ID. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Stop passing team_id to upload_to_testflight Both call sites authenticate with `api_key`, and pilot only ever reads `team_id` on the username/password Spaceship path — see `pilot/lib/pilot/manager.rb:36`, the sole reader of `config[:team_id]` in the whole of `pilot/lib`, which sits in the `else` branch that an API token skips. An App Store Connect API key is issued by a single team, so there is no team left to disambiguate. `woocommerce-ios` has shipped its TestFlight uploads without the parameter for this reason. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Stop provisioning project.env Every key it carried is now unused: the two export team IDs come from `xcconfig`, `FASTLANE_ITC_TEAM_ID` was inert alongside an `api_key`, the Sentry slugs are hardcoded constants in `build.rb`, and the two HockeyApp IDs outlived the service. With nothing reading the file, the `before_all` guard demanding it had no purpose either — which is what the three CI scripts were copying the example file to satisfy. `configure_apply` creates its destination directory itself, so nothing else needed that block. The file still exists in `mobile-secrets`, where it can now be deleted. --- Generated with the help of Claude Code, https://claude.com/claude-code Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Remove now unused `project.env.enc` --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9664012 commit b90d6b8

11 files changed

Lines changed: 42 additions & 42 deletions

File tree

.buildkite/commands/build-for-testing.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ fi
1616

1717
"$(dirname "${BASH_SOURCE[0]}")/shared-set-up.sh"
1818

19-
echo "--- :writing_hand: Copy Files"
20-
mkdir -pv ~/.configure/wordpress-ios/secrets
21-
cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env
22-
2319
echo "--- :closed_lock_with_key: Installing Secrets"
2420
bundle exec fastlane run configure_apply
2521

.buildkite/commands/lint-localized-strings-format.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@ if "$(dirname "${BASH_SOURCE[0]}")/should-skip-job.sh" --job-type localization;
44
exit 0
55
fi
66

7-
echo "--- :writing_hand: Copy Files"
8-
mkdir -pv ~/.configure/wordpress-ios/secrets
9-
cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env
10-
117
lint_localized_strings_format

.buildkite/commands/verify-strings-catalog.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ fi
1111
echo "--- :rubygems: Setting up Gems"
1212
install_gems
1313

14-
echo "--- :writing_hand: Copy Files"
15-
mkdir -pv ~/.configure/wordpress-ios/secrets
16-
cp -v fastlane/env/project.env-example ~/.configure/wordpress-ios/secrets/project.env
17-
1814
echo "--- :package: Generate Localizable.xcstrings from source"
1915
bundle exec fastlane ios generate_strings_catalog
2016

.configure

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
"branch": "trunk",
44
"pinned_hash": "6baf4e086398ddf8141d7132e557703a715fafd2",
55
"files_to_copy": [
6-
{
7-
"file": "iOS/WPiOS/project.env",
8-
"destination": "~/.configure/wordpress-ios/secrets/project.env",
9-
"encrypt": true
10-
},
116
{
127
"file": "iOS/WPiOS/Secrets.swift",
138
"destination": "~/.configure/wordpress-ios/secrets/WordPress-Secrets.swift",

.configure-files/project.env.enc

Lines changed: 0 additions & 2 deletions
This file was deleted.

fastlane/Fastfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ fastlane_require 'dotenv'
55
fastlane_require 'open-uri'
66
fastlane_require 'git'
77

8+
require_relative 'lanes/xcconfig_helper'
9+
810
UI.user_error!('Please run fastlane via `bundle exec`') unless FastlaneCore::Helper.bundler?
911

1012
########################################################################
@@ -27,8 +29,6 @@ BETA_APP_DESCRIPTION_PATH_READER = File.join(PROJECT_ROOT_FOLDER, 'fastlane', 'r
2729
# Env file paths to load
2830
ENV_FILE_NAME = '.wpios-env.default'
2931
USER_ENV_FILE_PATH = File.join(Dir.home, ENV_FILE_NAME)
30-
SECRETS_DIR = File.join(Dir.home, '.configure', 'wordpress-ios', 'secrets')
31-
PROJECT_ENV_FILE_PATH = File.join(SECRETS_DIR, 'project.env')
3232

3333
WORDPRESS_BUNDLE_IDENTIFIER = 'org.wordpress'
3434
WORDPRESS_EXTENSIONS_BUNDLE_IDENTIFIERS = %w[
@@ -54,10 +54,13 @@ ALL_READER_BUNDLE_IDENTIFIERS = [READER_BUNDLE_IDENTIFIER].freeze
5454

5555
# Environment Variables — used by lanes but also potentially actions
5656
Dotenv.load(USER_ENV_FILE_PATH)
57-
Dotenv.load(PROJECT_ENV_FILE_PATH)
5857
GITHUB_REPO = 'wordpress-mobile/wordpress-iOS'
5958
DEFAULT_BRANCH = 'trunk'
6059
PUBLIC_CONFIG_FILE = File.join(PROJECT_ROOT_FOLDER, 'config', 'Version.public.xcconfig')
60+
ALPHA_CONFIG_FILE = File.join(PROJECT_ROOT_FOLDER, 'config', 'Common.alpha.xcconfig')
61+
RELEASE_CONFIG_FILE = File.join(PROJECT_ROOT_FOLDER, 'config', 'Common.release.xcconfig')
62+
INTERNAL_TEAM_ID = XcconfigHelper.fetch(path: ALPHA_CONFIG_FILE, key: 'DEVELOPMENT_TEAM')
63+
EXTERNAL_TEAM_ID = XcconfigHelper.fetch(path: RELEASE_CONFIG_FILE, key: 'DEVELOPMENT_TEAM')
6164
ENV['FASTLANE_WWDR_USE_HTTP1_AND_RETRIES'] = 'true'
6265

6366
# Fastlane's `git_branch` action and its relevant helpers use environment variables to modify the output.
@@ -197,10 +200,6 @@ before_all do |lane|
197200
example_path = 'fastlane/env/user.env-example '
198201
UI.user_error! "#{ENV_FILE_NAME} not found: Please copy #{example_path} to #{USER_ENV_FILE_PATH} and fill in the values."
199202
end
200-
201-
unless File.file?(PROJECT_ENV_FILE_PATH)
202-
UI.user_error!("project.env not found at #{PROJECT_ENV_FILE_PATH}: Make sure your configuration is up to date with `rake dependencies`")
203-
end
204203
end
205204

206205
def compute_release_branch_name(options:, version: release_version_current)

fastlane/env/project.env-example

Lines changed: 0 additions & 7 deletions
This file was deleted.

fastlane/lanes/build.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
output_directory: BUILD_PRODUCTS_PATH,
169169
output_name: APP_STORE_CONNECT_BUILD_NAME_WORDPRESS,
170170
derived_data_path: DERIVED_DATA_PATH,
171-
export_team_id: get_required_env('EXT_EXPORT_TEAM_ID'),
171+
export_team_id: EXTERNAL_TEAM_ID,
172172
export_options: { **COMMON_EXPORT_OPTIONS, method: 'app-store' }
173173
)
174174

@@ -234,7 +234,7 @@
234234
scheme: 'Jetpack',
235235
workspace: WORKSPACE_PATH,
236236
clean: true,
237-
export_team_id: get_required_env('EXT_EXPORT_TEAM_ID'),
237+
export_team_id: EXTERNAL_TEAM_ID,
238238
output_directory: BUILD_PRODUCTS_PATH,
239239
output_name: APP_STORE_CONNECT_BUILD_NAME_JETPACK,
240240
derived_data_path: DERIVED_DATA_PATH,
@@ -283,7 +283,7 @@
283283
scheme: 'Reader',
284284
workspace: WORKSPACE_PATH,
285285
clean: true,
286-
export_team_id: get_required_env('EXT_EXPORT_TEAM_ID'),
286+
export_team_id: EXTERNAL_TEAM_ID,
287287
output_directory: BUILD_PRODUCTS_PATH,
288288
output_name: APP_STORE_CONNECT_BUILD_NAME_READER,
289289
derived_data_path: DERIVED_DATA_PATH,
@@ -373,7 +373,7 @@
373373
output_directory: BUILD_PRODUCTS_PATH,
374374
output_name: output_name,
375375
derived_data_path: DERIVED_DATA_PATH,
376-
export_team_id: get_required_env('EXT_EXPORT_TEAM_ID'),
376+
export_team_id: EXTERNAL_TEAM_ID,
377377
xcargs: { VERSION_LONG: build_code },
378378
export_options: { **COMMON_EXPORT_OPTIONS, method: 'app-store' }
379379
)
@@ -486,7 +486,7 @@ def build_and_upload_prototype_build(scheme:, output_app_name:, firebase_app_con
486486
output_directory: BUILD_PRODUCTS_PATH,
487487
output_name: output_app_name,
488488
derived_data_path: DERIVED_DATA_PATH,
489-
export_team_id: ENV.fetch('INT_EXPORT_TEAM_ID', nil),
489+
export_team_id: INTERNAL_TEAM_ID,
490490
export_method: 'enterprise',
491491
export_options: { **COMMON_EXPORT_OPTIONS, method: 'enterprise' }
492492
)
@@ -516,7 +516,6 @@ def upload_build_to_testflight(ipa_path:, whats_new_path:, distribution_groups:,
516516
distribute_external = distribution_groups.empty? == false
517517

518518
upload_to_testflight(
519-
team_id: get_required_env('FASTLANE_ITC_TEAM_ID'),
520519
api_key: app_store_connect_api_key,
521520
ipa: ipa_path,
522521
beta_app_description: File.read(beta_app_description_path),

fastlane/lanes/codesign.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def update_code_signing_enterprise(readonly:, app_identifiers:)
131131
update_code_signing(
132132
type: 'enterprise',
133133
# Enterprise builds belong to the "internal" team
134-
team_id: get_required_env('INT_EXPORT_TEAM_ID'),
134+
team_id: INTERNAL_TEAM_ID,
135135
readonly: readonly,
136136
app_identifiers: app_identifiers,
137137
api_key: nil
@@ -142,7 +142,7 @@ def update_code_signing_app_store(readonly:, app_identifiers:)
142142
update_code_signing(
143143
type: 'appstore',
144144
# App Store builds belong to the "external" team
145-
team_id: get_required_env('EXT_EXPORT_TEAM_ID'),
145+
team_id: EXTERNAL_TEAM_ID,
146146
readonly: readonly,
147147
app_identifiers: app_identifiers,
148148
api_key: app_store_connect_api_key

fastlane/lanes/promote.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ def promote_existing_build_to_groups(app:, app_version:, build_code:, changelog:
208208

209209
upload_to_testflight(
210210
api_key: app_store_connect_api_key,
211-
team_id: get_required_env('FASTLANE_ITC_TEAM_ID'),
212211
app_identifier: app[:identifier],
213212
app_platform: 'ios',
214213
app_version: app_version,

0 commit comments

Comments
 (0)