fastlane 2.241.2 → 2.242.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -38
  3. data/cert/lib/cert/runner.rb +1 -1
  4. data/credentials_manager/README.md +3 -3
  5. data/credentials_manager/lib/credentials_manager/account_manager.rb +13 -3
  6. data/deliver/lib/deliver/runner.rb +5 -0
  7. data/fastlane/lib/assets/certificates/AppleIncRootCertificate.cer +0 -0
  8. data/fastlane/lib/assets/certificates/AppleRootCA-G3.cer +0 -0
  9. data/fastlane/lib/fastlane/action.rb +8 -6
  10. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +1 -1
  11. data/fastlane/lib/fastlane/actions/changelog_from_git_commits.rb +0 -3
  12. data/fastlane/lib/fastlane/actions/clipboard.rb +1 -1
  13. data/fastlane/lib/fastlane/actions/commit_version_bump.rb +0 -1
  14. data/fastlane/lib/fastlane/actions/create_keychain.rb +20 -29
  15. data/fastlane/lib/fastlane/actions/delete_keychain.rb +5 -3
  16. data/fastlane/lib/fastlane/actions/docs/build_app.md +1 -1
  17. data/fastlane/lib/fastlane/actions/docs/create_app_online.md +1 -1
  18. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +4 -4
  19. data/fastlane/lib/fastlane/actions/docs/get_provisioning_profile.md +1 -1
  20. data/fastlane/lib/fastlane/actions/docs/upload_to_app_store.md.erb +1 -1
  21. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +12 -0
  22. data/fastlane/lib/fastlane/actions/download_app_privacy_details_from_app_store.rb +5 -4
  23. data/fastlane/lib/fastlane/actions/download_dsyms.rb +3 -1
  24. data/fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb +1 -0
  25. data/fastlane/lib/fastlane/actions/git_pull.rb +1 -1
  26. data/fastlane/lib/fastlane/actions/hg_commit_version_bump.rb +0 -1
  27. data/fastlane/lib/fastlane/actions/import_certificate.rb +18 -6
  28. data/fastlane/lib/fastlane/actions/import_from_gem.rb +70 -0
  29. data/fastlane/lib/fastlane/actions/jazzy.rb +1 -1
  30. data/fastlane/lib/fastlane/actions/lcov.rb +1 -1
  31. data/fastlane/lib/fastlane/actions/mailgun.rb +2 -2
  32. data/fastlane/lib/fastlane/actions/make_changelog_from_jenkins.rb +1 -1
  33. data/fastlane/lib/fastlane/actions/notarize.rb +55 -7
  34. data/fastlane/lib/fastlane/actions/prompt.rb +1 -1
  35. data/fastlane/lib/fastlane/actions/push_to_git_remote.rb +2 -2
  36. data/fastlane/lib/fastlane/actions/sh.rb +20 -2
  37. data/fastlane/lib/fastlane/actions/sourcedocs.rb +2 -2
  38. data/fastlane/lib/fastlane/actions/swiftlint.rb +5 -2
  39. data/fastlane/lib/fastlane/actions/unlock_keychain.rb +17 -29
  40. data/fastlane/lib/fastlane/actions/update_fastlane.rb +10 -3
  41. data/fastlane/lib/fastlane/actions/update_project_code_signing.rb +2 -1
  42. data/fastlane/lib/fastlane/actions/update_project_provisioning.rb +21 -18
  43. data/fastlane/lib/fastlane/actions/upload_app_privacy_details_to_app_store.rb +1 -1
  44. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +8 -2
  45. data/fastlane/lib/fastlane/actions/verify_build.rb +2 -1
  46. data/fastlane/lib/fastlane/actions/verify_pod_keys.rb +2 -1
  47. data/fastlane/lib/fastlane/actions/xcodebuild.rb +1 -1
  48. data/fastlane/lib/fastlane/cli_tools_distributor.rb +7 -0
  49. data/fastlane/lib/fastlane/environment_printer.rb +14 -14
  50. data/fastlane/lib/fastlane/fast_file.rb +35 -4
  51. data/fastlane/lib/fastlane/helper/sh_helper.rb +27 -45
  52. data/fastlane/lib/fastlane/lane_list.rb +1 -1
  53. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +2 -2
  54. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +0 -2
  55. data/fastlane/lib/fastlane/runner.rb +4 -6
  56. data/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb +4 -4
  57. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +3 -3
  58. data/fastlane/lib/fastlane/version.rb +2 -1
  59. data/fastlane/swift/Deliverfile.swift +1 -1
  60. data/fastlane/swift/DeliverfileProtocol.swift +1 -1
  61. data/fastlane/swift/Fastlane.swift +46 -152
  62. data/fastlane/swift/Gymfile.swift +1 -1
  63. data/fastlane/swift/GymfileProtocol.swift +1 -1
  64. data/fastlane/swift/Matchfile.swift +1 -1
  65. data/fastlane/swift/MatchfileProtocol.swift +1 -1
  66. data/fastlane/swift/Precheckfile.swift +1 -1
  67. data/fastlane/swift/PrecheckfileProtocol.swift +1 -1
  68. data/fastlane/swift/Runner.swift +1 -1
  69. data/fastlane/swift/Scanfile.swift +1 -1
  70. data/fastlane/swift/ScanfileProtocol.swift +1 -1
  71. data/fastlane/swift/Screengrabfile.swift +1 -1
  72. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  73. data/fastlane/swift/Snapshotfile.swift +1 -1
  74. data/fastlane/swift/SnapshotfileProtocol.swift +1 -1
  75. data/fastlane_core/lib/fastlane_core/cert_checker.rb +40 -76
  76. data/fastlane_core/lib/fastlane_core/command_executor.rb +128 -7
  77. data/fastlane_core/lib/fastlane_core/configuration/config_item.rb +1 -1
  78. data/fastlane_core/lib/fastlane_core/configuration/configuration_file.rb +1 -1
  79. data/fastlane_core/lib/fastlane_core/device_manager.rb +14 -5
  80. data/fastlane_core/lib/fastlane_core/fastlane_pty.rb +25 -10
  81. data/fastlane_core/lib/fastlane_core/helper.rb +26 -2
  82. data/fastlane_core/lib/fastlane_core/ios_app_identifier_guesser.rb +1 -1
  83. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +24 -19
  84. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +48 -71
  85. data/fastlane_core/lib/fastlane_core/pkg_file_analyser.rb +5 -1
  86. data/fastlane_core/lib/fastlane_core/print_table.rb +1 -1
  87. data/fastlane_core/lib/fastlane_core/queue_worker.rb +0 -2
  88. data/fastlane_core/lib/fastlane_core/stored_passwords.rb +29 -0
  89. data/fastlane_core/lib/fastlane_core/string_filters.rb +1 -2
  90. data/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb +8 -4
  91. data/fastlane_core/lib/fastlane_core/ui/github_issue_inspector_reporter.rb +2 -2
  92. data/fastlane_core/lib/fastlane_core/ui/implementations/shell.rb +1 -1
  93. data/frameit/lib/frameit/device_types.rb +11 -4
  94. data/frameit/lib/frameit/editor.rb +31 -12
  95. data/frameit/lib/frameit/frame_downloader.rb +4 -1
  96. data/gym/lib/gym/detect_values.rb +10 -10
  97. data/gym/lib/gym/options.rb +1 -7
  98. data/gym/lib/gym/runner.rb +6 -1
  99. data/match/lib/match/encryption/encryption.rb +6 -1
  100. data/match/lib/match/encryption/openssl.rb +8 -3
  101. data/match/lib/match/portal_fetcher.rb +12 -6
  102. data/match/lib/match/runner.rb +2 -1
  103. data/pem/lib/pem/manager.rb +3 -3
  104. data/precheck/lib/precheck/runner.rb +4 -2
  105. data/scan/lib/scan/detect_values.rb +0 -1
  106. data/scan/lib/scan/runner.rb +1 -0
  107. data/sigh/lib/assets/resign.sh +10 -3
  108. data/sigh/lib/sigh/resign.rb +5 -21
  109. data/snapshot/lib/snapshot/reset_simulators.rb +5 -2
  110. data/snapshot/lib/snapshot/runner.rb +0 -1
  111. data/spaceship/lib/spaceship/base.rb +1 -1
  112. data/spaceship/lib/spaceship/client.rb +6 -3
  113. data/spaceship/lib/spaceship/connect_api/api_client.rb +12 -14
  114. data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +1 -1
  115. data/spaceship/lib/spaceship/connect_api/models/user.rb +7 -3
  116. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +9 -11
  117. data/spaceship/lib/spaceship/connect_api/token.rb +21 -1
  118. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +3 -1
  119. data/spaceship/lib/spaceship/helper/plist_middleware.rb +2 -2
  120. data/spaceship/lib/spaceship/portal/portal_client.rb +8 -8
  121. data/spaceship/lib/spaceship/test_flight/client.rb +1 -5
  122. data/supply/lib/supply/client.rb +1 -1
  123. data/supply/lib/supply/options.rb +6 -0
  124. data/supply/lib/supply/uploader.rb +28 -2
  125. metadata +29 -26
  126. data/fastlane/lib/fastlane/actions/hockey.rb +0 -400
  127. data/fastlane/lib/fastlane/actions/typetalk.rb +0 -93
