fastlane-plugin-emerge 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f84892f800a40e25a4b867e178edb8619c24864a4b9ff9670470270ea227969c
4
- data.tar.gz: b8749428f0e193bf816b8dae1dc9e3f10ace668eb86ab3e1e6992d61438995cc
3
+ metadata.gz: d4d089c7870b5c71f07b01d99df92996471d9050ab6fd4b0f6c3290648dcd404
4
+ data.tar.gz: a98f1c7796d0e21d0a2d7dcbadc20e11d3e2de626e1441da4947610e8433d468
5
5
  SHA512:
6
- metadata.gz: 93d799a5679ba33a333028db9f30217da3742ca2af4cc24c4c792a1c3c06122ee3bc2f79c79ff0f5f2306513a079ab280f586204618deeb5a50fa6953eae363b
7
- data.tar.gz: 86718d6dc29e96ce1fbe78d6198dfcb5dde0fcdadadd63d6f87d1040672fa3d8f73c4171f059615afca40536a217b2f2b283f6cb8262aa68be07f73071538775
6
+ metadata.gz: 7afe4c7adc02c46fa4193dbed344afc716877d26ca00849f6dce44bdd73e7da8458221aa875e9b9290aeec36c2e08fa2036e71d08581af4de74cb848779fdffe
7
+ data.tar.gz: 3fb17574090d31c7088b5afb3e0f9161e627ba777de779887b7d34ee45ea6094d3439bde09851087035d3c2face7be1caf173fb5228e5b81496f412b80d27aa0
@@ -13,7 +13,7 @@ module Fastlane
13
13
  api_token = params[:api_token]
14
14
  file_path = params[:file_path] || lane_context[SharedValues::XCODEBUILD_ARCHIVE]
15
15
 
16
- if file_path == nil
16
+ if file_path.nil?
17
17
  file_path = Dir.glob("#{lane_context[SharedValues::SCAN_DERIVED_DATA_PATH]}/Build/Products/Debug-iphonesimulator/*.app").first
18
18
  end
19
19
  pr_number = params[:pr_number]
@@ -22,11 +22,11 @@ module Fastlane
22
22
  base_sha = params[:base_sha] || params[:base_build_id]
23
23
  repo_name = params[:repo_name]
24
24
  gitlab_project_id = params[:gitlab_project_id]
25
- build_type = params[:build_type]
25
+ tag = params[:tag]
26
26
  order_file_version = params[:order_file_version]
27
27
  config_path = params[:config_path]
28
28
 
29
- if file_path == nil || !File.exist?(file_path)
29
+ if file_path.nil? || !File.exist?(file_path)
30
30
  UI.error("Invalid input file")
31
31
  return
32
32
  end
@@ -38,8 +38,8 @@ module Fastlane
38
38
  Dir.mktmpdir do |d|
39
39
  application_folder = "#{d}/archive.xcarchive/Products/Applications/"
40
40
  dsym_folder = "#{d}/archive.xcarchive/dSYMs/"
41
- FileUtils.mkdir_p application_folder
42
- FileUtils.mkdir_p dsym_folder
41
+ FileUtils.mkdir_p(application_folder)
42
+ FileUtils.mkdir_p(dsym_folder)
43
43
  if params[:linkmaps] && params[:linkmaps].length > 0
44
44
  linkmap_folder = "#{d}/archive.xcarchive/Linkmaps/"
45
45
  FileUtils.mkdir_p(linkmap_folder)
@@ -51,13 +51,14 @@ module Fastlane
51
51
  FileUtils.cp_r(file_path, application_folder)
52
52
  copy_dsyms("#{absolute_path.dirname}/*.dsym", dsym_folder)
53
53
  copy_dsyms("#{absolute_path.dirname}/*/*.dsym", dsym_folder)
54
- Xcodeproj::Plist.write_to_path({"NAME" => "Emerge Upload"}, "#{d}/archive.xcarchive/Info.plist")
54
+ Xcodeproj::Plist.write_to_path({ "NAME" => "Emerge Upload" }, "#{d}/archive.xcarchive/Info.plist")
55
55
  file_path = "#{absolute_path.dirname}/archive.xcarchive.zip"
56
56
  ZipAction.run(
57
57
  path: "#{d}/archive.xcarchive",
58
58
  output_path: file_path,
59
59
  exclude: [],
60
- include: [])
60
+ include: []
61
+ )
61
62
  UI.message("Archive generated at #{file_path}")
