Skip to content

Commit b6b106e

Browse files
tmm1mpirri
authored andcommitted
Teach pilot about apps with multiple platforms (fastlane#7267)
* teach pilot about multiple platforms * use the build platform when updating a build testing status * pilot is supported on tvos too * style * build might be nil * redundant config * platform should not be required to list builds * optional platform for distributing latest build (not from upload)
1 parent 9faa3ad commit b6b106e

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

fastlane/lib/fastlane/actions/pilot.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def self.authors
6464
end
6565

6666
def self.is_supported?(platform)
67-
platform == :ios
67+
true
6868
end
6969
end
7070
end

pilot/lib/pilot/build_manager.rb

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def upload(options)
3131
end
3232

3333
UI.message("If you want to skip waiting for the processing to be finished, use the `skip_waiting_for_build_processing` option")
34-
uploaded_build = wait_for_processing_build(options) # this might take a while
34+
uploaded_build = wait_for_processing_build(options, platform) # this might take a while
3535

3636
distribute(options, uploaded_build)
3737
end
@@ -43,7 +43,8 @@ def distribute(options, build = nil)
4343
end
4444

4545
if build.nil?
46-
builds = app.all_processing_builds + app.builds
46+
platform = fetch_app_platform(required: false)
47+
builds = app.all_processing_builds(platform: platform) + app.builds(platform: platform)
4748
# sort by upload_date
4849
builds.sort! { |a, b| a.upload_date <=> b.upload_date }
4950
build = builds.last
@@ -81,12 +82,8 @@ def list(options)
8182
config[:app_identifier] = UI.input("App Identifier: ")
8283
end
8384

84-
if config[:app_platform].to_s.length == 0
85-
config[:app_platform] = ask("App Platform (ios, appletvos, osx): ")
86-
end
87-
88-
UI.user_error!("App Platform must be ios, appletvos, or osx") unless ['ios', 'appletvos', 'osx'].include? config[:app_platform]
89-
builds = app.all_processing_builds(platform: config[:app_platform]) + app.builds(platform: config[:app_platform])
85+
platform = fetch_app_platform(required: false)
86+
builds = app.all_processing_builds(platform: platform) + app.builds(platform: platform)
9087
# sort by upload_date
9188
builds.sort! { |a, b| a.upload_date <=> b.upload_date }
9289
rows = builds.collect { |build| describe_build(build) }
@@ -127,8 +124,7 @@ def should_update_build_information(options)
127124

128125
# This method will takes care of checking for the processing builds every few seconds
129126
# @return [Build] The build that we just uploaded
130-
131-
def wait_for_processing_build(platform: nil)
127+
def wait_for_processing_build(options, platform)
132128
# the upload date of the new buid
133129
# we use it to identify the build
134130
start = Time.now
@@ -144,7 +140,7 @@ def wait_for_processing_build(platform: nil)
144140
# build trains right away, and if we don't do this check, we will
145141
# get break out of this loop and then generate an error later when we
146142
# have a nil build
147-
if app.build_trains.count == 0
143+
if app.build_trains(platform: platform).count == 0
148144
UI.message("New application; waiting for build train to appear on iTunes Connect")
149145
else
150146
builds = app.all_processing_builds(platform: platform)

pilot/lib/pilot/manager.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ def fetch_app_identifier
5757
return result
5858
end
5959

60-
def fetch_app_platform
60+
def fetch_app_platform(required: true)
6161
result = config[:app_platform]
62-
result ||= FastlaneCore::IpaFileAnalyser.fetch_app_platform(config[:ipa])
63-
result ||= ask("Please enter the app's platform (appletvos, ios, osx): ")
64-
UI.user_error!("App Platform must be ios, appletvos, or osx") unless ['ios', 'appletvos', 'osx'].include? result
65-
UI.verbose("App Platform (#{result})")
62+
result ||= FastlaneCore::IpaFileAnalyser.fetch_app_platform(config[:ipa]) if config[:ipa]
63+
if required
64+
result ||= ask("Please enter the app's platform (appletvos, ios, osx): ")
65+
UI.user_error!("App Platform must be ios, appletvos, or osx") unless ['ios', 'appletvos', 'osx'].include? result
66+
UI.verbose("App Platform (#{result})")
67+
end
6668
return result
6769
end
6870
end

pilot/lib/pilot/options.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def self.available_options
2424
env_name: "PILOT_PLATFORM",
2525
description: "The platform to use (optional)",
2626
optional: true,
27-
default_value: "ios",
2827
verify_block: proc do |value|
2928
UI.user_error!("The platform can only be ios, appletvos, or osx") unless ['ios', 'appletvos', 'osx'].include? value
3029
end),

spaceship/lib/spaceship/tunes/build_train.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@ def latest_build
118118

119119
# @param (testing_type) internal or external
120120
def update_testing_status!(new_value, testing_type, build = nil)
121-
data = client.build_trains(self.application.apple_id, testing_type, platform: self.application.platform)
122-
123121
build ||= latest_build if testing_type == 'external'
122+
platform = build ? build.platform : self.application.platform
124123
testing_key = "#{testing_type}Testing"
125124

125+
data = client.build_trains(self.application.apple_id, testing_type, platform: platform)
126+
126127
# Delete the irrelevant trains and update the relevant one to enable testing
127128
data['trains'].delete_if do |train|
128129
if train['versionString'] != version_string

0 commit comments

Comments
 (0)