fastlane 2.157.4 → 2.162.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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +80 -80
  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 +17 -1
  7. data/deliver/lib/deliver/runner.rb +36 -7
  8. data/deliver/lib/deliver/upload_metadata.rb +37 -6
  9. data/deliver/lib/deliver/upload_price_tier.rb +7 -2
  10. data/deliver/lib/deliver/upload_screenshots.rb +25 -8
  11. data/{pilot/lib/pilot/.manager.rb.swp → fastlane/lib/fastlane/.erb_template_helper.rb.swp} +0 -0
  12. data/fastlane/lib/fastlane/actions/{.ensure_git_status_clean.rb.swp → .git_commit.rb.swp} +0 -0
  13. data/fastlane/lib/fastlane/actions/actions_helper.rb +20 -1
  14. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +6 -1
  15. data/fastlane/lib/fastlane/actions/clean_build_artifacts.rb +1 -0
  16. data/fastlane/lib/fastlane/actions/docs/capture_android_screenshots.md +2 -2
  17. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +1 -1
  18. data/fastlane/lib/fastlane/actions/docs/create_app_online.md +1 -1
  19. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +3 -2
  20. data/fastlane/lib/fastlane/actions/docs/run_tests.md +2 -2
  21. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +3 -3
  22. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +2 -2
  23. data/fastlane/lib/fastlane/actions/docs/upload_to_testflight.md +2 -2
  24. data/fastlane/lib/fastlane/actions/download_dsyms.rb +32 -7
  25. data/fastlane/lib/fastlane/actions/ensure_git_status_clean.rb +13 -2
  26. data/fastlane/lib/fastlane/helper/git_helper.rb +2 -0
  27. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +6 -4
  28. data/fastlane/lib/fastlane/swift_fastlane_function.rb +1 -1
  29. data/fastlane/lib/fastlane/version.rb +1 -1
  30. data/fastlane/swift/Actions.swift +2 -1
  31. data/fastlane/swift/Appfile.swift +2 -4
  32. data/fastlane/swift/ArgumentProcessor.swift +2 -6
  33. data/fastlane/swift/ControlCommand.swift +2 -5
  34. data/fastlane/swift/Deliverfile.swift +5 -2
  35. data/fastlane/swift/DeliverfileProtocol.swift +15 -4
  36. data/fastlane/swift/Fastfile.swift +5 -1
  37. data/fastlane/swift/Fastlane.swift +2333 -2240
  38. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.pbxproj +5 -5
  39. data/fastlane/swift/Gymfile.swift +5 -2
  40. data/fastlane/swift/GymfileProtocol.swift +6 -3
  41. data/fastlane/swift/LaneFileProtocol.swift +42 -29
  42. data/fastlane/swift/MainProcess.swift +77 -0
  43. data/fastlane/swift/Matchfile.swift +5 -2
  44. data/fastlane/swift/MatchfileProtocol.swift +21 -6
  45. data/fastlane/swift/Plugins.swift +2 -1
  46. data/fastlane/swift/Precheckfile.swift +5 -2
  47. data/fastlane/swift/PrecheckfileProtocol.swift +18 -3
  48. data/fastlane/swift/RubyCommand.swift +2 -6
  49. data/fastlane/swift/RubyCommandable.swift +2 -6
  50. data/fastlane/swift/Runner.swift +5 -9
  51. data/fastlane/swift/RunnerArgument.swift +2 -6
  52. data/fastlane/swift/Scanfile.swift +5 -2
  53. data/fastlane/swift/ScanfileProtocol.swift +6 -3
  54. data/fastlane/swift/Screengrabfile.swift +5 -2
  55. data/fastlane/swift/ScreengrabfileProtocol.swift +6 -3
  56. data/fastlane/swift/Snapshotfile.swift +5 -2
  57. data/fastlane/swift/SnapshotfileProtocol.swift +6 -3
  58. data/fastlane/swift/SocketClient.swift +3 -7
  59. data/fastlane/swift/SocketClientDelegateProtocol.swift +2 -6
  60. data/fastlane/swift/SocketResponse.swift +2 -6
  61. data/fastlane/swift/formatting/Brewfile.lock.json +18 -10
  62. data/fastlane/swift/main.swift +4 -8
  63. data/fastlane/swift/upgrade_manifest.json +1 -1
  64. data/fastlane_core/lib/fastlane_core/analytics/analytics_session.rb +6 -7
  65. data/fastlane_core/lib/fastlane_core/keychain_importer.rb +2 -2
  66. data/frameit/lib/frameit/editor.rb +1 -0
  67. data/match/lib/match/generator.rb +6 -1
  68. data/match/lib/match/importer.rb +44 -8
  69. data/match/lib/match/migrate.rb +13 -2
  70. data/match/lib/match/nuke.rb +65 -22
  71. data/match/lib/match/options.rb +27 -2
  72. data/match/lib/match/runner.rb +38 -10
  73. data/match/lib/match/spaceship_ensure.rb +27 -21
  74. data/match/lib/match/storage/google_cloud_storage.rb +20 -3
  75. data/match/lib/match/storage/s3_storage.rb +19 -3
  76. data/pilot/lib/pilot/options.rb +2 -2
  77. data/precheck/lib/precheck/options.rb +25 -0
  78. data/precheck/lib/precheck/rule_processor.rb +94 -60
  79. data/precheck/lib/precheck/runner.rb +26 -5
  80. data/sigh/lib/sigh/options.rb +21 -0
  81. data/sigh/lib/sigh/runner.rb +80 -38
  82. data/snapshot/lib/assets/SnapshotHelper.swift +17 -2
  83. data/spaceship/README.md +1 -1
  84. data/spaceship/lib/spaceship/{connect_api/.DS_Store → .DS_Store} +0 -0
  85. data/spaceship/lib/spaceship/client.rb +2 -1
  86. data/spaceship/lib/spaceship/connect_api.rb +1 -0
  87. data/spaceship/lib/spaceship/connect_api/api_client.rb +3 -3
  88. data/spaceship/lib/spaceship/connect_api/client.rb +38 -15
  89. data/{fastlane/lib/fastlane/actions/.update_project_provisioning.rb.swp → spaceship/lib/spaceship/connect_api/models/.app_store_version_submission.rb.swp} +0 -0
  90. data/spaceship/lib/spaceship/connect_api/models/app.rb +17 -9
  91. data/spaceship/lib/spaceship/connect_api/models/app_info.rb +1 -0
  92. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +3 -1
  93. data/spaceship/lib/spaceship/connect_api/models/app_screenshot_set.rb +2 -2
  94. data/spaceship/lib/spaceship/connect_api/models/app_store_version.rb +3 -5
  95. data/spaceship/lib/spaceship/connect_api/models/app_store_version_localization.rb +3 -5
  96. data/spaceship/lib/spaceship/connect_api/models/app_store_version_phased_release.rb +21 -0
  97. data/spaceship/lib/spaceship/connect_api/models/beta_tester.rb +2 -1
  98. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +42 -0
  99. data/spaceship/lib/spaceship/connect_api/models/profile.rb +7 -1
  100. data/spaceship/lib/spaceship/connect_api/models/user_invitation.rb +59 -0
  101. data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +28 -2
  102. data/spaceship/lib/spaceship/connect_api/spaceship.rb +3 -2
  103. data/spaceship/lib/spaceship/connect_api/testflight/testflight.rb +13 -0
  104. data/spaceship/lib/spaceship/connect_api/tunes/tunes.rb +29 -9
  105. data/spaceship/lib/spaceship/connect_api/users/users.rb +40 -0
  106. data/spaceship/lib/spaceship/helper/net_http_generic_request.rb +11 -5
  107. metadata +24 -25
  108. data/fastlane/lib/fastlane/actions/.hockey.rb.swp +0 -0
  109. data/fastlane/lib/fastlane/actions/.slack.rb.swp +0 -0
  110. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