@@ -1,5 +1,6 @@
1
1
  require 'fastlane_core/core_ext/cfpropertylist'
2
2
  require 'fastlane_core/project'
3
+ require 'security'
3
4
  require_relative 'module'
4
5
  require_relative 'code_signing_mapping'
5
6
 
@@ -41,8 +42,7 @@ module Gym
41
42
 
42
43
  # Make sure the output name is valid and remove a trailing `.ipa` extension
43
44
  # as it will be added by gym for free
44
- config[:output_name].gsub!(".ipa", "")
45
- config[:output_name].gsub!(File::SEPARATOR, "_")
45
+ config[:output_name] = config[:output_name].gsub(".ipa", "").gsub(File::SEPARATOR, "_")
46
46
 
47
47
  return config
48
48
  end
@@ -117,16 +117,16 @@ module Gym
117
117
  return
118
118
  end
119
119
 
120
- output = Helper.backticks("security find-certificate -a -c \"#{prefix}\"", print: false)
121
-
122
- # Find matches, filter by team_id, prepend prefix for full cert name
123
- certs = output.scan(/"(?:#{prefix})(.*)"/)
124
- certs = certs.flatten.uniq.select do |cert|
125
- cert.include?(team_id)
126
- end.map do |cert|
127
- prefix + cert
120
+ names = begin
121
+ Security::Certificate.find(name: prefix).map(&:name)
122
+ rescue Security::Error => e
123
+ UI.error("Could not search for installer certificates: #{e.message}")
124
+ []
128
125
  end
