fastlane 2.161.0 → 2.166.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +78 -78
  3. data/cert/lib/cert/options.rb +28 -1
  4. data/cert/lib/cert/runner.rb +51 -34
  5. data/deliver/lib/deliver/.upload_screenshots.rb.swp +0 -0
  6. data/deliver/lib/deliver/app_screenshot_iterator.rb +4 -4
  7. data/deliver/lib/deliver/module.rb +2 -0
  8. data/deliver/lib/deliver/options.rb +5 -5
  9. data/deliver/lib/deliver/queue_worker.rb +14 -29
  10. data/deliver/lib/deliver/upload_metadata.rb +20 -5
  11. data/deliver/lib/deliver/upload_screenshots.rb +28 -13
  12. data/fastlane/lib/fastlane/actions/.download_dsyms.rb.swp +0 -0
  13. data/fastlane/lib/fastlane/actions/actions_helper.rb +1 -1
  14. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +39 -3
  15. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +9 -0
  16. data/fastlane/lib/fastlane/actions/appledoc.rb +1 -1
  17. data/fastlane/lib/fastlane/actions/check_app_store_metadata.rb +1 -0
  18. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +5 -1
  19. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +9 -0
  20. data/fastlane/lib/fastlane/actions/get_certificates.rb +1 -0
  21. data/fastlane/lib/fastlane/actions/get_provisioning_profile.rb +1 -0
  22. data/fastlane/lib/fastlane/actions/import_from_git.rb +9 -1
  23. data/fastlane/lib/fastlane/actions/is_ci.rb +1 -1
  24. data/fastlane/lib/fastlane/actions/latest_testflight_build_number.rb +15 -0
  25. data/fastlane/lib/fastlane/actions/register_device.rb +46 -5
  26. data/fastlane/lib/fastlane/actions/register_devices.rb +50 -16
  27. data/fastlane/lib/fastlane/actions/set_changelog.rb +31 -3
  28. data/fastlane/lib/fastlane/actions/sync_code_signing.rb +1 -0
  29. data/fastlane/lib/fastlane/actions/update_fastlane.rb +24 -8
  30. data/fastlane/lib/fastlane/actions/upload_to_app_store.rb +3 -2
  31. data/fastlane/lib/fastlane/cli_tools_distributor.rb +1 -1
  32. data/fastlane/lib/fastlane/fast_file.rb +74 -23
  33. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +1 -0
  34. data/fastlane/lib/fastlane/swift_fastlane_function.rb +1 -1
  35. data/fastlane/lib/fastlane/version.rb +1 -1
  36. data/fastlane/swift/Deliverfile.swift +1 -1
  37. data/fastlane/swift/DeliverfileProtocol.swift +4 -4
  38. data/fastlane/swift/Fastlane.swift +119 -23
  39. data/fastlane/swift/Gymfile.swift +1 -1
  40. data/fastlane/swift/GymfileProtocol.swift +1 -1
  41. data/fastlane/swift/LaneFileProtocol.swift +15 -19
  42. data/fastlane/swift/MainProcess.swift +1 -1
  43. data/fastlane/swift/Matchfile.swift +1 -1
  44. data/fastlane/swift/MatchfileProtocol.swift +20 -4
  45. data/fastlane/swift/Precheckfile.swift +1 -1
  46. data/fastlane/swift/PrecheckfileProtocol.swift +1 -1
  47. data/fastlane/swift/Scanfile.swift +1 -1
  48. data/fastlane/swift/ScanfileProtocol.swift +5 -1
  49. data/fastlane/swift/Screengrabfile.swift +1 -1
  50. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  51. data/fastlane/swift/Snapshotfile.swift +1 -1
  52. data/fastlane/swift/SnapshotfileProtocol.swift +1 -1
  53. data/fastlane/swift/main.swift +1 -1
  54. data/fastlane_core/lib/fastlane_core/analytics/analytics_session.rb +6 -7
  55. data/fastlane_core/lib/fastlane_core/device_manager.rb +8 -4
  56. data/fastlane_core/lib/fastlane_core/helper.rb +10 -2
  57. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +3 -3
  58. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +3 -3
  59. data/gym/lib/gym/generators/package_command_generator_xcode7.rb +2 -2
  60. data/match/lib/match/generator.rb +6 -1
  61. data/match/lib/match/importer.rb +63 -18
  62. data/match/lib/match/migrate.rb +13 -2
  63. data/match/lib/match/nuke.rb +65 -22
  64. data/match/lib/match/options.rb +33 -2
  65. data/match/lib/match/runner.rb +38 -10
  66. data/match/lib/match/spaceship_ensure.rb +27 -21
  67. data/match/lib/match/storage/google_cloud_storage.rb +20 -3
  68. data/match/lib/match/storage/s3_storage.rb +19 -3
  69. data/scan/lib/scan/detect_values.rb +8 -9
  70. data/scan/lib/scan/module.rb +4 -0
  71. data/scan/lib/scan/options.rb +9 -0
  72. data/scan/lib/scan/runner.rb +2 -1
  73. data/sigh/lib/assets/resign.sh +1 -1
  74. data/sigh/lib/sigh/download_all.rb +16 -4
  75. data/sigh/lib/sigh/options.rb +21 -0
  76. data/sigh/lib/sigh/runner.rb +83 -41
  77. data/snapshot/lib/assets/SnapshotHelper.swift +4 -0
  78. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +2 -1
  79. data/snapshot/lib/snapshot/test_command_generator.rb +1 -1
  80. data/snapshot/lib/snapshot/test_command_generator_base.rb +3 -1
  81. data/snapshot/lib/snapshot/test_command_generator_xcode_8.rb +1 -1
  82. data/spaceship/lib/spaceship/client.rb +9 -4
  83. data/spaceship/lib/spaceship/connect_api.rb +27 -0
  84. data/spaceship/lib/spaceship/connect_api/api_client.rb +12 -3
  85. data/spaceship/lib/spaceship/connect_api/client.rb +20 -7
  86. data/spaceship/lib/spaceship/connect_api/models/app.rb +51 -0
  87. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +3 -1
  88. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +2 -1
  89. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +42 -0
  90. data/spaceship/lib/spaceship/connect_api/models/custom_app_organization.rb +43 -0
  91. data/spaceship/lib/spaceship/connect_api/models/custom_app_user.rb +41 -0
  92. data/spaceship/lib/spaceship/connect_api/models/device.rb +5 -0
  93. data/spaceship/lib/spaceship/connect_api/models/profile.rb +7 -1
  94. data/spaceship/lib/spaceship/connect_api/models/user_invitation.rb +59 -0
  95. data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +45 -2
  96. data/spaceship/lib/spaceship/connect_api/spaceship.rb +7 -4
  97. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +13 -0
  98. data/spaceship/lib/spaceship/connect_api/token.rb +6 -1
  99. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +71 -0
  100. data/spaceship/lib/spaceship/connect_api/users/users.rb +40 -0
  101. data/supply/lib/supply.rb +1 -1
  102. data/supply/lib/supply/uploader.rb +1 -1
  103. metadata +24 -18
