Class: Fastlane::Actions::SentryUploadSourcemapAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



123
124
125
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 123

def self.authors
  ["wschurman"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 65

def self.available_options
  Helper::SentryConfig.common_api_config_items + [
    FastlaneCore::ConfigItem.new(key: :version,
                                 description: "Release version on Sentry"),
    FastlaneCore::ConfigItem.new(key: :app_identifier,
                                 short_option: "-a",
                                 env_name: "SENTRY_APP_IDENTIFIER",
                                 description: "App Bundle Identifier, prepended to version",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :build,
                                 short_option: "-b",
                                 description: "Release build on Sentry",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :dist,
                                 description: "Distribution in release",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :sourcemap,
                                 description: "Path or an array of paths to the sourcemap(s) to upload",
                                 type: Array,
                                 verify_block: proc do |values|
                                   [*values].each do |value|
                                     UI.user_error! "Could not find sourcemap at path '#{value}'" unless File.exist?(value)
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :rewrite,
                                 description: "Rewrite the sourcemaps before upload",
                                 default_value: false,
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :strip_prefix,
                                 conflicting_options: [:strip_common_prefix],
                                 description: "Chop-off a prefix from uploaded files",
                                 default_value: false,
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :strip_common_prefix,
                                 conflicting_options: [:strip_prefix],
                                 description: "Automatically guess what the common prefix is and chop that one off",
                                 default_value: false,
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :url_prefix,
                                 description: "Sets a URL prefix in front of all files",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ignore,
                                 description: "Ignores all files and folders matching the given glob or array of globs",
                                 is_string: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :ignore_file,
                                 description: "Ignore all files and folders specified in the given ignore file, e.g. .gitignore",
                                 optional: true)
  ]
end

.descriptionObject



54
55
56
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 54

def self.description
  "Upload one or more sourcemap(s) to a release of a project on Sentry"
end

.detailsObject



58
59
60
61
62
63
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 58

def self.details
  [
    "This action allows you to upload one or more sourcemap(s) to a release of a project on Sentry.",
    "See https://docs.sentry.io/learn/cli/releases/#upload-sourcemaps for more information."
  ].join(" ")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


127
128
129
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 127

def self.is_supported?(platform)
  true
end

.return_valueObject



119
120
121
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 119

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb', line 4

def self.run(params)
  require 'shellwords'

  Helper::SentryConfig.parse_api_params(params)

  version = params[:version]
  version = "#{params[:app_identifier]}@#{params[:version]}" if params[:app_identifier]
  version = "#{version}+#{params[:build]}" if params[:build]

  sourcemaps = params[:sourcemap]

  command = [
    "releases",
    "files",
    version,
    "upload-sourcemaps"
  ]
  command += sourcemaps

  command.push('--rewrite') if params[:rewrite]
  command.push('--no-rewrite') unless params[:rewrite]
  command.push('--strip-prefix').push(params[:strip_prefix]) if params[:strip_prefix]
  command.push('--strip-common-prefix') if params[:strip_common_prefix]
  command.push('--url-prefix').push(params[:url_prefix]) unless params[:url_prefix].nil?
  command.push('--dist').push(params[:dist]) unless params[:dist].nil?

  unless params[:ignore].nil?
    # normalize to array
    unless params[:ignore].kind_of?(Enumerable)
      params[:ignore] = [params[:ignore]]
    end
    # no nil or empty strings
    params[:ignore].reject! do |e|
      e.strip.empty?
    rescue StandardError
      true
    end
    command.push('--ignore').push(*params[:ignore]) if params[:ignore].any?
  end

  command.push('--ignore-file').push(params[:ignore_file]) unless params[:ignore_file].nil?

  Helper::SentryHelper.call_sentry_cli(params, command)
  UI.success("Successfully uploaded files to release: #{version}")
end