refactor(fastlane): Adapted the Fastlane configurations from the KMP Project Template.#2579
Conversation
📝 WalkthroughWalkthroughAdds a centralized FastlaneConfig::ProjectConfig module and updates Fastlane configs to source Android/iOS settings from it. Introduces an extract_config utility, updates AppFile and fastlane-config/* files to use ProjectConfig, and reorganizes iOS lanes in Fastfile (new helper lanes and public lanes for build/sign/beta/release). Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer/CI
participant Fastlane as Fastfile Lanes
participant Config as ProjectConfig
participant Match as match (Certs/Profiles)
participant Xcode as Xcode / Gradle Build
participant ASC as App Store Connect
participant Firebase as Firebase / Google Play
Dev->>Fastlane: trigger lane (beta/release/deploy_on_firebase)
Fastlane->>Config: read platform build & firebase config
Fastlane->>Match: fetch certificates & provisioning
Match-->>Fastlane: certificates & profiles
Fastlane->>Xcode: build & sign (uses configs)
Xcode-->>Fastlane: artifact (IPA/AAB/APK)
Fastlane->>ASC: upload to TestFlight/App Store (beta/release)
Fastlane->>Firebase: upload to Firebase/Play (deploy_on_firebase)
ASC-->>Dev: upload status
Firebase-->>Dev: upload status
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@fastlane-config/project_config.rb`:
- Around line 34-39: The keystore block in project_config.rb contains hardcoded
credentials (keys: keystore, file, password, key_alias, key_password); replace
the plaintext passwords with environment variables and/or a secrets manager
(e.g. use ENV['KEYSTORE_PASSWORD'] and ENV['KEY_PASSWORD'] and ENV['KEY_ALIAS']
for the corresponding values referenced in the keystore hash), ensure the
fastlane code accesses these ENV vars instead of literals, add a clear error or
fail-fast check in the initialization (e.g., validate ENV presence and
raise/exit with a message if missing), and update project CI/README to document
the required environment variables or secret names so the keystore values are
provided securely at runtime.
In `@fastlane/FastFile`:
- Around line 429-435: In the lane :generateReleaseNote remove the unused local
variable branchName (the backtick call `git rev-parse --abbrev-ref
HEAD`.chomp()) since it's assigned but never referenced; update the
generateReleaseNote lane body to simply call changelog_from_git_commits and
return releaseNotes (or return the result directly) so there is no dead
assignment left in the generateReleaseNote lane.
🧹 Nitpick comments (3)
fastlane-config/project_config.rb (1)
134-139: Add trailing comma and consider path resolution robustness.Two issues:
- RuboCop flags a missing trailing comma after the last array element (line 138).
- The path resolution
File.join(Dir.pwd, '..', file)assumes execution from thefastlanedirectory, which may not always be the case.♻️ Proposed fix
required_files = [ ANDROID[:play_store_json_key], SHARED[:firebase_service_credentials], IOS[:app_store_connect][:key_filepath], - IOS[:code_signing][:match_git_private_key] + IOS[:code_signing][:match_git_private_key], ] - missing_files = required_files.reject { |file| File.exist?(File.join(Dir.pwd, '..', file)) } + project_root = File.expand_path('../..', __dir__) + missing_files = required_files.reject { |file| File.exist?(File.join(project_root, file)) }fastlane-config/ios_config.rb (1)
31-32: Minor: Inconsistent naming between config key and source.The key
app_rating_config_pathsources fromage_rating_config_path. While functionally correct, this naming inconsistency could cause confusion during maintenance.Consider aligning the naming:
- app_rating_config_path: ProjectConfig::IOS[:age_rating_config_path] + age_rating_config_path: ProjectConfig::IOS[:age_rating_config_path]Note: This would require updating references in
FastFile(line 550) as well.fastlane/FastFile (1)
461-497: Consider: Significant code duplication betweenbetaandreleaselanes.Both lanes share nearly identical setup logic (CI setup, API key loading, certificate fetching, version/build number incrementing). This duplication could be consolidated into a shared helper.
Based on learnings, since this is synced template code, this refactoring could be deferred to a follow-up issue. However, if you'd like, a shared
prepare_for_releasehelper could reduce ~30 lines of duplication:private_lane :prepare_for_release do |options| ios_config = FastlaneConfig::IosConfig::BUILD_CONFIG setup_ci_if_needed load_api_key(options) fetch_certificates_with_match(options.merge(match_type: "appstore")) increment_version_number( xcodeproj: ios_config[:project_path], version_number: ios_config[:version_number] ) latest_build_number = latest_testflight_build_number( app_identifier: options[:app_identifier] || ios_config[:app_identifier], api_key: Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY] ) increment_build_number( xcodeproj: ios_config[:project_path], build_number: latest_build_number + 1 ) endAlso applies to: 499-538
|
@techsavvy185 Can you please tell me the steps you have taken to adapt the Fastlane configuration? |
|
@biplab1 So basically I took all the values from the existing android and iOS configs and put references to the actual values in the project config file and replaced the already existing values in the project config file. Although I am not sure if we need to replace other values as well, particularly about the iOS config values since it did not contain that many values before. |
|
@techsavvy185 There are some sections missing from FastFile compared to that of the KMP project template. |
|
@biplab1 Ok, I'll make those changes. |
|
@biplab1 I have made the required changes. Those parts were missing since they were merged into the KMP template yesterday. |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
fastlane/FastFile (1)
31-42: Change assemble task to bundle task to generate AAB instead of APK.
bundleReleaseApksusestaskName: "assemble"which produces an APK file. The lane name and deployment pattern (compare todeployInternalat line 124 which correctly usestaskName: "bundleProd") indicate an AAB should be generated instead. Update totaskName: "bundle"ortaskName: "bundleRelease"to produce the correct artifact format.Proposed fix
buildAndSignApp( - taskName: "assemble", + taskName: "bundle", buildType: "Release", **signing_config )
🤖 Fix all issues with AI agents
In `@fastlane/FastFile`:
- Around line 448-454: The lanes build_signed_ios, beta, and release call
setup_ci_if_needed without forwarding the lane options, so overrides in
options[:ci_provider] are ignored; update those lanes (the lane definitions
named build_signed_ios, beta, and release) to call setup_ci_if_needed(options)
instead of setup_ci_if_needed so the helper receives the passed options and
respects ci_provider overrides.
- Around line 456-483: The deploy_on_firebase lane currently calls
increment_version without forwarding the firebase_app_id and serviceCredsFile
overrides, so update the deploy_on_firebase invocation of increment_version to
pass options[:firebase_app_id] and options[:serviceCredsFile] (or similarly
named params) through; then modify the increment_version lane to accept and use
those parameters (e.g., check for a passed appId and serviceCredsFile instead of
only using FastlaneConfig.get_firebase_config(:ios)) and use them when calling
firebase_app_distribution_get_latest_release so the appId and credentials used
come from the override rather than the default firebase_config.
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
fastlane/README.md (1)
117-165: Fix “iOS” capitalization and address MD003 heading-style lint.Line 117/125 uses “Ios”. Also markdownlint flags the new headings (Lines 119, 127, 135, 151, 159) for MD003; if lint is enforced, align heading style with the repo config or exclude this auto-generated file.
✏️ Suggested text fix
-Build Ios application +Build iOS application @@ -Build Signed Ios application +Build Signed iOS application
🤖 Fix all issues with AI agents
In `@fastlane-config/ios_config.rb`:
- Around line 12-25: BUILD_CONFIG currently includes a dead entry
app_rating_config_path (set from ProjectConfig::IOS[:age_rating_config_path]);
remove the app_rating_config_path key from BUILD_CONFIG to eliminate the unused
configuration, leaving all other keys (app_identifier, project_path,
workspace_path, plist_path, scheme, output_name, output_directory,
version_number, metadata_path) intact so lanes referencing BUILD_CONFIG continue
to work.
In `@fastlane-config/project_config.rb`:
- Around line 258-272: The validate_config method currently builds
required_files and checks existence using File.join(Dir.pwd, '..', file), which
can resolve outside the repo; replace that with an __dir__-anchored project root
(e.g., define a PROJECT_ROOT via File.expand_path('..', __dir__) or similar) and
use File.join(PROJECT_ROOT, file) when constructing missing_files; also fix the
trailing-comma RuboCop lint by removing the extra comma after the last element
in the required_files array (symbols: validate_config, required_files,
missing_files, File.join).
In `@fastlane/AppFile`:
- Around line 1-12: The Fastlane iOS wiring is wrong: change the apple_id call
to use the Apple ID email from FastlaneConfig::ProjectConfig::IOS[:apple_id]
(not the bundle id), set team_id to
FastlaneConfig::ProjectConfig::IOS_SHARED[:team_id] (not IOS[:team_id] which is
nil), and add an explicit
app_identifier(FastlaneConfig::ProjectConfig::IOS[:app_identifier]) call so the
bundle identifier is provided to fastlane; update the apple_id, team_id, and add
app_identifier in the AppFile accordingly.
♻️ Duplicate comments (1)
fastlane-config/project_config.rb (1)
34-39: Avoid hardcoded keystore passwords in source.Store keystore secrets in environment variables or a secrets manager to prevent leakage and accidental exposure.
🔒 Suggested fix
keystore: { file: "release_keystore.keystore", - password: "mifos1234", + password: ENV['ANDROID_KEYSTORE_PASSWORD'] || UI.user_error!("ANDROID_KEYSTORE_PASSWORD not set"), key_alias: "mifos", - key_password: "mifos1234" + key_password: ENV['ANDROID_KEY_PASSWORD'] || UI.user_error!("ANDROID_KEY_PASSWORD not set") },
|
@biplab1 Could you please look at this one again? I've made all changes. |
biplab1
left a comment
There was a problem hiding this comment.
Looks good to me. This can be merged.
Fixes - Jira-#599
Please make sure these boxes are checked before submitting your pull request - thanks!
Run the static analysis check
./gradlew checkorci-prepush.shto make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.