fastlane 2.161.0 → 2.162.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +76 -76
  3. data/cert/lib/cert/options.rb +28 -1
  4. data/cert/lib/cert/runner.rb +50 -33
  5. data/deliver/lib/deliver/app_screenshot_iterator.rb +4 -4
  6. data/deliver/lib/deliver/options.rb +2 -2
  7. data/deliver/lib/deliver/upload_metadata.rb +1 -0
  8. data/deliver/lib/deliver/upload_screenshots.rb +25 -8
  9. data/fastlane/lib/fastlane/version.rb +1 -1
  10. data/fastlane/swift/Deliverfile.swift +1 -1
  11. data/fastlane/swift/DeliverfileProtocol.swift +1 -1
  12. data/fastlane/swift/Fastlane.swift +51 -3
  13. data/fastlane/swift/Gymfile.swift +1 -1
  14. data/fastlane/swift/GymfileProtocol.swift +1 -1
  15. data/fastlane/swift/Matchfile.swift +1 -1
  16. data/fastlane/swift/MatchfileProtocol.swift +15 -3
  17. data/fastlane/swift/Precheckfile.swift +1 -1
  18. data/fastlane/swift/PrecheckfileProtocol.swift +1 -1
  19. data/fastlane/swift/Scanfile.swift +1 -1
  20. data/fastlane/swift/ScanfileProtocol.swift +1 -1
  21. data/fastlane/swift/Screengrabfile.swift +1 -1
  22. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  23. data/fastlane/swift/Snapshotfile.swift +1 -1
  24. data/fastlane/swift/SnapshotfileProtocol.swift +1 -1
  25. data/fastlane_core/lib/fastlane_core/analytics/analytics_session.rb +6 -7
  26. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +2 -2
  27. data/match/lib/match/generator.rb +6 -1
  28. data/match/lib/match/importer.rb +39 -6
  29. data/match/lib/match/migrate.rb +13 -2
  30. data/match/lib/match/nuke.rb +65 -22
  31. data/match/lib/match/options.rb +26 -1
  32. data/match/lib/match/runner.rb +38 -10
  33. data/match/lib/match/spaceship_ensure.rb +27 -21
  34. data/match/lib/match/storage/google_cloud_storage.rb +20 -3
  35. data/match/lib/match/storage/s3_storage.rb +19 -3
  36. data/sigh/lib/sigh/options.rb +21 -0
  37. data/sigh/lib/sigh/runner.rb +80 -38
  38. data/spaceship/lib/spaceship/client.rb +2 -1
  39. data/spaceship/lib/spaceship/connect_api.rb +1 -0
  40. data/spaceship/lib/spaceship/connect_api/api_client.rb +3 -3
  41. data/spaceship/lib/spaceship/connect_api/client.rb +13 -3
  42. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +3 -1
  43. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +2 -1
  44. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +42 -0
  45. data/spaceship/lib/spaceship/connect_api/models/profile.rb +7 -1
  46. data/spaceship/lib/spaceship/connect_api/models/user_invitation.rb +59 -0
  47. data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +28 -2
  48. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +13 -0
  49. data/spaceship/lib/spaceship/connect_api/users/users.rb +40 -0
  50. metadata +19 -18
@@ -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
@@ -4,28 +4,38 @@ require_relative 'module'
4
4
  module Match
5
5
  # Ensures the certificate and profiles are also available on App Store Connect
6
6
  class SpaceshipEnsure
7
- def initialize(user, team_id, team_name)
8
- # We'll try to manually fetch the password
9
- # to tell the user that a password is optional
10
- require 'credentials_manager/account_manager'
7
+ attr_accessor :team_id
11
8
 
12
- keychain_entry = CredentialsManager::AccountManager.new(user: user)
9
+ def initialize(user, team_id, team_name, api_token)
10
+ UI.message("Verifying that the certificate and profile are still valid on the Dev Portal...")
13
11
 
14
- if keychain_entry.password(ask_if_missing: false).to_s.length == 0
15
- UI.important("You can also run `fastlane match` in readonly mode to not require any access to the")
16
- UI.important("Developer Portal. This way you only share the keys and credentials")
17
- UI.command("fastlane match --readonly")
18
- UI.important("More information https://docs.fastlane.tools/actions/match/#access-control")
19
- end
12
+ if api_token
13
+ UI.message("Creating authorization token for App Store Connect API")
14
+ Spaceship::ConnectAPI.token = api_token
15
+ self.team_id = team_id
16
+ else
17
+ # We'll try to manually fetch the password
18
+ # to tell the user that a password is optional
19
+ require 'credentials_manager/account_manager'
20
20
 