@@ -28,10 +28,17 @@ module Match
28
28
  google_cloud_bucket_name: params[:google_cloud_bucket_name].to_s,
29
29
  google_cloud_keys_file: params[:google_cloud_keys_file].to_s,
30
30
  google_cloud_project_id: params[:google_cloud_project_id].to_s,
31
+ s3_bucket: params[:s3_bucket],
32
+ s3_region: params[:s3_region],
33
+ s3_access_key: params[:s3_access_key],
34
+ s3_secret_access_key: params[:s3_secret_access_key],
35
+ s3_object_prefix: params[:s3_object_prefix],
31
36
  readonly: params[:readonly],
32
37
  username: params[:username],
33
38
  team_id: params[:team_id],
34
- team_name: params[:team_name]
39
+ team_name: params[:team_name],
40
+ api_key_path: params[:api_key_path],
41
+ api_key: params[:api_key]
35
42
  })
36
43
  storage.download
37
44
 
@@ -48,11 +55,25 @@ module Match
48
55
 
49
56
  case cert_type
50
57
  when :development
51
- certificate_type = Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DEVELOPMENT + "," + Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT
58
+ certificate_type = [
59
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DEVELOPMENT,
60
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DEVELOPMENT,
61
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT
62
+ ].join(',')
52
63
  when :distribution, :enterprise
