Class: Fastlane::Actions::DownloadDsymsAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::DownloadDsymsAction
- Defined in:
- fastlane/lib/fastlane/actions/download_dsyms.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
- .return_value ⇒ Object
Class Method Summary collapse
- .download(download_url, bundle_id, train_number, build_version, uploaded_date, output_directory) ⇒ Object
- .download_file(url) ⇒ Object
- .get_details_and_download_dsym(app: nil, train: nil, build_number: nil, uploaded_date: nil, platform: nil, wait_for_dsym_processing: nil, wait_timeout: nil, output_directory: nil) ⇒ Object
-
.get_latest_build!(app_id: nil, version: nil, platform: nil) ⇒ Object
rubocop:enable Metrics/PerceivedComplexity.
-
.run(params) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity.
- .write_dsym(data, bundle_id, train_number, build_number, output_directory) ⇒ Object
Methods inherited from Fastlane::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.authors ⇒ Object
345 346 347 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 345 def self. ["KrauseFx"] end |
.available_options ⇒ Object
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 242 def self. user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id) user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id) [ FastlaneCore::ConfigItem.new(key: :username, short_option: "-u", env_name: "DOWNLOAD_DSYMS_USERNAME", description: "Your Apple ID Username for App Store Connect", default_value: user, default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :app_identifier, short_option: "-a", env_name: "DOWNLOAD_DSYMS_APP_IDENTIFIER", description: "The bundle identifier of your app", optional: false, code_gen_sensitive: true, default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier), default_value_dynamic: true), FastlaneCore::ConfigItem.new(key: :team_id, short_option: "-k", env_name: "DOWNLOAD_DSYMS_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: :team_name, short_option: "-e", env_name: "DOWNLOAD_DSYMS_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), FastlaneCore::ConfigItem.new(key: :platform, short_option: "-p", env_name: "DOWNLOAD_DSYMS_PLATFORM", description: "The app platform for dSYMs you wish to download (ios, appletvos)", optional: true, default_value: :ios), FastlaneCore::ConfigItem.new(key: :version, short_option: "-v", env_name: "DOWNLOAD_DSYMS_VERSION", description: "The app version for dSYMs you wish to download, pass in 'latest' to download only the latest build's dSYMs or 'live' to download only the live version dSYMs", optional: true), FastlaneCore::ConfigItem.new(key: :build_number, short_option: "-b", env_name: "DOWNLOAD_DSYMS_BUILD_NUMBER", description: "The app build_number for dSYMs you wish to download", optional: true, is_string: false), FastlaneCore::ConfigItem.new(key: :min_version, short_option: "-m", env_name: "DOWNLOAD_DSYMS_MIN_VERSION", description: "The minimum app version for dSYMs you wish to download", optional: true), FastlaneCore::ConfigItem.new(key: :after_uploaded_date, short_option: "-d", env_name: "DOWNLOAD_DSYMS_AFTER_UPLOADED_DATE", description: "The uploaded date after which you wish to download dSYMs", optional: true, is_string: true), FastlaneCore::ConfigItem.new(key: :output_directory, short_option: "-s", env_name: "DOWNLOAD_DSYMS_OUTPUT_DIRECTORY", description: "Where to save the download dSYMs, defaults to the current path", optional: true), FastlaneCore::ConfigItem.new(key: :wait_for_dsym_processing, short_option: "-w", env_name: "DOWNLOAD_DSYMS_WAIT_FOR_DSYM_PROCESSING", description: "Wait for dSYMs to process", optional: true, default_value: false, type: Boolean), FastlaneCore::ConfigItem.new(key: :wait_timeout, short_option: "-t", env_name: "DOWNLOAD_DSYMS_WAIT_TIMEOUT", description: "Number of seconds to wait for dSYMs to process", optional: true, default_value: 300, type: Integer) ] end |
.category ⇒ Object
364 365 366 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 364 def self.category :app_store_connect end |
.description ⇒ Object
221 222 223 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 221 def self.description "Download dSYM files from App Store Connect for Bitcode apps" end |
.details ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 225 def self.details sample = <<-SAMPLE.markdown_sample ```ruby lane :refresh_dsyms do download_dsyms # Download dSYM files from iTC upload_symbols_to_crashlytics # Upload them to Crashlytics clean_build_artifacts # Delete the local dSYM files end ``` SAMPLE [ "This action downloads dSYM files from App Store Connect after the ipa gets re-compiled by Apple. Useful if you have Bitcode enabled.".markdown_preserve_newlines, sample ].join("\n") end |
.download(download_url, bundle_id, train_number, build_version, uploaded_date, output_directory) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 177 def self.download(download_url, bundle_id, train_number, build_version, uploaded_date, output_directory) result = self.download_file(download_url) path = write_dsym(result, bundle_id, train_number, build_version, output_directory) UI.success("🔑 Successfully downloaded dSYM file for #{train_number} - #{build_version} to '#{path}'") Actions.lane_context[SharedValues::DSYM_PATHS] ||= [] Actions.lane_context[SharedValues::DSYM_PATHS] << File.(path) unless uploaded_date.nil? Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE] ||= uploaded_date current_latest = Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE] Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE] = [current_latest, uploaded_date].max UI.verbose("Most recent build uploaded_date #{Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE]}") end end |
.download_file(url) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 202 def self.download_file(url) uri = URI.parse(url) if ENV['http_proxy'] UI.verbose("Found 'http_proxy' environment variable so connect via proxy") proxy_uri = URI.parse(ENV['http_proxy']) http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port) else http = Net::HTTP.new(uri.host, uri.port) end http.read_timeout = 300 http.use_ssl = (uri.scheme == "https") res = http.get(uri.request_uri) res.body end |
.example_code ⇒ Object
353 354 355 356 357 358 359 360 361 362 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 353 def self.example_code [ 'download_dsyms', 'download_dsyms(version: "1.0.0", build_number: "345")', 'download_dsyms(version: "1.0.1", build_number: 42)', 'download_dsyms(version: "live")', 'download_dsyms(min_version: "1.2.3")', 'download_dsyms(after_uploaded_date: "2020-09-11T19:00:00+01:00")' ] end |
.get_details_and_download_dsym(app: nil, train: nil, build_number: nil, uploaded_date: nil, platform: nil, wait_for_dsym_processing: nil, wait_timeout: nil, output_directory: nil) ⇒ Object
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 151 152 153 154 155 156 157 158 159 160 161 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 124 def self.get_details_and_download_dsym(app: nil, train: nil, build_number: nil, uploaded_date: nil, platform: nil, wait_for_dsym_processing: nil, wait_timeout: nil, output_directory: nil) start = Time.now download_url = nil loop do begin resp = Spaceship::Tunes.client.build_details(app_id: app.id, train: train, build_number: build_number, platform: platform) resp['apple_id'] = app.id build_details = Spaceship::Tunes::BuildDetails.factory(resp) download_url = build_details.dsym_url UI.verbose("dsym_url: #{download_url}") rescue Spaceship::TunesClient::ITunesConnectError => ex UI.error("Error accessing dSYM file for build\n\n#{build}\n\nException: #{ex}") end unless download_url if !wait_for_dsym_processing || (Time.now - start) > wait_timeout # In some cases, AppStoreConnect does not process the dSYMs, thus no error should be thrown. UI.("Could not find any dSYM for #{build_number} (#{train})") else UI.("Waiting for dSYM file to appear...") sleep(30) next end end break end if download_url self.download(download_url, app.bundle_id, train, build_number, uploaded_date, output_directory) return if build_number else UI.("No dSYM URL for #{build_number} (#{train})") end end |
.get_latest_build!(app_id: nil, version: nil, platform: nil) ⇒ Object
rubocop:enable Metrics/PerceivedComplexity
164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 164 def self.get_latest_build!(app_id: nil, version: nil, platform: nil) filter = { app: app_id } filter["preReleaseVersion.version"] = version filter["preReleaseVersion.platform"] = platform latest_build = Spaceship::ConnectAPI.get_builds(filter: filter, sort: "-uploadedDate", includes: "preReleaseVersion").first if latest_build.nil? UI.user_error!("Could not find latest build for version #{version}") end return latest_build end |
.is_supported?(platform) ⇒ Boolean
349 350 351 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 349 def self.is_supported?(platform) [:ios, :appletvos].include?(platform) end |
.output ⇒ Object
334 335 336 337 338 339 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 334 def self.output [ ['DSYM_PATHS', 'An array to all the zipped dSYM files'], ['DSYM_LATEST_UPLOADED_DATE', 'Date of the most recent uploaded time of successfully downloaded dSYM files'] ] end |
.return_value ⇒ Object
341 342 343 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 341 def self.return_value nil end |
.run(params) ⇒ Object
rubocop:disable Metrics/PerceivedComplexity
9 10 11 12 13 14 15 16 17 18 19 20 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 71 72 73 74 75 76 77 78 79 80 81 82 83 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 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 9 def self.run(params) require 'openssl' require 'spaceship' require 'net/http' require 'date' # Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables # Prompts select team if multiple teams and none specified UI.("Login to App Store Connect (#{params[:username]})") Spaceship::ConnectAPI.login(params[:username], use_portal: false, use_tunes: true) UI.("Login successful") # Get App app = Spaceship::ConnectAPI::App.find(params[:app_identifier]) unless app UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}") end # Process options version = params[:version] build_number = params[:build_number].to_s unless params[:build_number].nil? itc_platform = params[:platform] output_directory = params[:output_directory] wait_for_dsym_processing = params[:wait_for_dsym_processing] wait_timeout = params[:wait_timeout] min_version = Gem::Version.new(params[:min_version]) if params[:min_version] after_uploaded_date = DateTime.parse(params[:after_uploaded_date]) unless params[:after_uploaded_date].nil? platform = Spaceship::ConnectAPI::Platform.map(itc_platform) # Set version if it is latest if version == 'latest' # Try to grab the edit version first, else fallback to live version UI.("Looking for latest version...") latest_version = app.get_edit_app_store_version(platform: platform) || app.get_live_app_store_version(platform: platform) UI.user_error!("Could not find latest version for your app, please try setting a specific version") if latest_version.nil? latest_build = get_latest_build!(app_id: app.id, version: latest_version.version_string, platform: platform) version = latest_build.app_version build_number = latest_build.version elsif version == 'live' UI.("Looking for live version...") live_version = app.get_live_app_store_version(platform: platform) UI.user_error!("Could not find live version for your app, please try setting 'latest' or a specific version") if live_version.nil? # No need to search for candidates, because released App Store version should only have one build version = live_version.version_string build_number = live_version.build.version end # Remove leading zeros from version string (eg. 1.02 -> 1.2) if version version = version.split(".").map(&:to_i).join(".") end # Make sure output_directory has a slash on the end if output_directory && !output_directory.end_with?('/') output_directory += '/' end # Write a nice message = [] << "Looking for dSYM files for '#{params[:app_identifier]}' on platform #{platform}" << "v#{version}" if version << "(#{build_number})" if build_number UI.(.join(" ")) filter = { app: app.id } filter["preReleaseVersion.platform"] = platform build_resps = Spaceship::ConnectAPI.get_builds(filter: filter, sort: "-uploadedDate", includes: "preReleaseVersion").all_pages builds = build_resps.flat_map(&:to_models) builds.each do |build| asc_app_version = build.app_version asc_build_number = build.version uploaded_date = DateTime.parse(build.uploaded_date) = [] << "Found train (version): #{asc_app_version}" << ", comparing to supplied version: #{version}" if version UI.verbose(.join(" ")) if version && version != asc_app_version UI.verbose("Version #{version} doesn't match: #{asc_app_version}") next end if min_version && min_version > Gem::Version.new(asc_app_version) UI.verbose("Min version #{min_version} not reached: #{asc_app_version}") next end if after_uploaded_date && after_uploaded_date >= uploaded_date UI.verbose("Upload date #{after_uploaded_date} not reached: #{uploaded_date}") next end = [] << "Found build version: #{asc_build_number}" << ", comparing to supplied build_number: #{build_number}" if build_number UI.verbose(.join(" ")) if build_number && asc_build_number != build_number UI.verbose("build_version: #{asc_build_number} doesn't match: #{build_number}") next end UI.verbose("Build_version: #{asc_build_number} matches #{build_number}, grabbing dsym_url") if build_number get_details_and_download_dsym(app: app, train: asc_app_version, build_number: asc_build_number, uploaded_date: uploaded_date, platform: itc_platform, wait_for_dsym_processing: wait_for_dsym_processing, wait_timeout: wait_timeout, output_directory: output_directory) end end |
.write_dsym(data, bundle_id, train_number, build_number, output_directory) ⇒ Object
193 194 195 196 197 198 199 200 |
# File 'fastlane/lib/fastlane/actions/download_dsyms.rb', line 193 def self.write_dsym(data, bundle_id, train_number, build_number, output_directory) file_name = "#{bundle_id}-#{train_number}-#{build_number}.dSYM.zip" if output_directory file_name = output_directory + file_name end File.binwrite(file_name, data) file_name end |