21
- # Prompts select team if multiple teams and none specified
22
- UI.message("Verifying that the certificate and profile are still valid on the Dev Portal...")
23
- Spaceship::ConnectAPI.login(user, use_portal: true, use_tunes: false, portal_team_id: team_id, team_name: team_name)
21
+ keychain_entry = CredentialsManager::AccountManager.new(user: user)
22
+
23
+ if keychain_entry.password(ask_if_missing: false).to_s.length == 0
24
+ UI.important("You can also run `fastlane match` in readonly mode to not require any access to the")
25
+ UI.important("Developer Portal. This way you only share the keys and credentials")
26
+ UI.command("fastlane match --readonly")
27
+ UI.important("More information https://docs.fastlane.tools/actions/match/#access-control")
28
+ end
29
+
30
+ # Prompts select team if multiple teams and none specified
31
+ Spaceship::ConnectAPI.login(user, use_portal: true, use_tunes: false, portal_team_id: team_id, team_name: team_name)
32
+ self.team_id = Spaceship::ConnectAPI.client.portal_team_id
33
+ end
24
34
  end
25
35
 
26
36
  # The team ID of the currently logged in team
27
37
  def team_id
28
- return Spaceship::ConnectAPI.client.portal_team_id
38
+ return @team_id
29
39
  end
30
40
 
31
41
  def bundle_identifier_exists(username: nil, app_identifier: nil, platform: nil)
@@ -45,12 +55,8 @@ module Match
45
55
  UI.user_error!("Couldn't find bundle identifier '#{app_identifier}' for the user '#{username}'")
46
56
  end
47
57
 
48
- def certificates_exists(username: nil, certificate_ids: [], platform: nil)
49
- if platform == :catalyst.to_s
50
- platform = :macos.to_s
51
- end
52
-
53
- Spaceship.certificate.all(mac: platform == "macos").each do |cert|
58
+ def certificates_exists(username: nil, certificate_ids: [])
59
+ Spaceship::ConnectAPI::Certificate.all.each do |cert|
54
60
  certificate_ids.delete(cert.id)
55
61
  end
56
62
  return if certificate_ids.empty?
@@ -23,6 +23,8 @@ module Match
23
23
  attr_reader :username
24
24
  attr_reader :team_id
25
25
  attr_reader :team_name
26
+ attr_reader :api_key_path
27
+ attr_reader :api_key
26
28
 
27
29
  # Managed values
28
30
  attr_accessor :gc_storage
@@ -44,7 +46,9 @@ module Match
44
46
  readonly: params[:readonly],
45
47
  username: params[:username],
46
48
  team_id: params[:team_id],
47
- team_name: params[:team_name]
49
+ team_name: params[:team_name],
50
+ api_key_path: params[:api_key_path],
51
+ api_key: params[:api_key]
48
52
  )
49
53
  end
50
54
 
@@ -56,7 +60,9 @@ module Match
56
60
  readonly: nil,
57
61
  username: nil,
58
62
  team_id: nil,
59
- team_name: nil)
63
+ team_name: nil,
64
+ api_key_path: nil,
65
+ api_key: nil)
60
66
  @type = type if type
61
67
  @platform = platform if platform
62
68
  @google_cloud_project_id = google_cloud_project_id if google_cloud_project_id
@@ -67,6 +73,9 @@ module Match
67
73
  @team_id = team_id
68
74
  @team_name = team_name
69
75
 
76
+ @api_key_path = api_key_path
77
+ @api_key = api_key
78
+
70
79
  @google_cloud_keys_file = ensure_keys_file_exists(google_cloud_keys_file, google_cloud_project_id)
71
80
 
72
81
  if self.google_cloud_keys_file.to_s.length > 0
@@ -106,11 +115,19 @@ module Match
106
115
  # see `prefixed_working_directory` comments for more details
107
116
  return self.team_id
108
117
  else