62
63
  end
63
64
  elsif File.extname(file_path) == '.xcarchive'
@@ -74,11 +75,12 @@ module Fastlane
74
75
  path: file_path,
75
76
  output_path: zip_path,
76
77
  exclude: [],
77
- include: [])
78
+ include: []
79
+ )
78
80
  file_path = zip_path
79
81
  elsif File.extname(file_path) == '.zip' && params[:linkmaps] && params[:linkmaps].length > 0
80
82
  UI.error("Provided zipped archive and linkmaps, linkmaps will not be added to zip.")
81
- elsif !File.extname(file_path) == '.zip'
83
+ elsif File.extname(file_path) != '.zip'
82
84
  UI.error("Invalid input file")
83
85
  return
84
86
  end
@@ -86,7 +88,7 @@ module Fastlane
86
88
  filename = File.basename(file_path)
87
89
  url = 'https://api.emergetools.com/upload'
88
90
  params = {
89
- filename: filename,
91
+ filename: filename
90
92
  }
91
93
  if pr_number
92
94
  params[:prNumber] = pr_number
@@ -109,24 +111,33 @@ module Fastlane
109
111
  if order_file_version
110
112
  params[:orderFileVersion] = order_file_version
111
113
  end
112
- params[:buildType] = build_type || "development"
114
+ params[:tag] = tag || "default"
113
115
  FastlaneCore::PrintTable.print_values(
114
116
  config: params,
115
117
  hide_keys: [],
116
- title: "Summary for Emerge #{Fastlane::Emerge::VERSION}")
117
- resp = Faraday.post(url, params.to_json, {'Content-Type' => 'application/json', 'X-API-Token' => api_token})
118
+ title: "Summary for Emerge #{Fastlane::Emerge::VERSION}"
119
+ )
120
+ resp = Faraday.post(
121
+ url,
122
+ params.to_json,
123
+ 'Content-Type' => 'application/json', 'X-API-Token' => api_token, 'User-Agent' => "fastlane-plugin-emerge/#{Fastlane::Emerge::VERSION}"
124
+ )
118
125
  case resp.status
119
126
  when 200
120
127
  json = JSON.parse(resp.body)
121
128
  upload_id = json["upload_id"]
122
129
  upload_url = json["uploadURL"]
123
- Helper::EmergeHelper.perform_upload(upload_url, upload_id, file_path)
130
+ warning = json["warning"]
131
+ if warning
132
+ UI.important(warning)
133
+ end
134
+ return Helper::EmergeHelper.perform_upload(upload_url, upload_id, file_path)
124
135
  when 403
125
136
  UI.error("Invalid API token")
126
137
  when 400
127
138
  UI.error("Invalid parameters")
128
139
  json = JSON.parse(resp.body)
129
- UI.error("Error: #{json["errorMessage"]}")
140
+ UI.error("Error: #{json['errorMessage']}")
130
141
  else
131
142
  UI.error("Upload failed")
132
143
  end
@@ -140,10 +151,16 @@ module Fastlane
140
151
  end
141
152
 
142
153
  def self.copy_config(config_path, tmp_dir)
143
- if config_path != nil && File.exist?(config_path)
144
- emerge_config_path = "#{tmp_dir}/emerge_config.yaml"
145
- FileUtils.cp(config_path, emerge_config_path)
154
+ return if config_path.nil?
155
+
156
+ expanded_path = File.expand_path(config_path)
157
+ unless File.exist?(expanded_path)
158
+ UI.error("No config file found at path '#{expanded_path}'.\nUploading without config file")
159
+ return
146
160
  end
161
+
162
+ emerge_config_path = "#{tmp_dir}/emerge_config.yaml"
163
+ FileUtils.cp(expanded_path, emerge_config_path)
147
164
  end
148
165
 
149
166
  def self.description
@@ -166,65 +183,65 @@ module Fastlane
166
183
  def self.available_options
