Class: Fastlane::Actions::UploadSymbolsToAppmetricaAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



72
73
74
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 72

def self.authors
  ["Yandex, LLC"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 80

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :binary_path,
                                 description: "The path to 'helper' binary in AppMetrica framework",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :post_api_key,
                                 env_name: "APPMETRICA_POST_API_KEY",
                                 description: "Post API key. This mandatory parameter is "\
                                 "used to upload dSYMs to AppMetrica",
                                 optional: false,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :package_output_path,
                                 description: "The path where temporary archives are stored. "\
                                 "If not specified, default system's temporary directory used instead",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :verbose,
                                 description: "Verbose mode. Displays additional information",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :files,
                                 description: "An optional list of dSYM files or directories that "\
                                 "contain these files to upload. If not specified, "\
                                 "the local working directory used by default",
                                 optional: true,
                                 type: Array)
  ]
end

.descriptionObject



68
69
70
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 68

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

.detailsObject



76
77
78
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 76

def self.details
  "This plugin allows uploading dSYM symbolication files to AppMetrica. It should be applied if you use Bitcode"
end

.find_binary(params) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 47

def self.find_binary(params)
  params[:binary_path] ||= Dir["./Pods/**/helper"].last

  unless params[:binary_path]
    UI.user_error!("Failed to find 'helper' binary. Install YandexMobileMetrica 3.8.0 pod or higher. "\
      "You may specify the location of the binary by using the binary_path option")
  end

  params[:binary_path] = File.expand_path(params[:binary_path])

  cli_version = Gem::Version.new(`#{params[:binary_path]} --version`.strip)
  unless Gem::Requirement.new(Fastlane::Appmetrica::CLI_VERSION) =~ cli_version
    UI.user_error!("Your 'helper' is outdatedcd, please upgrade to at least version "\
      "#{Fastlane::Appmetrica::CLI_VERSION} and start again!")
  end
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 110

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.process_file(file_path, temp_dir) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 37

def self.process_file(file_path, temp_dir)
  if File.extname(file_path) == ".zip"
    output_path = File.join(temp_dir, SecureRandom.uuid)
    Dir.mkdir(output_path)
    Actions.sh("unzip -o #{file_path.shellescape} -d #{output_path.shellescape} 2>/dev/null")
    return output_path
  end
  return File.absolute_path(file_path)
end

.run(params) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 6

def self.run(params)
  find_binary(params)

  Dir.mktmpdir do |temp_dir|
    self.run_helper(temp_dir, params)
  end
end

.run_helper(temp_dir, params) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/appmetrica/actions/upload_symbols_to_appmetrica.rb', line 14

def self.run_helper(temp_dir, params)
  unless params[:package_output_path].nil?
    package_output_path = File.absolute_path(params[:package_output_path])
  end

  files = []
  files += params[:files] if params[:files]
  files << Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] if Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH]
  files += Actions.lane_context[SharedValues::DSYM_PATHS] if Actions.lane_context[SharedValues::DSYM_PATHS]
    
  files = files.map do |file|
    self.process_file(file, temp_dir) unless file.nil?
  end

  cmd = [params[:binary_path], "--post-api-key=#{params[:post_api_key]}"]
  cmd << "--verbose" if params[:verbose]
  cmd << "--package-output-path=#{package_output_path.shellescape}" unless package_output_path.nil?
  cmd += files unless files.nil?

  UI.message("Starting helper")
  Actions.sh(cmd)
end