Class: Fastlane::Actions::UploadDsymAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane-ext/upload_dsym.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



139
140
141
# File 'lib/fastlane-ext/upload_dsym.rb', line 139

def self.authors
  ['https://github.com/sroik', 'https://github.com/elfenlaid']
end

.available_optionsObject



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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/fastlane-ext/upload_dsym.rb', line 59

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :kind,
                                 env_name: 'FL_UPLOAD_DSYM_KIND',
                                 description: "Origin of the dSYM ('beta', 'release', etc)",
                                 is_string: true,
                                 default_value: 'release',
                                 verify_block: proc do |value|
                                   UI.user_error!("No kind for UploadDsymAction given, pass using `kind: 'kind'`") unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :version,
                                 env_name: 'FL_UPLOAD_DSYM_VERSION',
                                 description: "Version of a constructed .ipa. (Build number '321', App version '1.2.3', etc.)",
                                 is_string: true,
                                 default_value: ENV['APP_RELEASE_BUILD_NUMBER'],
                                 verify_block: proc do |value|
                                   UI.user_error!("No version for UploadDsymAction given, pass using `version: 'version'`") unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :dSYM,
                                 env_name: 'FL_UPLOAD_DSYM_PATH',
                                 description: 'Archived dSYM files',
                                 is_string: true,
                                 default_value: ENV['DSYM_OUTPUT_PATH'] || Dir['*.dSYM.zip'].first,
                                 verify_block: proc do |value|
                                   UI.user_error!("Couldn't find dSYM file at path '#{value}'") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :region,
                                 env_name: 'FL_UPLOAD_DSYM_REGION',
                                 description: 'Region for S3 or Spaces',
                                 is_string: true,
                                 default_value: 'ams3',
                                 verify_block: proc do |value|
                                   UI.user_error!("No region for UploadDsymAction given, pass using `region: 'region'`") unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :endpoint,
                                 env_name: 'FL_UPLOAD_DSYM_ENDPOINT',
                                 description: 'Endpoint for S3 or Spaces',
                                 is_string: true,
                                 default_value: 'https://ams3.digitaloceanspaces.com',
                                 verify_block: proc do |value|
                                   UI.user_error!("No Endpoint for UploadDsymAction given, pass using `endpoint: 'endpoint'`") unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :access_key,
                                 env_name: 'FL_UPLOAD_DSYM_S3_ACCESS_KEY',
                                 description: 'Access Key for S3 or Spaces',
                                 is_string: true,
                                 verify_block: proc do |value|
                                   raise "No Access Key for UploadDsymAction given, pass using `access_key: 'access_key'`".red unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :secret_access_key,
                                 env_name: 'FL_UPLOAD_DSYM_S3_SECRET_ACCESS_KEY',
                                 description: 'Secret Access Key for S3 or Spaces',
                                 is_string: true,
                                 verify_block: proc do |value|
                                   raise "No Secret Access Key for UploadDsymAction given, pass using `secret_access_key: 'secret_access_key'`".red unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :bucket,
                                 env_name: 'FL_UPLOAD_DSYM_S3_BUCKET',
                                 description: 'Bucket for S3 or Spaces',
                                 is_string: true,
                                 default_value: 'default',
                                 verify_block: proc do |value|
                                   raise "No Bucket for UploadToS3Action given, pass using `bucket: 'bucket'`".red unless value && !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :space,
                                 env_name: 'FL_UPLOAD_DSYM_SPACE',
                                 description: 'Digital Ocean Space',
                                 is_string: true,
                                 default_value: 'project-dsym'),
    FastlaneCore::ConfigItem.new(key: :acl,
                                 env_name: 'FL_UPLOAD_DSYM_S3_ACL',
                                 description: 'Access level for the file',
                                 is_string: true,
                                 default_value: 'private',
                                 verify_block: proc do |value|
                                   raise "No Bucket for UploadToS3Action given, pass using `bucket: 'bucket'`".red unless value && !value.empty?
                                 end)
  ]
end

.descriptionObject



55
56
57
# File 'lib/fastlane-ext/upload_dsym.rb', line 55

def self.description
  'Upload dSYM archive to S3 or Spaces'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/fastlane-ext/upload_dsym.rb', line 143

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

.run(params) ⇒ Object



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
49
# File 'lib/fastlane-ext/upload_dsym.rb', line 6

def self.run(params)
  require 'aws-sdk-s3'

  kind = params[:kind]
  version = params[:version]
  dsym_path = params[:dSYM]
  dsym_name = File.basename(dsym_path, '.*')
  dsym_ext = File.extname(dsym_path)

  bucket = params[:space] || params[:bucket]
  acl = params[:acl]
  file_key = [dsym_name, kind, version].join('_') + dsym_ext
  file_path = params[:space] ? params[:bucket] + '/' + file_key : file_key

  client = Aws::S3::Client.new(
    access_key_id: params[:access_key],
    secret_access_key: params[:secret_access_key],
    endpoint: params[:endpoint],
    region: params[:region]
  )

  UI.message "Check whether destination bucket #{bucket} exists..💤"
  begin
    response = client.create_bucket(
      bucket: bucket,
      acl: acl
    )
    UI.message "Bucket #{bucket} created! ✨"
  rescue Aws::S3::Errors::BucketAlreadyExists
    UI.message "Bucket #{bucket} alredy exists 👌"
  end

  UI.message 'Going to upload dSYM..💤'
  File.open(dsym_path, 'r') do |body|
    response = client.put_object(
      acl: acl,
      bucket: bucket,
      key: file_path,
      body: body
    )

    UI.message "dSYM uploaded to #{file_path} ✨"
  end
end