Class: Fastlane::Actions::UploadSymbolsToCrashlyticsAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/upload_symbols_to_crashlytics.rb

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, sh, step_text

Class Method Details

.authorsObject



96
97
98
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 96

def self.authors
  ["KrauseFx"]
end

.available_optionsObject



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
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 52

def self.available_options
  [
    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.expand_path(value)}'") unless File.exist?(value)
                                   UI.user_error!("Symbolication file needs to be dSYM or zip") unless value.end_with?("dSYM.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

.descriptionObject



40
41
42
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 40

def self.description
  "Upload dSYM symbolication files to Crashlytics"
end

.detailsObject



44
45
46
47
48
49
50
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 44

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 100

def self.is_supported?(platform)
  platform == :ios
end

.outputObject



88
89
90
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 88

def self.output
  nil
end

.return_valueObject



92
93
94
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 92

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
29
30
31
32
33
34
# File 'lib/fastlane/actions/upload_symbols_to_crashlytics.rb', line 4

def self.run(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]

  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]

  dsym_paths = []
  dsym_paths << params[:dsym_path]
  dsym_paths += Actions.lane_context[SharedValues::DSYM_PATHS] if Actions.lane_context[SharedValues::DSYM_PATHS]

  UI.error("Couldn't find any dSYMs, please pass them using the dsym_path option") if dsym_paths.count == 0

  dsym_paths.each do |current_path|
    command = []
    command << File.expand_path(params[:binary_path])
    command << "-a #{params[:api_token]}"
    command << "-p #{params[:platform]}"
    command << File.expand_path(current_path)
    Actions.sh(command.join(" "))
  end

  UI.success("Successfully uploaded dSYM files to Crashlytics 💯")
end