167
184
  [
168
185
  FastlaneCore::ConfigItem.new(key: :api_token,
169
- env_name: "EMERGE_API_TOKEN",
170
- description: "An API token for Emerge",
171
- optional: false,
172
- type: String),
186
+ env_name: "EMERGE_API_TOKEN",
187
+ description: "An API token for Emerge",
188
+ optional: false,
189
+ type: String),
173
190
  FastlaneCore::ConfigItem.new(key: :file_path,
174
- env_name: "EMERGE_FILE_PATH",
175
- description: "Path to the zipped xcarchive or app to upload",
176
- optional: true,
177
- type: String),
191
+ env_name: "EMERGE_FILE_PATH",
192
+ description: "Path to the zipped xcarchive or app to upload",
193
+ optional: true,
194
+ type: String),
178
195
  FastlaneCore::ConfigItem.new(key: :linkmaps,
179
- description: "List of paths to linkmaps",
180
- optional: true,
181
- type: Array),
196
+ description: "List of paths to linkmaps",
197
+ optional: true,
198
+ type: Array),
182
199
  FastlaneCore::ConfigItem.new(key: :pr_number,
183
- description: "The PR number that triggered this upload",
184
- optional: true,
185
- type: String),
200
+ description: "The PR number that triggered this upload",
201
+ optional: true,
202
+ type: String),
186
203
  FastlaneCore::ConfigItem.new(key: :branch,
187
- description: "The current git branch",
188
- optional: true,
189
- type: String),
204
+ description: "The current git branch",
205
+ optional: true,
206
+ type: String),
190
207
  FastlaneCore::ConfigItem.new(key: :sha,
191
- description: "The git SHA that triggered this build",
192
- optional: true,
193
- type: String),
208
+ description: "The git SHA that triggered this build",
209
+ optional: true,
210
+ type: String),
194
211
  FastlaneCore::ConfigItem.new(key: :base_sha,
195
- description: "The git SHA of the base build",
196
- optional: true,
197
- type: String),
212
+ description: "The git SHA of the base build",
213
+ optional: true,
214
+ type: String),
198
215
  FastlaneCore::ConfigItem.new(key: :build_id,
199
- description: "A string to identify this build",
200
- deprecated: "Replaced by `sha`",
201
- optional: true,
202
- type: String),
216
+ description: "A string to identify this build",
217
+ deprecated: "Replaced by `sha`",
218
+ optional: true,
219
+ type: String),
203
220
  FastlaneCore::ConfigItem.new(key: :base_build_id,
204
- description: "Id of the build to compare with this upload",
205
- deprecated: "Replaced by `base_sha`",
206
- optional: true,
207
- type: String),
221
+ description: "Id of the build to compare with this upload",
222
+ deprecated: "Replaced by `base_sha`",
223
+ optional: true,
224
+ type: String),
208
225
  FastlaneCore::ConfigItem.new(key: :repo_name,
209
- description: "Full name of the respository this upload was triggered from. For example: EmergeTools/Emerge",
210
- optional: true,
211
- type: String),
226
+ description: "Full name of the respository this upload was triggered from. For example: EmergeTools/Emerge",
227
+ optional: true,
228
+ type: String),
212
229
  FastlaneCore::ConfigItem.new(key: :gitlab_project_id,
213
- description: "Id of the gitlab project this upload was triggered from",
214
- optional: true,
215
- type: Integer),
216
- FastlaneCore::ConfigItem.new(key: :build_type,
217
- description: "String to identify the type of build such as release/development. Used to filter size graphs. Defaults to development",
218
- optional: true,
219
- type: String),
230
+ description: "Id of the gitlab project this upload was triggered from",
231
+ optional: true,
232
+ type: Integer),
233
+ FastlaneCore::ConfigItem.new(key: :tag,
234
+ description: "String to label the build. Useful for grouping builds together in our dashboard, like development, default, or pull-request",
235
+ optional: true,
236
+ type: String),
220
237
  FastlaneCore::ConfigItem.new(key: :order_file_version,
221
- description: "Version of the order file to download",
222
- optional: true,
223
- type: String),
238
+ description: "Version of the order file to download",
239
+ optional: true,
240
+ type: String),
224
241
  FastlaneCore::ConfigItem.new(key: :config_path,
225
- description: "Path to Emerge config path",
226
- optional: true,
227
- type: String),
242
+ description: "Path to Emerge config path",
243
+ optional: true,
244
+ type: String)
228
245
  ]
229
246
  end
230
247
 
@@ -12,23 +12,23 @@ module Fastlane
12
12
  project_id = params[:gitlab_project_id]
13
13
  pr_number = params[:pr_number]
14
14
  gitlab_access_token = params[:gitlab_access_token]