109
- spaceship = SpaceshipEnsure.new(self.username, self.team_id, self.team_name)
118
+ UI.user_error!("The `team_id` option is required. fastlane cannot automatically determine portal team id via the App Store Connect API (yet)") if self.team_id.to_s.empty?
119
+
120
+ spaceship = SpaceshipEnsure.new(self.username, self.team_id, self.team_name, self.api_token)
110
121
  return spaceship.team_id
111
122
  end
112
123
  end
113
124
 
125
+ def api_token
126
+ api_token ||= Spaceship::ConnectAPI::Token.create(self.api_key) if self.api_key
127
+ api_token ||= Spaceship::ConnectAPI::Token.from_json_file(self.api_key_path) if self.api_key_path
128
+ return api_token
129
+ end
130
+
114
131
  def prefixed_working_directory
115
132
  # We fall back to "*", which means certificates and profiles
116
133
  # from all teams that use this bucket would be installed. This is not ideal, but
@@ -19,6 +19,8 @@ module Match
19
19
  attr_reader :username
20
20
  attr_reader :team_id
21
21
  attr_reader :team_name
22
+ attr_reader :api_key_path
23
+ attr_reader :api_key
22
24
 
23
25
  def self.configure(params)
24
26
  s3_region = params[:s3_region]
@@ -43,7 +45,9 @@ module Match
43
45
  readonly: params[:readonly],
44
46
  username: params[:username],
45
47
  team_id: params[:team_id],
46
- team_name: params[:team_name]
48
+ team_name: params[:team_name],
49
+ api_key_path: params[:api_key_path],
50
+ api_key: params[:api_key]
47
51
  )
48
52
  end
49
53
 
@@ -55,7 +59,9 @@ module Match
55
59
  readonly: nil,
56
60
  username: nil,
57
61
  team_id: nil,
58
- team_name: nil)
62
+ team_name: nil,
63
+ api_key_path: nil,
64
+ api_key: nil)
59
65
  @s3_bucket = s3_bucket
60
66
  @s3_region = s3_region
61
67
  @s3_client = Fastlane::Helper::S3ClientHelper.new(access_key: s3_access_key, secret_access_key: s3_secret_access_key, region: s3_region)
@@ -64,6 +70,8 @@ module Match
64
70
  @username = username
65
71
  @team_id = team_id
66
72
  @team_name = team_name
73
+ @api_key_path = api_key_path
74
+ @api_key = api_key
67
75
  end
68
76
 
69
77
  # To make debugging easier, we have a custom exception here
@@ -180,10 +188,18 @@ module Match
180
188
  # see `prefixed_working_directory` comments for more details
181
189
  return self.team_id
182
190
  else
183
- spaceship = SpaceshipEnsure.new(self.username, self.team_id, self.team_name)
191
+ UI.user_error!("The `team_id` option is required. fastlane cannot automatically determine portal team id via the App Store Connect API (yet)") if self.team_id.to_s.empty?
192
+
193
+ spaceship = SpaceshipEnsure.new(self.username, self.team_id, self.team_name, api_token)
184
194
  return spaceship.team_id
185
195
  end
186
196
  end
197
+
198
+ def api_token
199
+ api_token ||= Spaceship::ConnectAPI::Token.create(self.api_key) if self.api_key
200
+ api_token ||= Spaceship::ConnectAPI::Token.from_json_file(self.api_key_path) if self.api_key_path
201
+ return api_token
202
+ end
187
203
  end
188
204
  end
189
205
  end
@@ -54,6 +54,25 @@ module Sigh
54
54
  code_gen_sensitive: true,
55
55
  default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
56
56
  default_value_dynamic: true),
57
+
58
+ # App Store Connect API
59
+ FastlaneCore::ConfigItem.new(key: :api_key_path,
60
+ env_name: "SIGH_API_KEY_PATH",
61
+ 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)",
62
+ optional: true,
63
+ conflicting_options: [:api_key],
64
+ verify_block: proc do |value|
65
+ UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
66
+ end),
67
+ FastlaneCore::ConfigItem.new(key: :api_key,
68
+ env_name: "SIGH_API_KEY",
69
+ 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)",
70
+ type: Hash,
71
+ optional: true,
72
+ sensitive: true,
73
+ conflicting_options: [:api_key_path]),
74
+
75
+ # Apple ID
57
76
  FastlaneCore::ConfigItem.new(key: :username,
58
77
  short_option: "-u",
59
78
  env_name: "SIGH_USERNAME",
@@ -82,6 +101,8 @@ module Sigh
82
101
  verify_block: proc do |value|
83
102
  ENV["FASTLANE_TEAM_NAME"] = value.to_s
84
103
  end),