53
- certificate_type = Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION + "," + Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION
64
+ certificate_type = [
65
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION,
66
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DISTRIBUTION,
67
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION
68
+ ].join(',')
54
69
  when :developer_id_application
55
- certificate_type = Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPER_ID_APPLICATION
70
+ certificate_type = [
71
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPER_ID_APPLICATION
72
+ ].join(',')
73
+ when :mac_installer_distribution
74
+ certificate_type = [
75
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_INSTALLER_DISTRIBUTION
76
+ ].join(',')
56
77
  else
57
78
  UI.user_error!("Cert type '#{cert_type}' is not supported")
58
79
  end
@@ -61,23 +82,41 @@ module Match
61
82
  output_dir_certs = File.join(storage.prefixed_working_directory, "certs", cert_type.to_s)
62
83
  output_dir_profiles = File.join(storage.prefixed_working_directory, "profiles", prov_type.to_s)
63
84
 
64
- # Need to get the cert id by comparing base64 encoded cert content with certificate content from the API responses
65
- Spaceship::Portal.login(params[:username])
66
- Spaceship::Portal.select_team(team_id: params[:team_id], team_name: params[:team_name])
67
- certs = Spaceship::ConnectAPI::Certificate.all(filter: { certificateType: certificate_type })
85
+ should_skip_certificate_matching = params[:skip_certificate_matching]
86
+ # In case there is no access to Apple Developer portal but we have the certificates, keys and profiles
87
+ if should_skip_certificate_matching
88
+ cert_name = File.basename(cert_path, ".*")
89
+ p12_name = File.basename(p12_path, ".*")
68
90
 
69
- # Base64 encode contents to find match from API to find a cert ID
70
- cert_contents_base_64 = Base64.strict_encode64(File.binread(cert_path))
71
- matching_cert = certs.find do |cert|
72
- cert.certificate_content == cert_contents_base_64
73
- end
91
+ # Make dir if doesn't exist
92
+ FileUtils.mkdir_p(output_dir_certs)
93
+ dest_cert_path = File.join(output_dir_certs, "#{cert_name}.cer")
94
+ dest_p12_path = File.join(output_dir_certs, "#{p12_name}.p12")
95
+ else
96
+ # Need to get the cert id by comparing base64 encoded cert content with certificate content from the API responses
97
+ token = api_token(params)
98
+ if token
99
+ UI.message("Creating authorization token for App Store Connect API")
100
+ Spaceship::ConnectAPI.token = token
101
+ else
102
+ UI.message("Login to App Store Connect (#{params[:username]})")
103
+ Spaceship::ConnectAPI.login(params[:username], use_portal: true, use_tunes: false, portal_team_id: params[:team_id], team_name: params[:team_name])
104
+ end
105
+ certs = Spaceship::ConnectAPI::Certificate.all(filter: { certificateType: certificate_type })
106
+
107
+ # Base64 encode contents to find match from API to find a cert ID
108
+ cert_contents_base_64 = Base64.strict_encode64(File.binread(cert_path))
109
+ matching_cert = certs.find do |cert|
110
+ cert.certificate_content == cert_contents_base_64
111
+ end
74
112
 
75
- UI.user_error!("This certificate cannot be imported - the certificate contents did not match with any available on the Developer Portal") if matching_cert.nil?
113
+ UI.user_error!("This certificate cannot be imported - the certificate contents did not match with any available on the Developer Portal") if matching_cert.nil?
76
114
 
77
- # Make dir if doesn't exist
78
- FileUtils.mkdir_p(output_dir_certs)
79
- dest_cert_path = File.join(output_dir_certs, "#{matching_cert.id}.cer")
80
- dest_p12_path = File.join(output_dir_certs, "#{matching_cert.id}.p12")
115
+ # Make dir if doesn't exist
116
+ FileUtils.mkdir_p(output_dir_certs)
117
+ dest_cert_path = File.join(output_dir_certs, "#{matching_cert.id}.cer")
118
+ dest_p12_path = File.join(output_dir_certs, "#{matching_cert.id}.p12")
119
+ end
81
120
 
