fastlane-plugin-emerge 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/emerge/actions/emerge_action.rb +84 -75
- data/lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb +30 -30
- data/lib/fastlane/plugin/emerge/helper/emerge_helper.rb +38 -2
- data/lib/fastlane/plugin/emerge/helper/git.rb +66 -0
- data/lib/fastlane/plugin/emerge/helper/github.rb +77 -0
- data/lib/fastlane/plugin/emerge/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e170856bceb03b9747e72d074ce9a96d124dfe6519e5bc9f47becffb39b1acea
|
4
|
+
data.tar.gz: 71d34166a5fa640ac3af5ec2763a8b373052e3da358c0dc68dce5ed4bb46bd32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '07929884d01b7ce42b2863dc9973768b2bb033da495e6d63c6dd09a66e63d6613e55c41a0845eff819afcd8689897d5c32c6099028e0059e2f12df9aed1470af'
|
7
|
+
data.tar.gz: a971a076cb1724adec271841883b49a0ecfac4fe245884076b64cc655f1fabf930af60830f76cf7dbd46005d6e28c5a16d01d716a6ae63133df8a7cf6a013f56
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'fastlane/action'
|
2
2
|
require 'fastlane_core/print_table'
|
3
3
|
require_relative '../helper/emerge_helper'
|
4
|
+
require_relative '../helper/git'
|
5
|
+
require_relative '../helper/github'
|
4
6
|
require 'pathname'
|
5
7
|
require 'tmpdir'
|
6
8
|
require 'json'
|
@@ -13,20 +15,21 @@ module Fastlane
|
|
13
15
|
api_token = params[:api_token]
|
14
16
|
file_path = params[:file_path] || lane_context[SharedValues::XCODEBUILD_ARCHIVE]
|
15
17
|
|
16
|
-
if file_path
|
18
|
+
if file_path.nil?
|
17
19
|
file_path = Dir.glob("#{lane_context[SharedValues::SCAN_DERIVED_DATA_PATH]}/Build/Products/Debug-iphonesimulator/*.app").first
|
18
20
|
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
git_params = Helper::EmergeHelper.make_git_params
|
22
|
+
pr_number = params[:pr_number] || git_params.pr_number
|
23
|
+
branch = params[:branch] || git_params.branch
|
24
|
+
sha = params[:sha] || params[:build_id] || git_params.sha
|
25
|
+
base_sha = params[:base_sha] || params[:base_build_id] || git_params.base_sha
|
26
|
+
repo_name = params[:repo_name] || git_params.repo_name
|
24
27
|
gitlab_project_id = params[:gitlab_project_id]
|
25
|
-
|
28
|
+
tag = params[:tag]
|
26
29
|
order_file_version = params[:order_file_version]
|
27
30
|
config_path = params[:config_path]
|
28
31
|
|
29
|
-
if file_path
|
32
|
+
if file_path.nil? || !File.exist?(file_path)
|
30
33
|
UI.error("Invalid input file")
|
31
34
|
return
|
32
35
|
end
|
@@ -38,8 +41,8 @@ module Fastlane
|
|
38
41
|
Dir.mktmpdir do |d|
|
39
42
|
application_folder = "#{d}/archive.xcarchive/Products/Applications/"
|
40
43
|
dsym_folder = "#{d}/archive.xcarchive/dSYMs/"
|
41
|
-
FileUtils.mkdir_p
|
42
|
-
FileUtils.mkdir_p
|
44
|
+
FileUtils.mkdir_p(application_folder)
|
45
|
+
FileUtils.mkdir_p(dsym_folder)
|
43
46
|
if params[:linkmaps] && params[:linkmaps].length > 0
|
44
47
|
linkmap_folder = "#{d}/archive.xcarchive/Linkmaps/"
|
45
48
|
FileUtils.mkdir_p(linkmap_folder)
|
@@ -51,13 +54,14 @@ module Fastlane
|
|
51
54
|
FileUtils.cp_r(file_path, application_folder)
|
52
55
|
copy_dsyms("#{absolute_path.dirname}/*.dsym", dsym_folder)
|
53
56
|
copy_dsyms("#{absolute_path.dirname}/*/*.dsym", dsym_folder)
|
54
|
-
Xcodeproj::Plist.write_to_path({"NAME" => "Emerge Upload"}, "#{d}/archive.xcarchive/Info.plist")
|
57
|
+
Xcodeproj::Plist.write_to_path({ "NAME" => "Emerge Upload" }, "#{d}/archive.xcarchive/Info.plist")
|
55
58
|
file_path = "#{absolute_path.dirname}/archive.xcarchive.zip"
|
56
59
|
ZipAction.run(
|
57
60
|
path: "#{d}/archive.xcarchive",
|
58
61
|
output_path: file_path,
|
59
62
|
exclude: [],
|
60
|
-
include: []
|
63
|
+
include: []
|
64
|
+
)
|
61
65
|
UI.message("Archive generated at #{file_path}")
|
62
66
|
end
|
63
67
|
elsif File.extname(file_path) == '.xcarchive'
|
@@ -74,11 +78,12 @@ module Fastlane
|
|
74
78
|
path: file_path,
|
75
79
|
output_path: zip_path,
|
76
80
|
exclude: [],
|
77
|
-
include: []
|
81
|
+
include: []
|
82
|
+
)
|
78
83
|
file_path = zip_path
|
79
84
|
elsif File.extname(file_path) == '.zip' && params[:linkmaps] && params[:linkmaps].length > 0
|
80
85
|
UI.error("Provided zipped archive and linkmaps, linkmaps will not be added to zip.")
|
81
|
-
elsif
|
86
|
+
elsif File.extname(file_path) != '.zip'
|
82
87
|
UI.error("Invalid input file")
|
83
88
|
return
|
84
89
|
end
|
@@ -86,7 +91,7 @@ module Fastlane
|
|
86
91
|
filename = File.basename(file_path)
|
87
92
|
url = 'https://api.emergetools.com/upload'
|
88
93
|
params = {
|
89
|
-
filename: filename
|
94
|
+
filename: filename
|
90
95
|
}
|
91
96
|
if pr_number
|
92
97
|
params[:prNumber] = pr_number
|
@@ -109,24 +114,33 @@ module Fastlane
|
|
109
114
|
if order_file_version
|
110
115
|
params[:orderFileVersion] = order_file_version
|
111
116
|
end
|
112
|
-
params[:
|
117
|
+
params[:tag] = tag || "default"
|
113
118
|
FastlaneCore::PrintTable.print_values(
|
114
119
|
config: params,
|
115
120
|
hide_keys: [],
|
116
|
-
title: "Summary for Emerge #{Fastlane::Emerge::VERSION}"
|
117
|
-
|
121
|
+
title: "Summary for Emerge #{Fastlane::Emerge::VERSION}"
|
122
|
+
)
|
123
|
+
resp = Faraday.post(
|
124
|
+
url,
|
125
|
+
params.to_json,
|
126
|
+
'Content-Type' => 'application/json', 'X-API-Token' => api_token, 'User-Agent' => "fastlane-plugin-emerge/#{Fastlane::Emerge::VERSION}"
|
127
|
+
)
|
118
128
|
case resp.status
|
119
129
|
when 200
|
120
130
|
json = JSON.parse(resp.body)
|
121
131
|
upload_id = json["upload_id"]
|
122
132
|
upload_url = json["uploadURL"]
|
123
|
-
|
133
|
+
warning = json["warning"]
|
134
|
+
if warning
|
135
|
+
UI.important(warning)
|
136
|
+
end
|
137
|
+
return Helper::EmergeHelper.perform_upload(upload_url, upload_id, file_path)
|
124
138
|
when 403
|
125
139
|
UI.error("Invalid API token")
|
126
140
|
when 400
|
127
141
|
UI.error("Invalid parameters")
|
128
142
|
json = JSON.parse(resp.body)
|
129
|
-
UI.error("Error: #{json[
|
143
|
+
UI.error("Error: #{json['errorMessage']}")
|
130
144
|
else
|
131
145
|
UI.error("Upload failed")
|
132
146
|
end
|
@@ -140,10 +154,10 @@ module Fastlane
|
|
140
154
|
end
|
141
155
|
|
142
156
|
def self.copy_config(config_path, tmp_dir)
|
143
|
-
return
|
157
|
+
return if config_path.nil?
|
144
158
|
|
145
159
|
expanded_path = File.expand_path(config_path)
|
146
|
-
|
160
|
+
unless File.exist?(expanded_path)
|
147
161
|
UI.error("No config file found at path '#{expanded_path}'.\nUploading without config file")
|
148
162
|
return
|
149
163
|
end
|
@@ -161,84 +175,79 @@ module Fastlane
|
|
161
175
|
end
|
162
176
|
|
163
177
|
def self.return_value
|
164
|
-
|
178
|
+
"If successful, returns the upload id of the generated build"
|
165
179
|
end
|
166
180
|
|
167
181
|
def self.details
|
168
|
-
# Optional:
|
169
182
|
""
|
170
183
|
end
|
171
184
|
|
172
185
|
def self.available_options
|
173
186
|
[
|
174
187
|
FastlaneCore::ConfigItem.new(key: :api_token,
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
188
|
+
env_name: "EMERGE_API_TOKEN",
|
189
|
+
description: "An API token for Emerge",
|
190
|
+
optional: false,
|
191
|
+
type: String),
|
179
192
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
193
|
+
env_name: "EMERGE_FILE_PATH",
|
194
|
+
description: "Path to the zipped xcarchive or app to upload",
|
195
|
+
optional: true,
|
196
|
+
type: String),
|
184
197
|
FastlaneCore::ConfigItem.new(key: :linkmaps,
|
185
|
-
|
186
|
-
|
187
|
-
|
198
|
+
description: "List of paths to linkmaps",
|
199
|
+
optional: true,
|
200
|
+
type: Array),
|
188
201
|
FastlaneCore::ConfigItem.new(key: :pr_number,
|
189
|
-
|
190
|
-
|
191
|
-
|
202
|
+
description: "The PR number that triggered this upload",
|
203
|
+
optional: true,
|
204
|
+
type: String),
|
192
205
|
FastlaneCore::ConfigItem.new(key: :branch,
|
193
|
-
|
194
|
-
|
195
|
-
|
206
|
+
description: "The current git branch",
|
207
|
+
optional: true,
|
208
|
+
type: String),
|
196
209
|
FastlaneCore::ConfigItem.new(key: :sha,
|
197
|
-
|
198
|
-
|
199
|
-
|
210
|
+
description: "The git SHA that triggered this build",
|
211
|
+
optional: true,
|
212
|
+
type: String),
|
200
213
|
FastlaneCore::ConfigItem.new(key: :base_sha,
|
201
|
-
|
202
|
-
|
203
|
-
|
214
|
+
description: "The git SHA of the base build",
|
215
|
+
optional: true,
|
216
|
+
type: String),
|
204
217
|
FastlaneCore::ConfigItem.new(key: :build_id,
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
218
|
+
description: "A string to identify this build",
|
219
|
+
deprecated: "Replaced by `sha`",
|
220
|
+
optional: true,
|
221
|
+
type: String),
|
209
222
|
FastlaneCore::ConfigItem.new(key: :base_build_id,
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
223
|
+
description: "Id of the build to compare with this upload",
|
224
|
+
deprecated: "Replaced by `base_sha`",
|
225
|
+
optional: true,
|
226
|
+
type: String),
|
214
227
|
FastlaneCore::ConfigItem.new(key: :repo_name,
|
215
|
-
|
216
|
-
|
217
|
-
|
228
|
+
description: "Full name of the respository this upload was triggered from. For example: EmergeTools/Emerge",
|
229
|
+
optional: true,
|
230
|
+
type: String),
|
218
231
|
FastlaneCore::ConfigItem.new(key: :gitlab_project_id,
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
FastlaneCore::ConfigItem.new(key: :
|
223
|
-
|
224
|
-
|
225
|
-
|
232
|
+
description: "Id of the gitlab project this upload was triggered from",
|
233
|
+
optional: true,
|
234
|
+
type: Integer),
|
235
|
+
FastlaneCore::ConfigItem.new(key: :tag,
|
236
|
+
description: "String to label the build. Useful for grouping builds together in our dashboard, like development, default, or pull-request",
|
237
|
+
optional: true,
|
238
|
+
type: String),
|
226
239
|
FastlaneCore::ConfigItem.new(key: :order_file_version,
|
227
|
-
|
228
|
-
|
229
|
-
|
240
|
+
description: "Version of the order file to download",
|
241
|
+
optional: true,
|
242
|
+
type: String),
|
230
243
|
FastlaneCore::ConfigItem.new(key: :config_path,
|
231
|
-
|
232
|
-
|
233
|
-
|
244
|
+
description: "Path to Emerge config path",
|
245
|
+
optional: true,
|
246
|
+
type: String)
|
234
247
|
]
|
235
248
|
end
|
236
249
|
|
237
250
|
def self.is_supported?(platform)
|
238
|
-
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
239
|
-
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
240
|
-
#
|
241
|
-
# [:ios, :mac, :android].include?(platform)
|
242
251
|
platform == :ios
|
243
252
|
end
|
244
253
|
end
|
@@ -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
|
-
|
15
|
+
|
16
|
+
request_params = {
|
17
17
|
buildId: params[:build_id],
|
18
18
|
baseBuildId: params[:base_build_id]
|
19
19
|
}
|
20
|
-
resp = Faraday.get(url,
|
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
|
-
|
27
|
-
case
|
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 #{
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
59
|
+
description: "The PR number that triggered this upload",
|
60
|
+
optional: false,
|
61
|
+
type: String),
|
62
62
|
FastlaneCore::ConfigItem.new(key: :build_id,
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
description: "A string to identify this build",
|
64
|
+
optional: false,
|
65
|
+
type: String),
|
66
66
|
FastlaneCore::ConfigItem.new(key: :base_build_id,
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
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
|
@@ -4,21 +4,57 @@ require 'faraday'
|
|
4
4
|
module Fastlane
|
5
5
|
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
6
6
|
|
7
|
+
class GitResult
|
8
|
+
attr_accessor :sha, :base_sha, :branch, :pr_number, :repo_name
|
9
|
+
|
10
|
+
def initialize(sha:, base_sha:, branch:, pr_number: nil, repo_name: nil)
|
11
|
+
@pr_number = pr_number
|
12
|
+
@sha = sha
|
13
|
+
@base_sha = base_sha
|
14
|
+
@branch = branch
|
15
|
+
@repo_name = repo_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
7
19
|
module Helper
|
8
20
|
class EmergeHelper
|
9
21
|
def self.perform_upload(upload_url, upload_id, file_path)
|
10
22
|
UI.message("Starting upload")
|
11
23
|
response = Faraday.put(upload_url) do |req|
|
12
24
|
req.headers['Content-Type'] = 'application/zip'
|
13
|
-
req.headers['Content-Length'] =
|
25
|
+
req.headers['Content-Length'] = File.size(file_path).to_s
|
14
26
|
req.body = Faraday::UploadIO.new(file_path, 'application/zip')
|
15
27
|
end
|
16
28
|
case response.status
|
17
29
|
when 200
|
18
|
-
UI.success("Your app is processing, you can find the results at https://emergetools.com/build/#{upload_id}")
|
30
|
+
UI.success("🎉 Your app is processing, you can find the results at https://emergetools.com/build/#{upload_id}")
|
31
|
+
return upload_id
|
19
32
|
else
|
20
33
|
UI.error("Upload failed")
|
21
34
|
end
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.make_git_params
|
39
|
+
git_result = if Helper::Github.is_supported_github_event?
|
40
|
+
UI.message("Fetching Git info from Github event")
|
41
|
+
GitResult.new(
|
42
|
+
sha: Helper::Github.sha,
|
43
|
+
base_sha: Helper::Github.base_sha,
|
44
|
+
branch: Helper::Github.branch,
|
45
|
+
pr_number: Helper::Github.pr_number,
|
46
|
+
repo_name: Helper::Github.repo_name
|
47
|
+
)
|
48
|
+
else
|
49
|
+
UI.message("Fetching Git info from system Git")
|
50
|
+
GitResult.new(
|
51
|
+
sha: Helper::Git.sha,
|
52
|
+
base_sha: Helper::Git.base_sha,
|
53
|
+
branch: Helper::Git.branch
|
54
|
+
)
|
55
|
+
end
|
56
|
+
UI.message("Got git result #{git_result.inspect}")
|
57
|
+
git_result
|
22
58
|
end
|
23
59
|
end
|
24
60
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'fastlane_core/print_table'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Helper
|
6
|
+
module Git
|
7
|
+
def self.branch
|
8
|
+
shell_command = "git rev-parse --abbrev-ref HEAD"
|
9
|
+
UI.command(shell_command)
|
10
|
+
stdout, _, status = Open3.capture3(shell_command)
|
11
|
+
stdout.strip if status.success?
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.sha
|
15
|
+
shell_command = "git rev-parse HEAD"
|
16
|
+
UI.command(shell_command)
|
17
|
+
stdout, _, status = Open3.capture3(shell_command)
|
18
|
+
stdout.strip if status.success?
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.base_sha
|
22
|
+
shell_command = "git merge-base #{remote_head_branch} #{branch}"
|
23
|
+
UI.command(shell_command)
|
24
|
+
stdout, _, status = Open3.capture3(shell_command)
|
25
|
+
return nil if stdout.strip.empty? || !status.success?
|
26
|
+
current_sha = sha
|
27
|
+
stdout.strip == current_sha ? nil : stdout.strip
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.primary_remote
|
31
|
+
remote = remote()
|
32
|
+
return nil if remote.nil?
|
33
|
+
remote.include?("origin") ? "origin" : remote.first
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.remote_head_branch(remote = primary_remote)
|
37
|
+
return nil if remote.nil?
|
38
|
+
shell_command = "git remote show #{remote}"
|
39
|
+
UI.command(shell_command)
|
40
|
+
stdout, _, status = Open3.capture3(shell_command)
|
41
|
+
return nil if stdout.nil? || !status.success?
|
42
|
+
stdout
|
43
|
+
.split("\n")
|
44
|
+
.map(&:strip)
|
45
|
+
.find { |line| line.start_with?("HEAD branch: ") }
|
46
|
+
&.split(' ')
|
47
|
+
&.last
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.remote_url(remote = primary_remote)
|
51
|
+
return nil if remote.nil?
|
52
|
+
shell_command = "git config --get remote.#{remote}.url"
|
53
|
+
UI.command(shell_command)
|
54
|
+
stdout, _, status = Open3.capture3(shell_command)
|
55
|
+
stdout if status.success?
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.remote
|
59
|
+
shell_command = "git remote"
|
60
|
+
UI.command(shell_command)
|
61
|
+
stdout, _, status = Open3.capture3(shell_command)
|
62
|
+
stdout.split("\n") if status.success?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'fastlane_core/print_table'
|
3
|
+
require_relative 'git'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Helper
|
7
|
+
module Github
|
8
|
+
GITHUB_EVENT_PR = "pull_request".freeze
|
9
|
+
GITHUB_EVENT_PUSH = "push".freeze
|
10
|
+
|
11
|
+
def self.event_name
|
12
|
+
ENV['GITHUB_EVENT_NAME']
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.is_supported_github_event?
|
16
|
+
UI.message("GitHub event name: #{event_name}")
|
17
|
+
is_pull_request? || is_push?
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.is_pull_request?
|
21
|
+
event_name == GITHUB_EVENT_PR
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.is_push?
|
25
|
+
event_name == GITHUB_EVENT_PUSH
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.sha
|
29
|
+
if is_push?
|
30
|
+
ENV['GITHUB_SHA']
|
31
|
+
elsif is_pull_request?
|
32
|
+
github_event_data.dig(:pull_request, :head, :sha)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.base_sha
|
37
|
+
if is_pull_request?
|
38
|
+
github_event_data.dig(:pull_request, :base, :sha)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.pr_number
|
43
|
+
is_pull_request? ? github_event_data.dig(:number) : nil
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.branch
|
47
|
+
is_pull_request? ? github_event_data.dig(:pull_request, :head, :ref) : Git.branch
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.repo_owner
|
51
|
+
github_event_data.dig(:repository, :owner, :login)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.repo_name
|
55
|
+
github_event_data.dig(:repository, :full_name)
|
56
|
+
end
|
57
|
+
|
58
|
+
private_class_method
|
59
|
+
|
60
|
+
def self.github_event_data
|
61
|
+
github_event_path = ENV['GITHUB_EVENT_PATH']
|
62
|
+
UI.error!("GITHUB_EVENT_PATH is not set") if github_event_path.nil?
|
63
|
+
|
64
|
+
unless File.exist?(github_event_path)
|
65
|
+
UI.error!("File #{github_event_path} doesn't exist")
|
66
|
+
end
|
67
|
+
|
68
|
+
file_content = File.read(github_event_path)
|
69
|
+
file_json = JSON.parse(file_content, symbolize_names: true)
|
70
|
+
if ENV['DEBUG']
|
71
|
+
UI.message("Parsed GitHub event data: #{file_json.inspect}")
|
72
|
+
end
|
73
|
+
file_json
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
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.
|
4
|
+
version: 0.8.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:
|
11
|
+
date: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -163,6 +163,8 @@ files:
|
|
163
163
|
- lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb
|
164
164
|
- lib/fastlane/plugin/emerge/actions/emerge_order_file_action.rb
|
165
165
|
- lib/fastlane/plugin/emerge/helper/emerge_helper.rb
|
166
|
+
- lib/fastlane/plugin/emerge/helper/git.rb
|
167
|
+
- lib/fastlane/plugin/emerge/helper/github.rb
|
166
168
|
- lib/fastlane/plugin/emerge/version.rb
|
167
169
|
homepage: https://github.com/EmergeTools/fastlane-plugin-emerge
|
168
170
|
licenses:
|