-
Notifications
You must be signed in to change notification settings - Fork 90
ci: create and sign separate bundle ID for PRs #19505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
siddarthkay
wants to merge
11
commits into
master
Choose a base branch
from
fix-ios-signing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+852
−438
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
41514ea
ci: create and sign separate bundle ID for PRs
siddarthkay e986068
ci: upload iOS PR to Diawi
siddarthkay 6b92160
ci: iOS job for release
siddarthkay 711d934
ci: fix release job path
siddarthkay f15fd77
chore: address feedback
siddarthkay f0e3aaf
chore: use fastlane resign action
siddarthkay 5742e5d
debug: very verbose logs
siddarthkay 9d111ba
chore: xcode wrapper in nix flake
siddarthkay 1674de3
fix: resign expects provisioning profile
siddarthkay 33d96dc
chore: some cleanup
siddarthkay 0e0f8d5
chore: more feedback
siddarthkay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,3 +26,66 @@ It also expects the presence of the following credentials: | |
| * `macos-keychain-file` - Keychain file with the MacOS signing certificate. | ||
|
|
||
| You can read about how to create such a keychain [here](https://github.com/status-im/infra-docs/blob/master/articles/macos_signing_keychain.md). | ||
|
|
||
| ## iOS | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this could be somewhere in |
||
|
|
||
| iOS builds use **fastlane** with **match** for code signing management. This provides: | ||
| - Automatic certificate and profile management | ||
| - Separate signing for PR vs release builds | ||
|
|
||
| ### Bundle Identifiers | ||
|
|
||
| | Build Type | Bundle ID | Fastlane Lane | | ||
| |------------|-----------|---------------| | ||
| | PR builds | `app.status.mobile.pr` | `pr` | | ||
| | Release | `app.status.mobile` | `release` | | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Certificate Types | ||
|
|
||
| | Build Type | Certificate Type | Match Type | Purpose | | ||
| |------------|------------------|------------|---------| | ||
| | PR builds | Apple Development | `development` | Testing on registered devices | | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| | Release | Apple Distribution | `appstore` | App Store / TestFlight | | ||
|
|
||
| ### Fastlane Files | ||
|
|
||
| The `fastlane` configuration is located in `mobile/fastlane/`: | ||
|
|
||
| | File | Purpose | | ||
| |------|---------| | ||
| | `Fastfile` | Defines build lanes (pr, nightly, release) | | ||
| | `Matchfile` | Configures match for certificate management | | ||
| | `Appfile` | App identifiers and team configuration | | ||
| | `Gemfile` | Ruby dependencies | | ||
|
|
||
|
|
||
| ### Local Development | ||
|
|
||
| To run `fastlane` locally for testing: | ||
|
|
||
| ```bash | ||
| cd mobile/fastlane | ||
| nix --extra-experimental-features 'nix-command flakes' develop | ||
| bundle install | ||
|
|
||
| # Run a specific lane | ||
| bundle exec fastlane ios pr | ||
| bundle exec fastlane ios release | ||
| ``` | ||
|
|
||
| ### Revoking/Rotating Certificates | ||
|
|
||
| If a certificate is compromised or revoked: | ||
|
|
||
| ```bash | ||
| cd mobile/fastlane | ||
|
|
||
| # Nuke existing certificates (warning!! watch what you nuke) | ||
| bundle exec fastlane match nuke development | ||
| bundle exec fastlane match nuke distribution | ||
|
|
||
| # Regenerate | ||
| bundle exec fastlane match development --app_identifier "app.status.mobile.pr" | ||
| bundle exec fastlane match appstore --app_identifier "app.status.mobile" | ||
| ``` | ||
|
|
||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Default environment variables for fastlane | ||
| # These can be overridden by CI environment | ||
|
|
||
| # Disable fastlane colors in CI | ||
| FASTLANE_DISABLE_COLORS=1 | ||
|
|
||
| # Skip session verification | ||
| FASTLANE_SESSION="" | ||
|
|
||
| # Team ID | ||
| FASTLANE_TEAM_ID=8B5X2M6H2Y | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Gems installed locally | ||
| .gems/ | ||
| vendor/bundle/ | ||
|
|
||
| # Bundler | ||
| .bundle/ | ||
|
|
||
| # Fastlane | ||
| fastlane/report.xml | ||
| fastlane/Preview.html | ||
| fastlane/screenshots/ | ||
| fastlane/test_output/ | ||
|
|
||
| # Nix | ||
| result |
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.2.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # App identifiers for Status App iOS builds | ||
| app_identifier("app.status.mobile") | ||
| apple_id(ENV["FASTLANE_APPLE_ID"]) | ||
| team_id("8B5X2M6H2Y") | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| itc_team_id(ENV["FASTLANE_ITC_TEAM_ID"]) | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| for_lane :pr do | ||
| app_identifier("app.status.mobile.pr") | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,224 @@ | ||
| # This file defines the build and signing lanes for iOS | ||
|
|
||
| default_platform(:ios) | ||
|
|
||
| TEAM_ID = "8B5X2M6H2Y" | ||
| APP_ID_RELEASE = "app.status.mobile" | ||
| APP_ID_PR = "app.status.mobile.pr" | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| APP_NAME_RELEASE = "Status.app" | ||
| APP_NAME_PR = "StatusPR.app" | ||
| PROJECT_DIR = File.expand_path("../", __dir__) | ||
| BUILD_DIR = File.join(PROJECT_DIR, "bin", "ios", "qt6") | ||
|
|
||
| platform :ios do | ||
| before_all do | ||
| UI.message("Project directory: #{PROJECT_DIR}") | ||
| UI.message("Build directory: #{BUILD_DIR}") | ||
| end | ||
|
|
||
| after_all do | ||
| # Clean up CI keychain after build | ||
| if is_ci | ||
| delete_keychain(name: keychain_name) if File.exist?(File.expand_path("~/Library/Keychains/#{keychain_name}-db")) | ||
| end | ||
| end | ||
|
|
||
| error do | ||
| # Clean up CI keychain on failure too | ||
| if is_ci | ||
| delete_keychain(name: keychain_name) rescue nil | ||
| end | ||
| end | ||
|
|
||
| # ============================================ | ||
| # PR Builds | ||
| # ============================================ | ||
| desc "Build iOS app for PRs" | ||
| lane :pr do | ||
siddarthkay marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| setup_ci_keychain | ||
|
|
||
| run_match(type: "adhoc", app_identifier: APP_ID_PR) | ||
|
|
||
| sign_app( | ||
| app_identifier: APP_ID_PR, | ||
| app_name: APP_NAME_PR, | ||
| profile_type: "adhoc" | ||
| ) | ||
|
|
||
| create_ipa(app_name: APP_NAME_PR) | ||
| end | ||
|
|
||
| # ============================================ | ||
| # Release Builds | ||
| # ============================================ | ||
| desc "Build iOS app for release" | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| lane :release do | ||
| setup_ci_keychain | ||
|
|
||
| run_match(type: "appstore", app_identifier: APP_ID_RELEASE) | ||
|
|
||
| sign_app( | ||
| app_identifier: APP_ID_RELEASE, | ||
| app_name: APP_NAME_RELEASE, | ||
| profile_type: "appstore" | ||
| ) | ||
|
|
||
| create_ipa(app_name: APP_NAME_RELEASE) | ||
|
|
||
| if ENV["UPLOAD_TO_TESTFLIGHT"] == "true" | ||
| upload_to_testflight_lane | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
|
|
||
| # ============================================ | ||
| # TestFlight Upload | ||
| # ============================================ | ||
| desc "Upload IPA to TestFlight" | ||
| lane :upload_to_testflight_lane do | ||
| api_key = app_store_connect_api_key( | ||
| key_id: ENV["ASC_KEY_ID"], | ||
| issuer_id: ENV["ASC_ISSUER_ID"], | ||
| key_filepath: ENV["ASC_KEY_FILE"], | ||
| duration: 1200, | ||
| in_house: false | ||
| ) | ||
|
|
||
| upload_to_testflight( | ||
| api_key: api_key, | ||
| ipa: File.join(BUILD_DIR, "Status.ipa"), | ||
| skip_waiting_for_build_processing: true, | ||
| changelog: ENV["CHANGELOG"] || "New build from CI" | ||
| ) | ||
| end | ||
|
|
||
| # ============================================ | ||
| # Helper Methods | ||
| # ============================================ | ||
|
|
||
| private_lane :setup_ci_keychain do | ||
| if is_ci | ||
| create_keychain( | ||
| name: keychain_name, | ||
| password: keychain_password, | ||
| default_keychain: true, | ||
| unlock: true, | ||
| timeout: 3600, | ||
| lock_when_sleeps: false | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| private_lane :run_match do |options| | ||
| match_params = { | ||
| type: options[:type], | ||
| app_identifier: options[:app_identifier], | ||
| readonly: false, | ||
| # Auto-regenerate development profiles when new devices are registered | ||
| force_for_new_devices: options[:type] == "development" | ||
| } | ||
|
|
||
| # Only specify keychain params in CI where we create a custom keychain | ||
| if is_ci | ||
| match_params[:keychain_name] = keychain_name | ||
| match_params[:keychain_password] = keychain_password | ||
| end | ||
|
|
||
| match(match_params) | ||
| end | ||
|
|
||
| private_lane :sign_app do |options| | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app_identifier = options[:app_identifier] | ||
| app_name = options[:app_name] || "Status.app" | ||
| profile_type = options[:profile_type] | ||
|
|
||
| app_path = File.join(BUILD_DIR, app_name) | ||
|
|
||
| unless File.exist?(app_path) | ||
| UI.user_error!("#{app_name} not found at #{app_path}") | ||
| end | ||
|
|
||
| # Use plutil to handle both binary and XML plist formats | ||
| plist_path = File.join(app_path, "Info.plist") | ||
| UI.message("Setting CFBundleIdentifier to #{app_identifier} in #{plist_path}") | ||
| sh("plutil -replace CFBundleIdentifier -string '#{app_identifier}' '#{plist_path}'") | ||
|
|
||
| UI.message("Signing app with identifier: #{app_identifier}") | ||
|
|
||
| profile_name = "match #{profile_type.capitalize} #{app_identifier}" | ||
|
|
||
| signing_identity = ENV["sigh_#{app_identifier}_#{profile_type}_certificate-name"] || | ||
| lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]&.dig(app_identifier) || | ||
| get_signing_identity(profile_type) | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Need to Sign all frameworks first, else App crashes at runtime | ||
| frameworks_path = File.join(app_path, "Frameworks") | ||
| if File.directory?(frameworks_path) | ||
| Dir.glob("#{frameworks_path}/*.framework").each do |framework| | ||
| UI.message("Signing framework: #{File.basename(framework)}") | ||
| sh("codesign --force --sign '#{signing_identity}' --timestamp '#{framework}'") | ||
| end | ||
| end | ||
|
|
||
| UI.message("Signing main app bundle...") | ||
|
|
||
| profile_path = ENV["sigh_#{app_identifier}_#{profile_type}_profile-path"] | ||
|
|
||
| if profile_path && File.exist?(profile_path) | ||
| FileUtils.cp(profile_path, File.join(app_path, "embedded.mobileprovision")) | ||
| end | ||
|
|
||
| # Extract entitlements from provisioning profile and sign with them | ||
| entitlements_path = File.join(Dir.tmpdir, "entitlements.plist") | ||
| decoded_profile_path = File.join(Dir.tmpdir, "profile_decoded.plist") | ||
| embedded_profile = File.join(app_path, "embedded.mobileprovision") | ||
| sh("security cms -D -i '#{embedded_profile}' > '#{decoded_profile_path}'") | ||
| sh("plutil -extract Entitlements xml1 -o '#{entitlements_path}' '#{decoded_profile_path}'") | ||
|
|
||
| sh("codesign --force --sign '#{signing_identity}' --entitlements '#{entitlements_path}' --timestamp '#{app_path}'") | ||
|
|
||
| UI.success("App signed successfully!") | ||
| end | ||
|
|
||
| private_lane :create_ipa do |options| | ||
| app_name = options[:app_name] || "Status.app" | ||
| ipa_name = app_name.sub(".app", ".ipa") | ||
|
|
||
| app_path = File.join(BUILD_DIR, app_name) | ||
| ipa_path = File.join(BUILD_DIR, ipa_name) | ||
|
|
||
| UI.message("Creating IPA at #{ipa_path}...") | ||
|
|
||
| FileUtils.rm_f(ipa_path) | ||
|
|
||
| Dir.mktmpdir do |tmpdir| | ||
| payload_dir = File.join(tmpdir, "Payload") | ||
| FileUtils.mkdir_p(payload_dir) | ||
| FileUtils.cp_r(app_path, payload_dir) | ||
|
|
||
| Dir.chdir(tmpdir) do | ||
| sh("zip -r '#{ipa_path}' Payload") | ||
| end | ||
| end | ||
|
|
||
| UI.success("IPA created at #{ipa_path}") | ||
| end | ||
|
|
||
| def keychain_name | ||
| "status_ci_#{ENV['BUILD_NUMBER'] || 'local'}.keychain" | ||
| end | ||
|
|
||
| def keychain_password | ||
| ENV["MATCH_PASSWORD"] || "fastlane_ci_password" | ||
| end | ||
|
|
||
| def get_signing_identity(profile_type) | ||
| case profile_type | ||
| when "development" | ||
| "Apple Development" | ||
| when "adhoc", "appstore" | ||
| "Apple Distribution" | ||
| else | ||
| "Apple Distribution" | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| source "https://rubygems.org" | ||
|
|
||
| ruby ">= 3.0.0", "< 4.0.0" | ||
siddarthkay marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Core dependencies | ||
| gem "fastlane", "~> 2.225" | ||
|
|
||
| plugins_path = File.join(File.dirname(__FILE__), 'Pluginfile') | ||
| eval_gemfile(plugins_path) if File.exist?(plugins_path) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.