104
+
105
+ # Other options
85
106
  FastlaneCore::ConfigItem.new(key: :provisioning_name,
86
107
  short_option: "-n",
87
108
  env_name: "SIGH_PROVISIONING_PROFILE_NAME",
@@ -17,11 +17,16 @@ module Sigh
17
17
  hide_keys: [:output_path],
18
18
  title: "Summary for sigh #{Fastlane::VERSION}")
19
19
 
20
- # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
21
- # Prompts select team if multiple teams and none specified
22
- UI.message("Starting login with user '#{Sigh.config[:username]}'")
23
- Spaceship::ConnectAPI.login(Sigh.config[:username], nil, use_portal: true, use_tunes: false)
24
- UI.message("Successfully logged in")
20
+ if api_token
21
+ UI.message("Creating authorization token for App Store Connect API")
22
+ Spaceship::ConnectAPI.token = api_token
23
+ else
24
+ # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
25
+ # Prompts select team if multiple teams and none specified
26
+ UI.message("Starting login with user '#{Sigh.config[:username]}'")
27
+ Spaceship::ConnectAPI.login(Sigh.config[:username], nil, use_portal: true, use_tunes: false)
28
+ UI.message("Successfully logged in")
29
+ end
25
30
 
26
31
  profiles = [] if Sigh.config[:skip_fetch_profiles]
27
32
  profiles ||= fetch_profiles # download the profile if it's there
@@ -54,6 +59,12 @@ module Sigh
54
59
  return download_profile(profile)
55
60
  end
56
61
 
62
+ def api_token
63
+ @api_token ||= Spaceship::ConnectAPI::Token.create(Sigh.config[:api_key]) if Sigh.config[:api_key]
64
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Sigh.config[:api_key_path]) if Sigh.config[:api_key_path]
65
+ return @api_token
66
+ end
67
+
57
68
  # The kind of provisioning profile we're interested in
58
69
  def profile_type
59
70
  return @profile_type if @profile_type
@@ -190,65 +201,95 @@ module Sigh
190
201
  profiles
191
202
  end
192
203
 
204
+ def fetch_certificates(certificate_types)
205
+ filter = {
206
+ certificateType: certificate_types.join(',')
207
+ }
208
+ return Spaceship::ConnectAPI::Certificate.all(filter: filter)
209
+ end
210
+
193
211
  def certificates_for_profile_and_platform
212
+ types = []
213
+
194
214
  case Sigh.config[:platform].to_s
195
215
  when 'ios', 'tvos'
196
216
  if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_DEVELOPMENT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_DEVELOPMENT
197
- certificates = Spaceship.certificate.development.all +
198
- Spaceship.certificate.apple_development.all
217
+ types = [
218
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT,
219
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DEVELOPMENT
220
+ ]
199
221
  elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_INHOUSE || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_INHOUSE
200
222
  # Enterprise accounts don't have access to Apple Distribution certificates
201
- certificates = Spaceship.certificate.in_house.all
223
+ types = [
224
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
225
+ ]
202
226
  # handles case where the desired certificate type is adhoc but the account is an enterprise account
203
227
  # the apple dev portal api has a weird quirk in it where if you query for distribution certificates
204
228
  # for enterprise accounts, you get nothing back even if they exist.
205
- elsif (profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC) && Spaceship.client && Spaceship.client.in_house?
229
+ elsif (profile_type == Spaceship::ConnectAPI::Profile::ProfileType::IOS_APP_ADHOC || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::TVOS_APP_ADHOC) && Spaceship::ConnectAPI.client && Spaceship::ConnectAPI.client.in_house?
206
230
  # Enterprise accounts don't have access to Apple Distribution certificates
207
- certificates = Spaceship.certificate.in_house.all
231
+ types = [
232
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
233
+ ]
208
234
  else
209
- # Ad hoc or App Store
210
- certificates = Spaceship.certificate.production.all +
211
- Spaceship.certificate.apple_distribution.all
235
+ types = [
236
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION,
237
+ Spaceship::ConnectAPI::Certificate::CertificateType::IOS_DISTRIBUTION
238
+ ]
212
239
  end