129
126
 
127
+ # Filter by team_id, the part after the prefix
128
+ certs = names.uniq.select { |name| name.start_with?(prefix) && name.delete_prefix(prefix).include?(team_id) }
129
+
130
130
  if certs.first
131
131
  UI.verbose("Detected installer certificate to use: #{certs.first}")
132
132
  Gym.config[:installer_cert_name] = certs.first
@@ -124,17 +124,11 @@ module Gym
124
124
  description: "Path to an export options plist or a hash with export options. Use 'xcodebuild -help' to print the full set of available options",
125
125
  optional: true,
126
126
  type: Hash,
127
- skip_type_validation: true,
128
- conflict_block: proc do |value|
129
- UI.user_error!("'#{value.key}' must be false to use 'export_options'")
130
- end),
127
+ skip_type_validation: true),
131
128
  FastlaneCore::ConfigItem.new(key: :export_xcargs,
132
129
  env_name: "GYM_EXPORT_XCARGS",
133
130
  description: "Pass additional arguments to xcodebuild for the package phase. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS=\"-ObjC -lstdc++\"",
134
131
  optional: true,
135
- conflict_block: proc do |value|
136
- UI.user_error!("'#{value.key}' must be false to use 'export_xcargs'")
137
- end,
138
132
  type: :shell_string),
