Class: Fastlane::Actions::UploadSymbolsToCrashlyticsAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::UploadSymbolsToCrashlyticsAction
- Defined in:
- lib/fastlane/actions/upload_symbols_to_crashlytics.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
- .find_api_token(params) ⇒ Object
- .find_binary_path(params) ⇒ Object
- .handle_dsym(params, current_path) ⇒ Object
- .run(params) ⇒ Object
- .upload_dsym(params, path) ⇒ Object
Methods inherited from Fastlane::Action
action_name, author, sh, step_text
Class Method Details
.authors ⇒ Object
145 146 147 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 145 def self. ["KrauseFx"] end |
.available_options ⇒ Object
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 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 101 def self. [ FastlaneCore::ConfigItem.new(key: :dsym_path, env_name: "FL_UPLOAD_SYMBOLS_TO_CRASHLYTICS_DSYM_PATH", description: "Path to the DSYM file or zip to upload", default_value: ENV[SharedValues::DSYM_OUTPUT_PATH.to_s] || (Dir["./**/*.dSYM"] + Dir["./**/*.dSYM.zip"]).first, optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find file at path '#{File.(value)}'") unless File.exist?(value) UI.user_error!("Symbolication file needs to be dSYM or zip") unless value.end_with?(".zip", ".dSYM") end), FastlaneCore::ConfigItem.new(key: :api_token, env_name: "CRASHLYTICS_API_TOKEN", optional: true, description: "Crashlytics Beta API Token", verify_block: proc do |value| UI.user_error!("No API token for Crashlytics given, pass using `api_token: 'token'`") if value.to_s.length == 0 end), FastlaneCore::ConfigItem.new(key: :binary_path, env_name: "FL_UPLOAD_SYMBOLS_TO_CRASHLYTICS_BINARY_PATH", description: "The path to the upload-symbols file", optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :platform, env_name: "FL_UPLOAD_SYMBOLS_TO_CRASHLYTICS_PLATFORM", description: "The platform of the app (ios, tvos, mac)", default_value: "ios", verify_block: proc do |value| available = ['ios', 'tvos', 'mac'] UI.user_error!("Invalid platform '#{value}', must be #{available.join(', ')}") unless available.include?(value) end) ] end |
.description ⇒ Object
89 90 91 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 89 def self.description "Upload dSYM symbolication files to Crashlytics" end |
.details ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 93 def self.details [ "This action allows you to upload symbolication files to Crashlytics.", "It's extra useful if you use it to download the latest dSYM files from Apple when you", "use Bitcode" ].join(" ") end |
.find_api_token(params) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 66 def self.find_api_token(params) unless params[:api_token].to_s.length > 0 Dir["./**/Info.plist"].each do |current| result = Actions::GetInfoPlistValueAction.run(path: current, key: "Fabric") next unless result next unless result.kind_of?(Hash) params[:api_token] ||= result["APIKey"] end end UI.user_error!("Please provide an api_token using api_token:") unless params[:api_token] end |
.find_binary_path(params) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 78 def self.find_binary_path(params) params[:binary_path] ||= (Dir["/Applications/Fabric.app/**/upload-symbols"] + Dir["./Pods/**/upload-symbols"]).last UI.user_error!("Please provide a path to the binary using binary_path:") unless params[:binary_path] params[:binary_path] = File.(params[:binary_path]) end |
.handle_dsym(params, current_path) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 32 def self.handle_dsym(params, current_path) if current_path.end_with?(".dSYM") upload_dsym(params, current_path) elsif current_path.end_with?(".zip") UI.("Extracting '#{current_path}'...") current_path = File.(current_path) Dir.mktmpdir do |dir| Dir.chdir(dir) do Actions.sh("unzip -qo #{current_path.shellescape}") Dir["*.dSYM"].each do |sub| handle_dsym(params, sub) end end end else UI.error "Don't know how to handle '#{current_path}'" end end |
.is_supported?(platform) ⇒ Boolean
149 150 151 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 149 def self.is_supported?(platform) platform == :ios end |
.output ⇒ Object
137 138 139 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 137 def self.output nil end |
.return_value ⇒ Object
141 142 143 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 141 def self.return_value nil end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 4 def self.run(params) require 'tmpdir' find_binary_path(params) find_api_token(params) dsym_paths = [] dsym_paths << params[:dsym_path] dsym_paths += Actions.lane_context[SharedValues::DSYM_PATHS] if Actions.lane_context[SharedValues::DSYM_PATHS] if dsym_paths.count == 0 UI.error("Couldn't find any dSYMs, please pass them using the dsym_path option") return nil end # Get rid of duplicates (which might occur when both passed and detected) dsym_paths = dsym_paths.collect { |a| File.(a) } dsym_paths.uniq! dsym_paths.each do |current_path| handle_dsym(params, current_path) end UI.success("Successfully uploaded dSYM files to Crashlytics 💯") end |
.upload_dsym(params, path) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 52 def self.upload_dsym(params, path) UI.("Uploading '#{path}'...") command = [] command << params[:binary_path] command << "-a #{params[:api_token]}" command << "-p #{params[:platform]}" command << File.(path).shellescape begin Actions.sh(command.join(" "), log: false) rescue => ex UI.error ex.to_s # it fails, however we don't want to fail everything just for this end end |