213
240
 
214
241
  when 'macos', 'catalyst'
215
242
  if profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DEVELOPMENT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DEVELOPMENT
216
- certificates = Spaceship.certificate.mac_development.all +
217
- Spaceship.certificate.apple_development.all
243
+ types = [
244
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPMENT,
245
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DEVELOPMENT
246
+ ]
218
247
  elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_STORE || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_STORE
219
- certificates = Spaceship.certificate.mac_app_distribution.all +
220
- Spaceship.certificate.apple_distribution.all
248
+ types = [
249
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION,
250
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DISTRIBUTION
251
+ ]
221
252
  elsif profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_APP_DIRECT || profile_type == Spaceship::ConnectAPI::Profile::ProfileType::MAC_CATALYST_APP_DIRECT
222
- certificates = Spaceship.certificate.developer_id_application.all
253
+ types = [
254
+ Spaceship::ConnectAPI::Certificate::CertificateType::DEVELOPER_ID_APPLICATION
255
+ ]
223
256
  else
224
- certificates = Spaceship.certificate.mac_app_distribution.all +
225
- Spaceship.certificate.apple_distribution.all
257
+ types = [
258
+ Spaceship::ConnectAPI::Certificate::CertificateType::DISTRIBUTION,
259
+ Spaceship::ConnectAPI::Certificate::CertificateType::MAC_APP_DISTRIBUTION
260
+ ]
226
261
  end
227
262
  end
228
263
 
229
- certificates
264
+ fetch_certificates(types)
230
265
  end
231
266
 
232
267
  def devices_to_use
233
268
  # Only use devices if development or adhoc
234
269
  return [] if !Sigh.config[:development] && !Sigh.config[:adhoc]
235
270
 
236
- device_class = case Sigh.config[:platform].to_s
237
- when 'ios'
238
- [
239
- Spaceship::ConnectAPI::Device::DeviceClass::APPLE_WATCH,
240
- Spaceship::ConnectAPI::Device::DeviceClass::IPAD,
241
- Spaceship::ConnectAPI::Device::DeviceClass::IPHONE,
242
- Spaceship::ConnectAPI::Device::DeviceClass::IPOD
243
- ].join(",")
244
- when 'tvos'
245
- Spaceship::ConnectAPI::Device::DeviceClass::APPLE_TV
246
- when 'macos', 'catalyst'
247
- Spaceship::ConnectAPI::Device::DeviceClass::MAC
248
- end
249
-
250
- filter = { deviceClass: device_class }
251
- return Spaceship::ConnectAPI::Device.all(filter: filter)
271
+ device_classes = case Sigh.config[:platform].to_s
272
+ when 'ios'
273
+ [
274
+ Spaceship::ConnectAPI::Device::DeviceClass::APPLE_WATCH,
275
+ Spaceship::ConnectAPI::Device::DeviceClass::IPAD,
276
+ Spaceship::ConnectAPI::Device::DeviceClass::IPHONE,
277
+ Spaceship::ConnectAPI::Device::DeviceClass::IPOD
278
+ ]
279
+ when 'tvos'
280
+ [Spaceship::ConnectAPI::Device::DeviceClass::APPLE_TV]
281
+ when 'macos', 'catalyst'
282
+ [Spaceship::ConnectAPI::Device::DeviceClass::MAC]
283
+ end
284
+
285
+ if api_token
286
+ return Spaceship::ConnectAPI::Device.all.select do |device|
287
+ device_classes.include?(device.device_class)
288
+ end
289
+ else
290
+ filter = { deviceClass: device_classes.join(",") }
291
+ return Spaceship::ConnectAPI::Device.all(filter: filter)
292
+ end
252
293
  end
253
294
 
254
295
  # Certificate to use based on the current distribution mode
@@ -273,7 +314,8 @@ module Sigh
273
314
  unless Sigh.config[:skip_certificate_verification]
274
315
  certificates = certificates.find_all do |c|
275
316
  file = Tempfile.new('cert')
276
- file.write(c.download_raw)
317
+ raw_data = Base64.decode64(c.certificate_content)
318
+ file.write(raw_data)
277
319
  file.close
278
320
 
279
321
  FastlaneCore::CertChecker.installed?(file.path)