@@ -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
@@ -12,7 +12,7 @@ module Pilot
12
12
  [
13
13
  FastlaneCore::ConfigItem.new(key: :api_key_path,
14
14
  env_name: "PILOT_API_KEY_PATH",
15
- description: "Path to your App Store Connect API key JSON file",
15
+ 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)",
16
16
  optional: true,
17
17
  conflicting_options: [:username],
18
18
  verify_block: proc do |value|
@@ -20,7 +20,7 @@ module Pilot
20
20
  end),
21
21
  FastlaneCore::ConfigItem.new(key: :api_key,
22
22
  env_name: "PILOT_API_KEY",
23
- description: "Path to your App Store Connect API key JSON file",
23
+ 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)",
24
24
  type: Hash,
25
25
  optional: true,
26
26
  sensitive: true,
@@ -25,6 +25,22 @@ module Precheck
25
25
  user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
26
26
 
27
27
  [
28
+ FastlaneCore::ConfigItem.new(key: :api_key_path,
29
+ env_name: "PRECHECK_API_KEY_PATH",
30
+ 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)",
31
+ optional: true,
32
+ conflicting_options: [:username],
33
+ verify_block: proc do |value|
34
+ UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
35
+ end),
36
+ FastlaneCore::ConfigItem.new(key: :api_key,
37
+ env_name: "PRECHECK_API_KEY",
38
+ 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)",
39
+ type: Hash,
40
+ optional: true,
41
+ sensitive: true,
42
+ conflicting_options: [:api_key_path, :username]),
43
+
28
44
  FastlaneCore::ConfigItem.new(key: :app_identifier,
29
45
  short_option: "-a",
30
46
  env_name: "PRECHECK_APP_IDENTIFIER",
@@ -60,6 +76,15 @@ module Precheck
60
76
  verify_block: proc do |value|
61
77
  ENV["FASTLANE_ITC_TEAM_NAME"] = value.to_s
62
78
  end),