139
133
  FastlaneCore::ConfigItem.new(key: :skip_build_archive,
140
134
  env_name: "GYM_SKIP_BUILD_ARCHIVE",
@@ -224,7 +224,12 @@ module Gym
224
224
 
225
225
  output_path = File.expand_path(File.join(Gym.config[:output_directory], Gym.config[:output_name] + ".app.dSYM.zip"))
226
226
  command = "cd #{containing_directory.shellescape} && zip -r #{output_path.shellescape} *.dSYM"
227
- Helper.backticks(command, print: !Gym.config[:silent])
227
+ FastlaneCore::CommandExecutor.execute(command: command,
228
+ print_all: !Gym.config[:silent],
229
+ print_command: !Gym.config[:silent],
230
+ error: proc do |output|
231
+ UI.user_error!("Could not compress the dSYM(s) to '#{output_path}':\n#{output}")
232
+ end)
228
233
  puts("") # new line
229
234
 
230
235
  UI.success("Successfully exported and compressed dSYM file")
@@ -1,6 +1,7 @@
1
1
  require 'base64'
2
2
  require 'openssl'
3
3
  require 'securerandom'
4
+ require 'fastlane_core/helper'
4
5
 
5
6
  module Match
6
7
  module Encryption
@@ -147,7 +148,11 @@ module Match
147
148
  content = File.read(file_path)
148
149
  e = MatchDataEncryption.new
149
150
  decrypted_data = e.decrypt(base64encoded_encrypted: content, password: password)
150
- File.binwrite(output_path, decrypted_data)
151
+ if File.extname(output_path) == ".p12"
152
+ FastlaneCore::Helper.open_owner_only(output_path, "wb") { |file| file.write(decrypted_data) }
153
+ else
154
+ File.binwrite(output_path, decrypted_data)
155
+ end
151
156
  end
152
157
  end
153
158
  end
@@ -67,6 +67,7 @@ module Match
67
67
  end
68
68
 
69
69
  def store_password(password)
70
+ return unless FastlaneCore::StoredPasswords.store?
70
71
  Security::InternetPassword.add(server_name(self.keychain_name), "", password)
71
72
  end
72
73
 
@@ -95,7 +96,11 @@ module Match
95
96
  unless password
96
97
  begin
97
98
  item = Security::InternetPassword.find(server: server_name(self.keychain_name))
98
- password = item.password if item
99
+ if item
100
+ password = item.password
101
+ server = server_name(self.keychain_name)
102
+ FastlaneCore::StoredPasswords.read_warning(server, what: "the match passphrase", remove_with: "security delete-internet-password -s #{server}", instead: "provide it with the MATCH_PASSWORD environment variable")&.each { |line| UI.important(line) }
103
+ end
99
104
  rescue Security::Error => ex
100
105
  UI.important("Could not read the local keychain: #{ex.message}")
101
106
  end
@@ -105,10 +110,10 @@ module Match
105
110
  if !UI.interactive?
106
111
  UI.error("Neither the MATCH_PASSWORD environment variable nor the local keychain contained a password.")
107
112
  UI.error("Bailing out instead of asking for a password, since this is non-interactive mode.")
108
- UI.user_error!("Try setting the MATCH_PASSWORD environment variable, or temporarily enable interactive mode to store a password.")
113
+ UI.user_error!("Try setting the MATCH_PASSWORD environment variable.")
109
114
  else
110
115
  UI.important("Enter the passphrase that should be used to encrypt/decrypt your certificates")
111
- UI.important("This passphrase is specific per repository and will be stored in your local keychain")
116
+ UI.important(FastlaneCore::StoredPasswords.store? ? "This passphrase is specific per repository and will be stored in your local keychain" : "This passphrase is specific per repository")
112
117
  UI.important("Make sure to remember the password, as you'll need it when you run match on a different machine")
113
118
  password = FastlaneCore::Helper.ask_password(message: "Passphrase for Match storage: ", confirm: true)
114
119
  store_password(password)
@@ -58,14 +58,20 @@ module Match
58
58
  devices
59
59
  end
60
60
 
61
- def self.bundle_ids(bundle_id_identifiers: nil)
62
- filter = { identifier: bundle_id_identifiers.join(',') } if bundle_id_identifiers
61
+ # App Store Connect refuses a filter value longer than 5000 characters; fastlane#29783 saw failures below that.
62
+ MAX_BUNDLE_ID_FILTER_LENGTH = 3500
63
63
 
64
- bundle_ids = Spaceship::ConnectAPI::BundleId.all(
65
- filter: filter
66
- )
64
+ def self.bundle_ids(bundle_id_identifiers: nil, max_bundle_id_filter_length: MAX_BUNDLE_ID_FILTER_LENGTH)
65
+ return Spaceship::ConnectAPI::BundleId.all(filter: nil) unless bundle_id_identifiers
67
66
 
68
- bundle_ids
67
+ filters = bundle_id_identifiers.each_with_object([]) do |identifier, list|
68
+ if list.empty? || list.last.length + 1 + identifier.length > max_bundle_id_filter_length
69
+ list << identifier.dup
70
+ else
71
+ list.last << ",#{identifier}"
72
+ end
73
+ end
74
+ filters.flat_map { |filter| Spaceship::ConnectAPI::BundleId.all(filter: { identifier: filter }) }
69
75
  end
70
76
  end
71
77
  end
@@ -250,7 +250,8 @@ module Match
250
250
 
251
251
  if params[:output_path]
252
252
  FileUtils.cp(cert_path, params[:output_path])
253
- FileUtils.cp(select_cert_or_key(paths: keys, certificate_id: certificate_id), params[:output_path])
253
+ key_path = select_cert_or_key(paths: keys, certificate_id: certificate_id)
254
+ FastlaneCore::Helper.open_owner_only(File.join(params[:output_path], File.basename(key_path)), "wb") { |file| IO.copy_stream(key_path, file) }
254
255
  end
255
256
 
256
257
  # Get and print info of certificate
@@ -73,7 +73,7 @@ module PEM
73
73
 
74
74
  if PEM.config[:save_private_key]
75
75
  private_key_path = File.join(output_path, "#{filename_base}.pkey")
76
- File.write(private_key_path, pkey.to_pem)
76
+ FastlaneCore::Helper.open_owner_only(private_key_path) { |file| file.write(pkey.to_pem) }
77
77
  UI.message("Private key: ".green + Pathname.new(private_key_path).realpath.to_s)
78
78
  end
79
79
 
@@ -81,12 +81,12 @@ module PEM
81
81
  p12_cert_path = File.join(output_path, "#{filename_base}.p12")
82
82
  p12_password = PEM.config[:p12_password] == "" ? nil : PEM.config[:p12_password]
83
83
  p12 = OpenSSL::PKCS12.create(p12_password, certificate_type, pkey, x509_certificate)
84
- File.write(p12_cert_path, p12.to_der.force_encoding("UTF-8"))
84
+ FastlaneCore::Helper.open_owner_only(p12_cert_path) { |file| file.write(p12.to_der.force_encoding("UTF-8")) }
85
85
  UI.message("p12 certificate: ".green + Pathname.new(p12_cert_path).realpath.to_s)
86
86
  end
87
87
 
88
88
  x509_cert_path = File.join(output_path, "#{filename_base}.pem")
89
- File.write(x509_cert_path, x509_certificate.to_pem + pkey.to_pem)
89
+ FastlaneCore::Helper.open_owner_only(x509_cert_path) { |file| file.write(x509_certificate.to_pem + pkey.to_pem) }
90
90
  UI.message("PEM: ".green + Pathname.new(x509_cert_path).realpath.to_s)
91
91
  return x509_cert_path
92
92
  end
@@ -8,6 +8,9 @@ require_relative 'options'
8
8
 
9
9
  module Precheck
10
10
  class Runner
11
+ class BlockingViolationError < FastlaneCore::Interface::FastlaneError
12
+ end
13
+
11
14
  attr_accessor :spaceship
12
15
 
13
16
  # Uses the spaceship to download app metadata and then run all rule checkers
@@ -67,8 +70,7 @@ module Precheck
67
70
  end
68
71
 
69
72
  if processor_result.should_trigger_user_error?
70
- UI.user_error!("precheck 👮‍♀️ 👮 found one or more potential problems that must be addressed before submitting to review")
71
- return false
73
+ raise BlockingViolationError, "precheck 👮‍♀️ 👮 found one or more potential problems that must be addressed before submitting to review"
72
74
  end
73
75
 
74
76
  if processor_result.has_errors_or_warnings?
@@ -1,7 +1,6 @@
1
1
  require 'fastlane_core/device_manager'
2
2
  require 'fastlane_core/project'
3
3
  require 'pathname'
4
- require 'set'
5
4
  require_relative 'module'
6
5
 
7
6
  module Scan
@@ -378,6 +378,7 @@ module Scan
378
378
  end
379
379
 
380
380
  def test_results
381
+ UI.deprecated("Scan::Runner#test_results is deprecated and will be removed in a future version of fastlane; scan no longer uses it. Read the test results from the result bundle with Trainer::TestParser.")
381
382
  temp_junit_report = Scan.cache[:temp_junit_report]
382
383
  return File.read(temp_junit_report) if temp_junit_report && File.file?(temp_junit_report)
383
384
 
@@ -383,10 +383,17 @@ function provision_for_bundle_id {
383
383
  done
384
384
  }
385
385
 
386
+ # Print the plist inside a provisioning profile. Unlike `security cms -D`, this imports no certificate
387
+ # into the default keychain (#30186). Like it, it does not check the signature.
388
+ function decode_provision {
389
+
390
+ /usr/bin/openssl smime -verify -noverify -nosigs -inform DER -in "$1" 2> >(grep -v '^Verification successful$' >&2)
391
+ }
392
+
386
393
  # Find the bundle identifier contained inside a provisioning profile
387
394
  function bundle_id_for_provision {
388
395
 
389
- local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(security cms -D -i "$1")")
396
+ local FULL_BUNDLE_ID=$(PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< "$(decode_provision "$1")")
390
397
  checkStatus
391
398
  echo "${FULL_BUNDLE_ID#*.}"
392
399
  }
@@ -502,7 +509,7 @@ function resign {
502
509
 
503
510
  # Replace the embedded mobile provisioning profile
504
511
  log "Validating the new provisioning profile: $NEW_PROVISION"
505
- security cms -D -i "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
512
+ decode_provision "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
506
513
  checkStatus
507
514
 
508
515
  APP_IDENTIFIER_PREFIX=$(PlistBuddy -c "Print :Entitlements:application-identifier" "$TEMP_DIR/profile.plist" | grep -E '^[A-Z0-9]*' -o | tr -d '\n')
@@ -681,7 +688,7 @@ function resign {
681
688
 
682
689
  # Get the old and the new team ID
683
690
  # Old team ID is not part of app entitlements, have to get it from old embedded provisioning profile
684
- security cms -D -i "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
691
+ decode_provision "$TEMP_DIR/old-embedded.mobileprovision" > "$TEMP_DIR/old-embedded-profile.plist"
685
692
  OLD_TEAM_ID=$(PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/old-embedded-profile.plist" 2>/dev/null)
686
693
  if [ "$OLD_TEAM_ID" == "" ]; then
687
694
  OLD_TEAM_ID="$OLD_APP_ID"
@@ -1,4 +1,5 @@
1
1
  require 'shellwords'
2
+ require 'security'
2
3
  require 'fastlane_core/globals'
3
4
 
4
5
  require_relative 'module'
@@ -25,12 +26,11 @@ module Sigh
25
26
  if keychain_path
26
27
  keychain_path_absolute = File.expand_path(keychain_path)
27
28
 
28
- current_keychains = `security list-keychains`
29
- current_keychains.delete!("\n")
29
+ current_keychains = Security::Keychain.list(:user).map(&:filename)
30
30
 
31
31
  unless current_keychains.include?(keychain_path_absolute)
32
32
  previous_keychains = current_keychains
33
- `security list-keychains -s #{current_keychains} '#{keychain_path_absolute}'`
33
+ Security::Keychain.set_search_list(current_keychains + [keychain_path_absolute])
34
34
  end
35
35
  end
36
36
 
@@ -84,7 +84,7 @@ module Sigh
84
84
  false
85
85
  end
86
86
  ensure
87
- `security list-keychains -s #{previous_keychains}` if previous_keychains
87
+ Security::Keychain.set_search_list(previous_keychains) if previous_keychains
88
88
  end
89
89
 
90
90
  def get_inputs(options, args)
@@ -189,23 +189,7 @@ module Sigh
189
189
 
190
190
  # Hash of available signing identities
191
191
  def installed_identities
192
- available = request_valid_identities
193
- ids = {}
194
- available.split("\n").each do |current|
195
- begin
196
- sha1 = current.match(/[a-zA-Z0-9]{40}/).to_s
197
- name = current.match(/.*\"(.*)\"/)[1]
198
- ids[sha1] = name
199
- rescue
200
- nil
201
- end # the last line does not match
202
- end
203
-
204
- ids
205
- end
206
-
207
- def request_valid_identities
208
- `security find-identity -v -p codesigning`
192
+ Security::Identity.find.to_h { |identity| [identity.sha1, identity.name] }
209
193
  end
210
194
 
211
195
  def installed_identity_descriptions
@@ -18,6 +18,11 @@ module Snapshot
18
18
 
19
19
  UI.abort_with_message!("User cancelled action") unless sure
20
20
 
21
+ # Listed before deleting: with nothing listed, nothing would be created again
22
+ all_runtime_type = runtimes
23
+ all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
24
+ UI.user_error!("`xcrun simctl list` returned no runtimes or no device types; no simulator was deleted") if all_runtime_type.empty? || all_device_types.empty?
25
+
21
26
  if ios_versions
22
27
  ios_versions.each do |version|
23
28
  FastlaneCore::Simulator.delete_all_by_version(os_version: version)
@@ -29,7 +34,6 @@ module Snapshot
29
34
  FastlaneCore::SimulatorTV.delete_all
30
35
  FastlaneCore::SimulatorWatch.delete_all
31
36
 
32
- all_runtime_type = runtimes
33
37
  # == Runtimes ==
34
38
  # iOS 9.3 (9.3 - 13E233) (com.apple.CoreSimulator.SimRuntime.iOS-9-3)
35
39
  # iOS 10.0 (10.0 - 14A345) (com.apple.CoreSimulator.SimRuntime.iOS-10-0)
@@ -47,7 +51,6 @@ module Snapshot
47
51
  tv_version_ids = filter_runtimes(all_runtime_type, 'tvOS')
48
52
  watch_versions_ids = filter_runtimes(all_runtime_type, 'watchOS')
49
53
 
50
- all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
51
54
  # == Device Types ==
52
55
  # iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
53
56
  # iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
@@ -1,7 +1,6 @@
1
1
  require 'shellwords'
2
2
  require 'plist'
3
3
  require 'os'
4
- require 'thread'
5
4
  require 'terminal-table'
6
5
 
7
6
  require 'fastlane_core/print_table'
@@ -181,7 +181,7 @@ module Spaceship
181
181
  # ProvisioningProfile.some_other_method
182
182
  # #=> NoMethodError: undefined method `some_other_method' for ProvisioningProfile
183
183
  def method_missing(method_sym, *args, &block)
184
- module_name = method_sym.to_s
184
+ module_name = method_sym.to_s.dup
185
185
  module_name.sub!(/^[a-z\d]/) { $&.upcase }
186
186
  module_name.gsub!(%r{(?:_|(/))([a-z\d])}) { $2.upcase }
187
187
  if const_defined?(module_name)
@@ -1189,15 +1189,18 @@ module Spaceship
1189
1189
 
1190
1190
  handle_error(response)
1191
1191
 
1192
- if response.body.to_s.include?("<title>302 Found</title>")
1192
+ # Error pages are HTML; converting a parsed JSON or plist body to a string for each check is slow on large responses
1193
+ body = response.body.kind_of?(String) ? response.body : ""
1194
+
1195
+ if body.include?("<title>302 Found</title>")
1193
1196
  raise AppleTimeoutError.new, "Apple 302 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime"
1194
1197
  end
1195
1198
 
1196
- if response.body.to_s.include?("<h3>Bad Gateway</h3>")
1199
+ if body.include?("<h3>Bad Gateway</h3>")
1197
1200
  raise BadGatewayError.new, "Apple 502 detected - this might be temporary server error, try again later"
1198
1201
  end
1199
1202
 
1200
- if response.body.to_s.include?("<title>503 Service Temporarily Unavailable</title>") || response.body.to_s.include?("<h1>503 Service Temporarily Unavailable</h1>")
1203
+ if body.include?("<title>503 Service Temporarily Unavailable</title>") || body.include?("<h1>503 Service Temporarily Unavailable</h1>")
1201
1204
  raise AppleTimeoutError.new, "Apple 503 detected - this might be temporary server error, check https://developer.apple.com/system-status/ to see if there is a known downtime"
1202
1205
  end
1203
1206
 
@@ -169,8 +169,7 @@ module Spaceship
169
169
  status = response.status if response
170
170
 
171
171
  if [500, 504].include?(status)
172
- msg = "Timeout received! Retrying after 3 seconds (remaining: #{tries})..."
173
- raise TimeoutRetryError, msg
172
+ raise TimeoutRetryError, "Server error got #{status}"
174
173
  end
175
174
 
176
175
  if status == 429
@@ -191,10 +190,10 @@ module Spaceship
191
190
  end
192
191
  rescue TimeoutRetryError => error
193
192
  tries -= 1
194
- puts(error) if Spaceship::Globals.verbose?
195
193
  if tries.zero?
196
194
  return response
197
195
  else
196
+ puts("#{error.message}, retrying (remaining: #{tries})...") if Spaceship::Globals.verbose?
198
197
  retry
199
198
  end
200
199
  rescue TooManyRequestsError => error
@@ -233,7 +232,7 @@ module Spaceship
233
232
  def handle_error(response)
234
233
  body = response.body.empty? ? {} : response.body
235
234
 
236
- # Setting body nil if invalid JSON which can happen if 502
235
+ # A body that is not JSON, such as a 502 page, stays a String
237
236
  begin
238
237
  body = JSON.parse(body) if body.kind_of?(String)
239
238
  rescue
@@ -244,7 +243,8 @@ module Spaceship
244
243
  when 401
245
244
  raise UnauthorizedAccessError, format_errors(response)
246
245
  when 403
247
- error = (body['errors'] || []).first || {}
246
+ errors = body['errors'] if body.kind_of?(Hash)
247
+ error = (errors || []).first || {}
248
248
  error_code = error['code']
249
249
  if error_code == "FORBIDDEN.REQUIRED_AGREEMENTS_MISSING_OR_EXPIRED"
250
250
  raise ProgramLicenseAgreementUpdated, format_errors(response)
@@ -335,7 +335,13 @@ module Spaceship
335
335
  # }
336
336
 
337
337
  body = response.body.empty? ? {} : response.body
338
- body = JSON.parse(body) if body.kind_of?(String)
338
+ if body.kind_of?(String)
339
+ begin
340
+ body = JSON.parse(body)
341
+ rescue JSON::ParserError
342
+ return body # not JSON, such as an HTML error page
343
+ end
344
+ end
339
345
 
340
346
  formatted_errors = (body['errors'] || []).map do |error|
341
347
  messages = [[error['title'], error['detail'], error.dig("source", "pointer")].compact.join(" - ")]
@@ -357,14 +363,6 @@ module Spaceship
357
363
 
358
364
  private
359
365
 
360
- def local_variable_get(binding, name)
361
- if binding.respond_to?(:local_variable_get)
362
- binding.local_variable_get(name)
363
- else
364
- binding.eval(name.to_s)
365
- end
366
- end
367
-
368
366
  def provider_id
369
367
  return team_id if self.provider.nil?
370
368
  self.provider.provider_id
@@ -41,7 +41,7 @@ module Spaceship
41
41
 
42
42
  def self.all(client: nil, filter: {}, includes: nil, fields: nil, limit: Spaceship::ConnectAPI::MAX_OBJECTS_PER_PAGE_LIMIT, sort: nil)
43
43
  client ||= Spaceship::ConnectAPI
44
- resps = client.get_bundle_ids(filter: filter, includes: includes, fields: fields, limit: nil, sort: nil).all_pages
44
+ resps = client.get_bundle_ids(filter: filter, includes: includes, fields: fields, limit: limit, sort: sort).all_pages
45
45
  return resps.flat_map(&:to_models)
46
46
  end
47
47
 
@@ -1,4 +1,5 @@
1
1
  require_relative '../model'
2
+
2
3
  module Spaceship
3
4
  class ConnectAPI
4
5
  class User
@@ -56,19 +57,22 @@ module Spaceship
56
57
  CUSTOMER_SUPPORT = "CUSTOMER_SUPPORT"
57
58
  end
58
59
 
60
+ # Not at the top: connect_api loads user_invitation.rb, which reads UserRole while it loads
61
+ require_relative '../../connect_api'
62
+
59
63
  #
60
64
  # API
61
65
  #
62
66
 
63
- def self.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: nil, sort: nil)
67
+ def self.all(client: nil, filter: {}, includes: ESSENTIAL_INCLUDES, limit: Spaceship::ConnectAPI::MAX_OBJECTS_PER_PAGE_LIMIT, sort: nil)
64
68
  client ||= Spaceship::ConnectAPI
65
- resps = client.get_users(filter: filter, includes: includes).all_pages
69
+ resps = client.get_users(filter: filter, includes: includes, limit: limit, sort: sort).all_pages
66
70
  return resps.flat_map(&:to_models)
67
71
  end
68
72
 
69
73
  def self.find(client: nil, email: nil, includes: ESSENTIAL_INCLUDES)
70
74
  client ||= Spaceship::ConnectAPI
71
- return all(client: client, filter: { email: email }, includes: includes)
75
+ return all(client: client, filter: { username: email }, includes: includes)
72
76
  end
73
77
 
74
78
  # @param client [ConnectAPI] ConnectAPI client.
@@ -209,22 +209,20 @@ module Spaceship
209
209
  end
210
210
 
211
211
  def create_beta_group(app_id: nil, group_name: nil, is_internal_group: false, public_link_enabled: false, public_link_limit: 10_000, public_link_limit_enabled: false, has_access_to_all_builds: nil)
212
+ attributes = { name: group_name, isInternalGroup: is_internal_group }
212
213
  if is_internal_group
213
- has_access_to_all_builds = true if has_access_to_all_builds.nil?
214
+ # Apple's docs don't say which groups take hasAccessToAllBuilds; fastlane sends it for internal groups only, as since #21478
215
+ attributes[:hasAccessToAllBuilds] = has_access_to_all_builds.nil? ? true : has_access_to_all_builds
214
216
  else
215
- # Access to all builds is only for internal groups
216
- has_access_to_all_builds = nil
217
+ attributes.merge!(
218
+ publicLinkEnabled: public_link_enabled,
219
+ publicLinkLimit: public_link_limit,
220
+ publicLinkLimitEnabled: public_link_limit_enabled
221
+ )
217
222
  end
218
223
  body = {
219
224
  data: {
220
- attributes: {
221
- name: group_name,
222
- isInternalGroup: is_internal_group,
223
- hasAccessToAllBuilds: has_access_to_all_builds, # Undocumented of 2021-08-02 in ASC API docs and ASC Open API spec. This is the default behavior on App Store Connect and does work with both Apple ID and API Token
224
- publicLinkEnabled: public_link_enabled,
225
- publicLinkLimit: public_link_limit,
226
- publicLinkLimitEnabled: public_link_limit_enabled
227
- },
225
+ attributes: attributes,
228
226
  relationships: {
229
227
  app: {
230
228
  data: {
@@ -125,7 +125,27 @@ module Spaceship
125
125
  end
126
126
 
127
127
  def write_key_to_file(path)
128
- File.open(path, 'w') { |f| f.write(@key_raw) }
128
+ return unless @key_raw.kind_of?(String)
129
+
130
+ lines = @key_raw.lines.map(&:chomp)
131
+
132
+ if lines.size == 3 && lines.first.include?("BEGIN") && lines.last.include?("END")
133
+ header = lines.first
134
+ footer = lines.last
135
+ raw_base64 = lines[1].gsub(/\s+/, "") # Remove any whitespace
136
+
137
+ # Rewrap base64 content at 64 characters per line
138
+ wrapped = raw_base64.scan(/.{1,64}/).join("\n")
139
+
140
+ File.open(path, 'w') do |f|
141
+ f.puts(header)
142
+ f.puts(wrapped)
143
+ f.puts(footer)
144
+ end
145
+ else
146
+ # Fall back to writing raw (likely already well-formatted)
147
+ File.write(path, @key_raw)
148
+ end
129
149
  end
130
150
  end
131
151
  end
@@ -1114,7 +1114,9 @@ module Spaceship
1114
1114
  }
1115
1115
  }
1116
1116
 
1117
- tunes_request_client.post("#{Version::V1}/appStoreVersionReleaseRequests", body)
1117
+ # App Store Connect can return a 500/504 after it has accepted the release request. A retry is then
1118
+ # rejected because the version is already being released, so leave it to the caller to check the version state
1119
+ tunes_request_client.post("#{Version::V1}/appStoreVersionReleaseRequests", body, tries: 1)
1118
1120
  end
1119
1121
 
1120
1122
  #
@@ -10,13 +10,13 @@ module Spaceship
10
10
 
11
11
  def process_response(env)
12
12
  env.body = parse(env.body)
13
+ rescue StandardError, SyntaxError => e
14
+ raise Faraday::ParsingError.new(e, env[:response])
13
15
  end
14
16
 
15
17
  def parse(body)
16
18
  require 'plist' unless Object.const_defined?("Plist")
17
19
  Plist.parse_xml(body.force_encoding("UTF-8"))
18
- rescue StandardError, SyntaxError => e
19
- raise Faraday::ParsingError.new(e, env)
20
20
  end
21
21
 
22
22
  def parse_response?(env)