82
121
  files_to_commit = [dest_cert_path, dest_p12_path]
83
122
 
@@ -108,5 +147,11 @@ module Match
108
147
  UI.user_error!("#{file_description} does not exist at path: #{file_path}") unless !file_path.nil? || optional
109
148
  file_path
110
149
  end
150
+
151
+ def api_token(params)
152
+ @api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key]
153
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path]
154
+ return @api_token
155
+ end
111
156
  end
112
157
  end
@@ -42,9 +42,14 @@ module Match
42
42
  # while on Git we recommend using the git branch instead. As there is
43
43
  # no concept of branches in Google Cloud Storage (omg thanks), we use
44
44
  # the team id properly
45
- spaceship = SpaceshipEnsure.new(params[:username], params[:team_id], params[:team_name])
45
+ spaceship = SpaceshipEnsure.new(params[:username], params[:team_id], params[:team_name], api_token(params))
46
46
  team_id = spaceship.team_id
47
- UI.message("Detected team ID '#{team_id}' to use for Google Cloud Storage...")
47
+
48
+ if team_id.to_s.empty?
49
+ UI.user_error!("The `team_id` option is required. fastlane cannot automatically determine portal team id via the App Store Connect API (yet)")
50
+ else
51
+ UI.message("Detected team ID '#{team_id}' to use for Google Cloud Storage...")
52
+ end
48
53
 
49
54
  files_to_commit = []
50
55
  Dir.chdir(git_storage.working_directory) do
@@ -85,6 +90,12 @@ module Match
85
90
  UI.input("Please make sure to read the above and confirm with enter")
86
91
  end
87
92
 
93
+ def api_token(params)
94
+ @api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key]
95
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path]
96
+ return @api_token
97
+ end
98
+
88
99
  def ensure_parameters_are_valid(params)
89
100
  if params[:readonly]
90
101
  UI.user_error!("`fastlane match migrate` doesn't work in `readonly` mode")
@@ -44,7 +44,7 @@ module Match
44
44
  s3_access_key: params[:s3_access_key].to_s,
45
45
  s3_secret_access_key: params[:s3_secret_access_key].to_s,
46
46
  s3_bucket: params[:s3_bucket].to_s,
47
- team_id: params[:team_id] || Spaceship.client.team_id
47
+ team_id: params[:team_id] || Spaceship::ConnectAPI.client.portal_team_id
48
48
  })
49
49
  self.storage.download
50
50
 
@@ -97,10 +97,14 @@ module Match
97
97
  end
98
98
 
99
99
  def spaceship_login
100
- Spaceship.login(params[:username])
101
- Spaceship.select_team(team_id: params[:team_id], team_name: params[:team_name])
100
+ if api_token
101
+ UI.message("Creating authorization token for App Store Connect API")
102
+ Spaceship::ConnectAPI.token = api_token
103
+ else
104
+ Spaceship::ConnectAPI.login(params[:username], use_portal: true, use_tunes: false, portal_team_id: params[:team_id], team_name: params[:team_name])
105
+ end
102
106
 
103
- if Spaceship.client.in_house? && (type == "distribution" || type == "enterprise")
107
+ if Spaceship::ConnectAPI.client.in_house? && (type == "distribution" || type == "enterprise")
104
108
  UI.error("---")
105
109
  UI.error("⚠️ Warning: This seems to be an Enterprise account!")
106
110
  UI.error("By nuking your account's distribution, all your apps deployed via ad-hoc will stop working!") if type == "distribution"
@@ -111,6 +115,12 @@ module Match
111
115
  end
112
116
  end
113
117
 
118
+ def api_token
119
+ @api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key]
120
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path]
121
+ return @api_token
122
+ end
123
+
114
124
  # Collect all the certs/profiles
115
125
  def prepare_list
116
126
  UI.message("Fetching certificates and profiles...")
@@ -125,8 +135,10 @@ module Match
125
135
  # Get all iOS and macOS profile
126
136
  self.profiles = []
127
137
  prov_types.each do |prov_type|
128
- self.profiles += profile_type(prov_type).all(mac: false)
129
- self.profiles += profile_type(prov_type).all(mac: true)
138
+ types = profile_types(prov_type)
139
+ # Filtering on 'profileType' seems to be undocumented as of 2020-07-30
140
+ # but works on both web session and official API
141
+ self.profiles += Spaceship::ConnectAPI::Profile.all(filter: { profileType: types.join(",") })
130
142
  end
131
143
 
132
144
  # Gets the main and additional cert types
@@ -138,7 +150,7 @@ module Match
138
150
  self.certs = []
139
151
  self.certs += cert_types.map do |ct|
140
152
  certificate_type(ct).flat_map do |cert|
141
- cert.all(mac: false) + cert.all(mac: true)
153
+ Spaceship::ConnectAPI::Certificate.all(filter: { certificateType: cert })
142
154
  end
143
155
  end.flatten
144
156
 
@@ -165,7 +177,7 @@ module Match
165
177
  puts("")
166
178
  if self.certs.count > 0
167
179
  rows = self.certs.collect do |cert|
168
- cert_expiration = cert.expires.nil? ? "Unknown" : cert.expires.strftime("%Y-%m-%d")
180
+ cert_expiration = cert.expiration_date.nil? ? "Unknown" : Time.parse(cert.expiration_date).strftime("%Y-%m-%d")
169
181
  [cert.name, cert.id, cert.class.to_s.split("::").last, cert_expiration]
170
182
  end