79
+ FastlaneCore::ConfigItem.new(key: :platform,
80
+ short_option: "-j",
81
+ env_name: "PRECHECK_PLATFORM",
82
+ description: "The platform to use (optional)",
83
+ optional: true,
84
+ default_value: "ios",
85
+ verify_block: proc do |value|
86
+ UI.user_error!("The platform can only be ios, appletvos, or osx") unless %('ios', 'appletvos', 'osx').include?(value)
87
+ end),
63
88
  FastlaneCore::ConfigItem.new(key: :default_rule_level,
64
89
  short_option: "-r",
65
90
  env_name: "PRECHECK_DEFAULT_RULE_LEVEL",
@@ -1,4 +1,5 @@
1
1
  require 'spaceship/tunes/language_item'
2
+ require 'spaceship/tunes/iap_list'
2
3
  require 'fastlane/markdown_table_formatter'
3
4
 
4
5
  require_relative 'module'
@@ -43,8 +44,8 @@ module Precheck
43
44
  class RuleProcessor
44
45
  def self.process_app_and_version(app: nil, app_version: nil, rules: nil)
45
46
  items_to_check = []
46
- items_to_check += generate_text_items_to_check(app: app, app_version: app_version)
47
- items_to_check += generate_url_items_to_check(app: app, app_version: app_version)
47
+ items_to_check += generate_app_items_to_check(app: app)
48
+ items_to_check += generate_version_items_to_check(app_version: app_version)
48
49
 
49
50
  return process_rules(items_to_check: items_to_check, rules: rules)
50
51
  end
@@ -125,66 +126,41 @@ module Precheck
125
126
  return rule_hash
126
127
  end
127
128
 
128
- def self.generate_url_items_to_check(app: nil, app_version: nil)
129
+ def self.generate_app_items_to_check(app: nil)
129
130
  items = []
130
- items += collect_urls_from_hash(hash: app_version.support_url,
131
- item_name: :support_url,
132
- friendly_name_postfix: "support URL")
133
- items += collect_urls_from_hash(hash: app_version.marketing_url,
134
- item_name: :marketing_url,
135
- friendly_name_postfix: "marketing URL",
136
- is_optional: true)
137
-
138
- items += collect_urls_from_hash(hash: app.details.privacy_url,
139
- item_name: :privacy_url,
140
- friendly_name_postfix: "privacy URL",
141
- is_optional: true)
142
- return items
143
- end
144
131
 
145
- def self.collect_urls_from_hash(hash: nil, item_name: nil, friendly_name_postfix: nil, is_optional: false)
146
- items = []
147
- hash.each do |key, value|
148
- items << URLItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{key})", is_optional)
132
+ # App info localizations
133
+ app_info = app.fetch_edit_app_info
134
+ app_info_localizations = app_info.get_app_info_localizations
135
+ app_info_localizations.each do |localization|
136
+ items << collect_text_items_from_language_item(locale: localization.locale,
137
+ value: localization.name,
138
+ item_name: :app_name,
139
+ friendly_name_postfix: "app name")
140
+
141
+ items << collect_text_items_from_language_item(locale: localization.locale,
142
+ value: localization.subtitle,
143
+ item_name: :app_subtitle,
144
+ friendly_name_postfix: "app name subtitle",
145
+ is_optional: true)
146
+
147
+ items << collect_text_items_from_language_item(locale: localization.locale,
148
+ value: localization.privacy_policy_text,
149
+ item_name: :privacy_policy_text,
150
+ friendly_name_postfix: " tv privacy policy")
151
+
152
+ items << collect_urls_from_language_item(locale: localization.locale,
153
+ value: localization.privacy_policy_url,
154
+ item_name: :privacy_policy_url,
155
+ friendly_name_postfix: "privacy URL",
156
+ is_optional: true)
149
157
  end
150
- return items
151
- end
152
-
153
- def self.generate_text_items_to_check(app: nil, app_version: nil)
154
- items = []
155
-
156
- items << TextItemToCheck.new(app_version.copyright, :copyright, "copyright")
157
-
158
- items += collect_text_items_from_language_item(hash: app_version.keywords,
159
- item_name: :keywords,
160
- friendly_name_postfix: "keywords")
161
-
162
- items += collect_text_items_from_language_item(hash: app_version.description,
163
- item_name: :description,
164
- friendly_name_postfix: "description")
165
-
166
- items += collect_text_items_from_language_item(hash: app_version.release_notes,
167
- item_name: :release_notes,
168
- friendly_name_postfix: "release notes")
169
-
170
- items += collect_text_items_from_language_item(hash: app.details.name,
171
- item_name: :app_name,
172
- friendly_name_postfix: "app name")
173
-
174
- items += collect_text_items_from_language_item(hash: app.details.apple_tv_privacy_policy,
175
- item_name: :app_subtitle,
176
- friendly_name_postfix: " tv privacy policy")
177
-
178
- items += collect_text_items_from_language_item(hash: app.details.subtitle,
179
- item_name: :app_subtitle,
180
- friendly_name_postfix: "app name subtitle",
181
- is_optional: true)
182
158
 
183
159
  should_include_iap = Precheck.config[:include_in_app_purchases]
184
160
  if should_include_iap
185
161
  UI.message("Reading in-app purchases. If you have a lot, this might take a while")
186
162
  UI.message("You can disable IAP checking by setting the `include_in_app_purchases` flag to `false`")
187
- in_app_purchases = app.in_app_purchases.all
163
+ in_app_purchases = get_iaps(app_id: app.id)
188
164
  in_app_purchases ||= []
189
165
  in_app_purchases.each do |purchase|
190
166
  items += collect_iap_language_items(purchase_edit_versions: purchase.edit.versions)
@@ -195,6 +171,64 @@ module Precheck
195
171
  return items
196
172
  end
197
173
 
174
+ def self.generate_version_items_to_check(app_version: nil)
175
+ items = []
176
+
177
+ items << TextItemToCheck.new(app_version.copyright, :copyright, "copyright")
178
+
179
+ # Version localizations
180
+ version_localizations = app_version.get_app_store_version_localizations
181
+ version_localizations.each do |localization|
182
+ items << collect_text_items_from_language_item(locale: localization.locale,
183
+ value: localization.keywords,
184
+ item_name: :keywords,
185
+ friendly_name_postfix: "keywords")
186
+
187
+ items << collect_text_items_from_language_item(locale: localization.locale,
188
+ value: localization.description,
189
+ item_name: :description,
190
+ friendly_name_postfix: "description")
191
+
192
+ items << collect_text_items_from_language_item(locale: localization.locale,
193
+ value: localization.whats_new,
194
+ item_name: :release_notes,
195
+ friendly_name_postfix: "what's new")
196
+
197
+ items << collect_urls_from_language_item(locale: localization.locale,
198
+ value: localization.support_url,
199
+ item_name: :support_url,
200
+ friendly_name_postfix: "support URL")
201
+
202
+ items << collect_urls_from_language_item(locale: localization.locale,
203
+ value: localization.marketing_url,
204
+ item_name: :marketing_url,
205
+ friendly_name_postfix: "marketing URL",
206
+ is_optional: true)
207
+ end
208
+
209
+ return items
210
+ end
211
+
212
+ # As of 2020-09-04, this is the only non App Store Connect call in prechecks
213
+ # This will need to get replaced when the API becomes available
214
+ def self.get_iaps(app_id: nil, include_deleted: false)
215
+ r = Spaceship::Tunes.client.iaps(app_id: app_id)
216
+ return_iaps = []
217
+ r.each do |product|
218
+ attrs = product
219
+
220
+ # This is not great but Spaceship::Tunes::IAPList.factory looks
221
+ # for `application.apple_id`
222
+ mock_application = OpenStruct.new({ apple_id: app_id })
223
+ attrs[:application] = mock_application
224
+
225
+ loaded_iap = Spaceship::Tunes::IAPList.factory(attrs)
226
+ next if loaded_iap.status == "deleted" && !include_deleted
227
+ return_iaps << loaded_iap
228
+ end
229
+ return return_iaps
230
+ end
231
+
198
232
  def self.collect_iap_language_items(purchase_edit_versions: nil, is_optional: false)
199
233
  items = []
200
234
  purchase_edit_versions.each do |language_key, hash|
@@ -207,12 +241,12 @@ module Precheck
207
241
  end
208
242
 
209
243
  # a few attributes are LanguageItem this method creates a TextItemToCheck for each pair
210
- def self.collect_text_items_from_language_item(hash: nil, item_name: nil, friendly_name_postfix: nil, is_optional: false)
211
- items = []
212
- hash.each do |key, value|
213
- items << TextItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{key})", is_optional)
214
- end
215
- return items
244
+ def self.collect_text_items_from_language_item(locale: nil, value: nil, item_name: nil, friendly_name_postfix: nil, is_optional: false)
245
+ return TextItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{locale})", is_optional)
246
+ end
247
+
248
+ def self.collect_urls_from_language_item(locale: nil, value: nil, item_name: nil, friendly_name_postfix: nil, is_optional: false)
249
+ return URLItemToCheck.new(value, item_name, "#{friendly_name_postfix}: (#{locale})", is_optional)
216
250
  end
217
251
  end
218
252
  end
@@ -18,10 +18,24 @@ module Precheck
18
18
  hide_keys: [:output_path],
19
19
  title: "Summary for precheck #{Fastlane::VERSION}")
20
20
 
21
- unless Spaceship::Tunes.client
21
+ if api_token
22
+
23
+ # As of 2020-09-15, App Store Connect API does not have support for IAPs yet
24
+ # This means that API Key will fail if checking for IAPs.
25
+ #
26
+ # There is also a check in Deliver::Runner for this.
27
+ # Please remove check in Deliver when the API support IAPs.
28
+ if Precheck.config[:include_in_app_purchases]
29
+ UI.user_error!("Precheck cannot check In-app purchases with the App Store Connect API Key (yet). Exclude In-app purchases from precheck or use Apple ID login")
30
+ end
31
+
32
+ UI.message("Creating authorization token for App Store Connect API")
33
+ Spaceship::ConnectAPI.token = api_token
34
+ elsif Spaceship::Tunes.client.nil?
35
+ # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
36
+ # Prompts select team if multiple teams and none specified
22
37
  UI.message("Starting login with user '#{Precheck.config[:username]}'")
23
- Spaceship::Tunes.login(Precheck.config[:username])
24
- Spaceship::Tunes.select_team
38
+ Spaceship::ConnectAPI.login(Precheck.config[:username], use_portal: false, use_tunes: true)
25
39
 
26
40
  UI.message("Successfully logged in")
27
41
  end
@@ -57,6 +71,12 @@ module Precheck
57
71
  return true
58
72
  end
59
73
 
74
+ def api_token
75
+ @api_token ||= Spaceship::ConnectAPI::Token.create(Precheck.config[:api_key]) if Precheck.config[:api_key]
76
+ @api_token ||= Spaceship::ConnectAPI::Token.from_json_file(Precheck.config[:api_key_path]) if Precheck.config[:api_key_path]
77
+ return @api_token
78
+ end
79
+
60
80
  def print_items_not_checked(processor_result: nil)
61
81
  names = processor_result.items_not_checked.map(&:friendly_name)
62
82
  UI.message("😶 Metadata fields not checked by any rule: #{names.join(', ')}".yellow) if names.length > 0
@@ -160,11 +180,12 @@ module Precheck
160
180
  end
161
181
 
162
182
  def app
163
- Spaceship::Tunes::Application.find(Precheck.config[:app_identifier])
183
+ Spaceship::ConnectAPI::App.find(Precheck.config[:app_identifier])
164
184
  end
165
185
 
166
186
  def latest_app_version
167
- @latest_version ||= app.latest_version
187
+ platform = Spaceship::ConnectAPI::Platform.map(Precheck.config[:platform])
188
+ @latest_version ||= app.get_edit_app_store_version(platform: platform)
168
189
  end
169
190
 
170
191
  # Makes sure the current App ID exists. If not, it will show an appropriate error message
@@ -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)