21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 21
def self.get_build_number(params)
UI.message("Login to App Store Connect (#{params[:username]})")
Spaceship::Tunes.login(params[:username])
Spaceship::Tunes.select_team
UI.message("Login successful")
platform = params[:platform]
app = Spaceship::Tunes::Application.find(params[:app_identifier])
if params[:live]
UI.message("Fetching the latest build number for live-version")
UI.user_error!("Could not find a live-version of #{params[:app_identifier]} on iTC") unless app.live_version
build_nr = app.live_version.current_build_number
else
version_number = params[:version]
unless version_number
begin
train_numbers = app.all_build_train_numbers(platform: platform)
testflight_version = self.order_versions(train_numbers).last
rescue
testflight_version = params[:version]
end
if testflight_version
version_number = testflight_version
else
version_number = UI.input("You have to specify a new version number, as there are multiple to choose from")
end
end
UI.message("Fetching the latest build number for version #{version_number}")
begin
build_numbers = app.all_builds_for_train(train: version_number, platform: platform).map(&:build_version)
build_nr = self.order_versions(build_numbers).last
if build_nr.nil? && params[:initial_build_number]
UI.message("Could not find a build on iTC. Using supplied 'initial_build_number' option")
build_nr = params[:initial_build_number]
end
rescue
UI.user_error!("Could not find a build on iTC - and 'initial_build_number' option is not set") unless params[:initial_build_number]
build_nr = params[:initial_build_number]
end
end
UI.message("Latest upload for version #{version_number} is build: #{build_nr}")
build_nr
end
|