171
183
  puts(Terminal::Table.new({
@@ -178,11 +190,11 @@ module Match
178
190
 
179
191
  if self.profiles.count > 0
180
192
  rows = self.profiles.collect do |p|
181
- status = p.status == 'Active' ? p.status.green : p.status.red
193
+ status = p.valid? ? p.profile_state.green : p.profile_state.red
182
194
 
183
195
  # Expires is sometimes nil
184
- expires = p.expires ? p.expires.strftime("%Y-%m-%d") : nil
185
- [p.name, p.id, status, p.type, expires]
196
+ expires = p.expiration_date ? Time.parse(p.expiration_date).strftime("%Y-%m-%d") : nil
197
+ [p.name, p.id, status, p.profile_type, expires]
186
198
  end
187
199
  puts(Terminal::Table.new({
188
200
  title: "Provisioning Profiles that are going to be revoked".green,
@@ -227,7 +239,7 @@ module Match
227
239
  self.certs.each do |cert|
228
240
  UI.message("Revoking certificate '#{cert.name}' (#{cert.id})...")
229
241
  begin
230
- cert.revoke!
242
+ cert.delete!
231
243
  rescue => ex
232
244
  UI.message(ex.to_s)
233
245
  end
@@ -274,31 +286,62 @@ module Match
274
286
  def certificate_type(type)
275
287
  case type.to_sym
276
288
  when :mac_installer_distribution
277
- return [Spaceship.certificate.mac_installer_distribution]
289
+ return [
290
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_INSTALLER_DISTRIBUTION
291
+ ]
278
292
  when :distribution
279
- return [Spaceship.certificate.production, Spaceship.certificate.apple_distribution]
293
+ return [
294
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DISTRIBUTION,
295
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION,
296
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION
297
+ ]
280
298
  when :development
281
- return [Spaceship.certificate.development, Spaceship.certificate.apple_development]
299
+ return [
300
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DEVELOPMENT,
301
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DEVELOPMENT,
302
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT
303
+ ]
282
304
  when :enterprise
283
- return [Spaceship.certificate.in_house]
305
+ return [
306
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
307
+ ]
284
308
  else
285
309
  raise "Unknown type '#{type}'"
286
310
  end
287
311
  end
288
312
 
289
313
  # The kind of provisioning profile we're interested in
290
- def profile_type(prov_type)
314
+ def profile_types(prov_type)
291
315
  case prov_type.to_sym
292
316
  when :appstore
293
- return Spaceship.provisioning_profile.app_store
317
+ return [
318
+ Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_STORE,
319
+ Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE,
320
+ Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_STORE,
321
+ Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE
322
+ ]
294
323
  when :development
295
- return Spaceship.provisioning_profile.development
324
+ return [
325
+ Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT,
326
+ Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT,
327
+ Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT,
328
+ Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT
329
+ ]
296
330
  when :enterprise
297
- return Spaceship.provisioning_profile.in_house
331
+ return [
332
+ Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE,
333
+ Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE
334
+ ]
298
335
  when :adhoc
299
- return Spaceship.provisioning_profile.ad_hoc
336
+ return [
337
+ Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC,
338
+ Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC
339
+ ]
300
340
  when :developer_id
301
- return Spaceship.provisioning_profile.direct
341
+ return [
342
+ Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT,
343
+ Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT
344
+ ]
302
345
  else
303
346
  raise "Unknown provisioning type '#{prov_type}'"
304
347
  end
@@ -62,20 +62,39 @@ module Match
62
62
  type: Boolean,
63
63
  default_value: false),
64
64
 
65
- # app
66
65
  FastlaneCore::ConfigItem.new(key: :app_identifier,
67
66
  short_option: "-a",
68
67
  env_name: "MATCH_APP_IDENTIFIER",
69
- description: "The bundle identifier(s) of your app (comma-separated)",
68
+ description: "The bundle identifier(s) of your app (comma-separated string or array of strings)",
70
69
  type: Array, # we actually allow String and Array here
71
70
  skip_type_validation: true,
72
71
  code_gen_sensitive: true,
73
72
  default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
74
73
  default_value_dynamic: true),
74
+
75
+ # App Store Connect API
76
+ FastlaneCore::ConfigItem.new(key: :api_key_path,
77
+ env_name: "SIGH_API_KEY_PATH",
78
+ description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
79
+ optional: true,
80
+ conflicting_options: [:api_key],
81
+ verify_block: proc do |value|
82
+ UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
83
+ end),
84
+ FastlaneCore::ConfigItem.new(key: :api_key,
85
+ env_name: "SIGH_API_KEY",
86
+ description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option)",
87
+ type: Hash,
88
+ optional: true,
89
+ sensitive: true,
90
+ conflicting_options: [:api_key_path]),
91
+
92
+ # Apple ID
75
93
  FastlaneCore::ConfigItem.new(key: :username,
76
94
  short_option: "-u",
77
95
  env_name: "MATCH_USERNAME",
78
96
  description: "Your Apple ID Username",
97
+ optional: true,
79
98
  default_value: user,
80
99
  default_value_dynamic: true),
81
100
  FastlaneCore::ConfigItem.new(key: :team_id,
@@ -264,10 +283,22 @@ module Match
264
283
  optional: true,
265
284
  type: Boolean,
266
285
  default_value: false),
286
+ FastlaneCore::ConfigItem.new(key: :skip_certificate_matching,
287
+ env_name: "MATCH_SKIP_CERTIFICATE_MATCHING",
288
+ description: "Set to true if there is no access to Apple developer portal but there are certificates, keys and profiles provided. Only works with match import action",
289
+ optional: true,
290
+ type: Boolean,
291
+ default_value: false),
267
292
  FastlaneCore::ConfigItem.new(key: :output_path,
268
293
  env_name: "MATCH_OUTPUT_PATH",
269
294
  description: "Path in which to export certificates, key and profile",
270
295
  optional: true),
296
+ FastlaneCore::ConfigItem.new(key: :skip_set_partition_list,
297
+ short_option: "-P",
298
+ env_name: "MATCH_SKIP_SET_PARTITION_LIST",
299
+ description: "Skips setting the partition list (which can sometimes take a long time). Setting the partition list is usually needed to prevent Xcode from prompting to allow a cert to be used for signing",
300
+ type: Boolean,
301
+ default_value: false),
271
302
 
272
303
  # other
273
304
  FastlaneCore::ConfigItem.new(key: :verbose,
@@ -55,7 +55,9 @@ module Match
55
55
  readonly: params[:readonly],
56
56
  username: params[:readonly] ? nil : params[:username], # only pass username if not readonly
57
57
  team_id: params[:team_id],
58
- team_name: params[:team_name]
58
+ team_name: params[:team_name],
59
+ api_key_path: params[:api_key_path],
60
+ api_key: params[:api_key]
59
61
  })
60
62
  storage.download
61
63
 
@@ -67,7 +69,7 @@ module Match
67
69
  encryption.decrypt_files if encryption
68
70
 
69
71
  unless params[:readonly]
70
- self.spaceship = SpaceshipEnsure.new(params[:username], params[:team_id], params[:team_name])
72
+ self.spaceship = SpaceshipEnsure.new(params[:username], params[:team_id], params[:team_name], api_token(params))
71
73
  if params[:type] == "enterprise" && !Spaceship.client.in_house?
72
74
  UI.user_error!("You defined the profile type 'enterprise', but your Apple account doesn't support In-House profiles")
73
75
  end
@@ -100,7 +102,7 @@ module Match
100
102
  end
101
103
 
102
104
  cert_ids << cert_id
103
- spaceship.certificates_exists(username: params[:username], certificate_ids: cert_ids, platform: params[:platform]) if spaceship
105
+ spaceship.certificates_exists(username: params[:username], certificate_ids: cert_ids) if spaceship
104
106
 
105
107
  # Provisioning Profiles
106
108
  unless params[:skip_provisioning_profiles]
@@ -136,6 +138,12 @@ module Match
136
138
  end
137
139
  # rubocop:enable Metrics/PerceivedComplexity
138
140
 
141
+ def api_token(params)
142
+ @api_token ||= Spaceship::ConnectAPI::Token.create(params[:api_key]) if params[:api_key]
143
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(params[:api_key_path]) if params[:api_key_path]
144
+ return @api_token
145
+ end
146
+
139
147
  # Used when creating a new certificate or profile
140
148
  def prefixed_working_directory
141
149
  return self.storage.prefixed_working_directory
@@ -316,23 +324,43 @@ module Match
316
324
 
317
325
  parsed = FastlaneCore::ProvisioningProfile.parse(profile, keychain_path)
318
326
  uuid = parsed["UUID"]
319
- portal_profile = Spaceship.provisioning_profile.all.detect { |i| i.uuid == uuid }
327
+
328
+ all_profiles = Spaceship::ConnectAPI::Profile.all(includes: "devices")
329
+ portal_profile = all_profiles.detect { |i| i.uuid == uuid }
320
330
 
321
331
  if portal_profile
322
- profile_device_count = portal_profile.devices.count
332
+ profile_device_count = portal_profile.fetch_all_devices.count
323
333
 
324
- portal_device_count =
334
+ device_classes =
325
335
  case platform
326
336
  when :ios
327
- Spaceship.device.all_ios_profile_devices.count
337
+ [
338
+ Spaceship::ConnectAPI::Device::DeviceClass::IPAD,
339
+ Spaceship::ConnectAPI::Device::DeviceClass::IPHONE,
340
+ Spaceship::ConnectAPI::Device::DeviceClass::IPOD,
341
+ Spaceship::ConnectAPI::Device::DeviceClass::APPLE_WATCH
342
+ ]
328
343
  when :tvos
329
- Spaceship.device.all_apple_tvs.count
344
+ [
345
+ Spaceship::ConnectAPI::Device::DeviceClass::APPLE_TV
346
+ ]
330
347
  when :mac, :catalyst
331
- Spaceship.device.all_macs.count
348
+ [
349
+ Spaceship::ConnectAPI::Device::DeviceClass::MAC
350
+ ]
332
351
  else
333
- Spaceship.device.all.count
352
+ []
334
353
  end
335
354
 
355
+ devices = Spaceship::ConnectAPI::Device.all
356
+ unless device_classes.empty?
357
+ devices = devices.select do |device|
358
+ device_classes.include?(device.device_class)
359
+ end
360
+ end
361
+
362
+ portal_device_count = devices.size
363
+
336
364
  return portal_device_count != profile_device_count
337
365
  end
338
366
  return false