Class: Fastlane::Actions::AppStoreBuildNumberAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::AppStoreBuildNumberAction
- Defined in:
- fastlane/lib/fastlane/actions/app_store_build_number.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
permalink .authors ⇒ Object
[View source]
180 181 182 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 180 def self. ["hjanuschka"] end |
permalink .available_options ⇒ Object
[View source]
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 84 def self. user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id) user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id) [ FastlaneCore::ConfigItem.new(key: :initial_build_number, env_name: "INITIAL_BUILD_NUMBER", description: "sets the build number to given value if no build is in current train", is_string: false), FastlaneCore::ConfigItem.new(key: :app_identifier, short_option: "-a", env_name: "FASTLANE_APP_IDENTIFIER", description: "The bundle identifier of your app", code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier), default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :username, short_option: "-u", env_name: "ITUNESCONNECT_USER", description: "Your Apple ID Username", default_value: user, default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :team_id, short_option: "-k", env_name: "APPSTORE_BUILD_NUMBER_LIVE_TEAM_ID", description: "The ID of your App Store Connect team if you're in multiple teams", optional: true, is_string: false, # as we also allow integers, which we convert to strings anyway code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id), default_value_dynamic: true, verify_block: proc do |value| ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s end), FastlaneCore::ConfigItem.new(key: :live, short_option: "-l", env_name: "APPSTORE_BUILD_NUMBER_LIVE", description: "Query the live version (ready-for-sale)", optional: true, is_string: false, default_value: true), FastlaneCore::ConfigItem.new(key: :version, env_name: "LATEST_VERSION", description: "The version number whose latest build number we want", optional: true), FastlaneCore::ConfigItem.new(key: :platform, short_option: "-j", env_name: "APPSTORE_PLATFORM", description: "The platform to use (optional)", optional: true, is_string: true, default_value: "ios", verify_block: proc do |value| UI.user_error!("The platform can only be ios, appletvos, or osx") unless %('ios', 'appletvos', 'osx').include?(value) end), FastlaneCore::ConfigItem.new(key: :team_name, short_option: "-e", env_name: "LATEST_TESTFLIGHT_BUILD_NUMBER_TEAM_NAME", description: "The name of your App Store Connect team if you're in multiple teams", optional: true, code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name), default_value_dynamic: true, verify_block: proc do |value| ENV["FASTLANE_ITC_TEAM_NAME"] = value.to_s end) ] end |
permalink .category ⇒ Object
[View source]
184 185 186 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 184 def self.category :app_store_connect end |
permalink .description ⇒ Object
[View source]
80 81 82 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 80 def self.description "Returns the current build_number of either live or edit version" end |
permalink .details ⇒ Object
[View source]
158 159 160 161 162 163 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 158 def self.details [ "Returns the current build number of either the live or testflight version - it is useful for getting the build_number of the current or ready-for-sale app version, and it also works on non-live testflight version.", "If you need to handle more build-trains please see `latest_testflight_build_number`." ].join("\n") end |
permalink .example_code ⇒ Object
[View source]
165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 165 def self.example_code [ 'app_store_build_number', 'app_store_build_number( app_identifier: "app.identifier", username: "user@host.com" )', 'app_store_build_number( live: false, app_identifier: "app.identifier", version: "1.2.9" )' ] end |
permalink .get_build_number(params) ⇒ Object
[View source]
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.("Login to App Store Connect (#{params[:username]})") Spaceship::Tunes.login(params[:username]) Spaceship::Tunes.select_team UI.("Login successful") platform = params[:platform] app = Spaceship::Tunes::Application.find(params[:app_identifier]) if params[:live] UI.("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 # Automatically fetch the latest version in testflight 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.("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.("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.("Latest upload for version #{version_number} is build: #{build_nr}") build_nr end |
permalink .is_supported?(platform) ⇒ Boolean
188 189 190 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 188 def self.is_supported?(platform) [:ios, :mac].include?(platform) end |
permalink .order_versions(versions) ⇒ Object
[View source]
72 73 74 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 72 def self.order_versions(versions) versions.map(&:to_s).sort_by { |v| Gem::Version.new(v) } end |
permalink .output ⇒ Object
[View source]
152 153 154 155 156 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 152 def self.output [ ['LATEST_BUILD_NUMBER', 'The latest build number of either live or testflight version'] ] end |
permalink .run(params) ⇒ Object
[View source]
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'fastlane/lib/fastlane/actions/app_store_build_number.rb', line 8 def self.run(params) require 'spaceship' build_nr = get_build_number(params) # Convert build_nr to int (for legacy use) if no "." in string if build_nr.kind_of?(String) && !build_nr.include?(".") build_nr = build_nr.to_i end Actions.lane_context[SharedValues::LATEST_BUILD_NUMBER] = build_nr end |