15
-
16
- requestParams = {
15
+
16
+ request_params = {
17
17
  buildId: params[:build_id],
18
18
  baseBuildId: params[:base_build_id]
19
19
  }
20
- resp = Faraday.get(url, requestParams, {'x-api-token' => api_token})
20
+ resp = Faraday.get(url, request_params, 'x-api-token' => api_token)
21
21
  case resp.status
22
22
  when 200
23
23
  UI.message("Received comment from Emerge")
24
24
  baseURL = gitlab_url ? gitlab_url : "https://gitlab.com"
25
25
  url = "#{baseURL}/api/v4/projects/#{project_id}/merge_requests/#{pr_number}/notes"
26
- gitlabResponse = Faraday.post(url, {"body" => resp.body}, {'Authorization' => "Bearer #{gitlab_access_token}"})
27
- case gitlabResponse.status
26
+ gitlab_response = Faraday.post(url, { "body" => resp.body }, 'Authorization' => "Bearer #{gitlab_access_token}")
27
+ case gitlab_response.status
28
28
  when 200...299
29
29
  UI.message("Successfully posted comment")
30
30
  else
31
- UI.error("Received error #{gitlabResponse.status} from Gitlab")
31
+ UI.error("Received error #{gitlab_response.status} from Gitlab")
32
32
  end
33
33
  else
34
34
  UI.error("Received error #{resp.status} from Emerge")
@@ -46,35 +46,35 @@ module Fastlane
46
46
  def self.available_options
47
47
  [
48
48
  FastlaneCore::ConfigItem.new(key: :api_token,
49
- env_name: "EMERGE_API_TOKEN",
50
- description: "An API token for Emerge",
51
- optional: false,
52
- type: String),
49
+ env_name: "EMERGE_API_TOKEN",
50
+ description: "An API token for Emerge",
51
+ optional: false,
52
+ type: String),
53
53
  FastlaneCore::ConfigItem.new(key: :gitlab_acces_token,
54
- env_name: "GITLAB_ACCESS_TOKEN",
55
- description: "An access token for Gitlab",
56
- optional: false,
57
- type: String),
54
+ env_name: "GITLAB_ACCESS_TOKEN",
55
+ description: "An access token for Gitlab",
56
+ optional: false,
57
+ type: String),
58
58
  FastlaneCore::ConfigItem.new(key: :pr_number,
59
- description: "The PR number that triggered this upload",
60
- optional: false,
61
- type: String),
59
+ description: "The PR number that triggered this upload",
60
+ optional: false,
61
+ type: String),
62
62
  FastlaneCore::ConfigItem.new(key: :build_id,
63
- description: "A string to identify this build",
64
- optional: false,
65
- type: String),
63
+ description: "A string to identify this build",
64
+ optional: false,
65
+ type: String),
66
66
  FastlaneCore::ConfigItem.new(key: :base_build_id,
67
- description: "Id of the build to compare with this upload",
68
- optional: false,
69
- type: String),
67
+ description: "Id of the build to compare with this upload",
68
+ optional: false,
69
+ type: String),
70
70
  FastlaneCore::ConfigItem.new(key: :gitlab_url,
71
- description: "URL of the self hosted gitlab instance",
72
- optional: true,
73
- type: String),
71
+ description: "URL of the self hosted gitlab instance",
72
+ optional: true,
73
+ type: String),
74
74
  FastlaneCore::ConfigItem.new(key: :gitlab_project_id,
75
- description: "Id of the gitlab project this upload was triggered from",
76
- optional: false,
77
- type: Integer)
75
+ description: "Id of the gitlab project this upload was triggered from",
76
+ optional: false,
77
+ type: Integer)
78
78
  ]
79
79
  end
80
80
 
@@ -83,4 +83,4 @@ module Fastlane
83
83
  end
84
84
  end
85
85
  end
86
- end
86
+ end
@@ -16,9 +16,11 @@ module Fastlane
16
16
  case response.status
17
17
  when 200
18
18
  UI.success("Your app is processing, you can find the results at https://emergetools.com/build/#{upload_id}")
19
+ return upload_id
19
20
  else
20
21
  UI.error("Upload failed")
21
22
  end
23
+ return nil
22
24
  end
23
25
  end
24
26
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Emerge
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-emerge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emerge Tools, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-25 00:00:00.000000000 Z
11
+ date: 2024-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday