fastlane-plugin-emerge 0.1.2 → 0.3.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f8a9346a1287446245c5388083f6f4faf27082ae763b3387b80003b1210f34
|
4
|
+
data.tar.gz: 33f349c77e7c9b5a4eebec0501704db85d37c776f43d8bc6a94ed2d27a162248
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b692e0d3a5816a835aa904faa496b5114492850942f43ede61fa4f79b769e8446d119da5810b5c3e72aca9ae940353943f563cfc301a5528d6d3df5cbc887d61
|
7
|
+
data.tar.gz: f0132eb0d9c8f98186fc2fbcbb3b54a89bc8f16e69beb2365831b1e107bb167f555ab38cda70e4368262a7ce4ab77a9147a6a8596351f45d4363fe9e5763c5df
|
@@ -1,18 +1,58 @@
|
|
1
1
|
require 'fastlane/action'
|
2
|
+
require 'fastlane_core/print_table'
|
2
3
|
require_relative '../helper/emerge_helper'
|
4
|
+
require 'pathname'
|
5
|
+
require 'tmpdir'
|
6
|
+
require 'fileutils'
|
3
7
|
|
4
8
|
module Fastlane
|
5
9
|
module Actions
|
6
10
|
class EmergeAction < Action
|
7
11
|
def self.run(params)
|
8
12
|
api_token = params[:api_token]
|
9
|
-
file_path = params[:file_path]
|
13
|
+
file_path = params[:file_path] || lane_context[SharedValues::XCODEBUILD_ARCHIVE]
|
14
|
+
|
15
|
+
if file_path == nil
|
16
|
+
file_path = Dir.glob("#{lane_context[SharedValues::SCAN_DERIVED_DATA_PATH]}/Build/Products/Debug-iphonesimulator/*.app").first
|
17
|
+
end
|
10
18
|
pr_number = params[:pr_number]
|
11
19
|
build_id = params[:build_id]
|
12
20
|
base_build_id = params[:base_build_id]
|
13
21
|
repo_name = params[:repo_name]
|
22
|
+
gitlab_project_id = params[:gitlab_project_id]
|
14
23
|
build_type = params[:build_type]
|
15
|
-
|
24
|
+
|
25
|
+
if !File.exist?(file_path)
|
26
|
+
UI.error("Invalid input file")
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
# If the user provided a .app we will look for dsyms and package it into a zipped xcarchive
|
31
|
+
if File.extname(file_path) == '.app'
|
32
|
+
absolute_path = Pathname.new(File.expand_path(file_path))
|
33
|
+
UI.message("A .app was provided, dSYMs will be looked for in #{absolute_path.dirname}")
|
34
|
+
Dir.mktmpdir do |d|
|
35
|
+
application_folder = "#{d}/archive.xcarchive/Products/Applications/"
|
36
|
+
dsym_folder = "#{d}/archive.xcarchive/dSYMs/"
|
37
|
+
FileUtils.mkdir_p application_folder
|
38
|
+
FileUtils.mkdir_p dsym_folder
|
39
|
+
FileUtils.cp_r(file_path, application_folder)
|
40
|
+
copy_dsyms("#{absolute_path.dirname}/*.dsym", dsym_folder)
|
41
|
+
copy_dsyms("#{absolute_path.dirname}/*/*.dsym", dsym_folder)
|
42
|
+
Xcodeproj::Plist.write_to_path({"NAME" => "Emerge Upload"}, "#{d}/archive.xcarchive/Info.plist")
|
43
|
+
file_path = "#{absolute_path.dirname}/archive.xcarchive.zip"
|
44
|
+
ZipAction.run(
|
45
|
+
path: "#{d}/archive.xcarchive",
|
46
|
+
output_path: file_path)
|
47
|
+
UI.message("Archive generated at #{file_path}")
|
48
|
+
end
|
49
|
+
elsif File.extname(file_path) == '.xcarchive'
|
50
|
+
zip_path = file_path + ".zip"
|
51
|
+
Actions::ZipAction.run(
|
52
|
+
path: file_path,
|
53
|
+
output_path: zip_path)
|
54
|
+
file_path = zip_path
|
55
|
+
elsif !File.extname(file_path) == '.zip'
|
16
56
|
UI.error("Invalid input file")
|
17
57
|
return
|
18
58
|
end
|
@@ -34,7 +74,14 @@ module Fastlane
|
|
34
74
|
if repo_name
|
35
75
|
params[:repoName] = repo_name
|
36
76
|
end
|
77
|
+
if gitlab_project_id
|
78
|
+
params[:gitlabProjectId] = gitlab_project_id
|
79
|
+
end
|
37
80
|
params[:buildType] = build_type || "development"
|
81
|
+
FastlaneCore::PrintTable.print_values(
|
82
|
+
config: params,
|
83
|
+
hide_keys: [],
|
84
|
+
title: "Summary for Emerge #{Fastlane::Emerge::VERSION}")
|
38
85
|
resp = Faraday.get(url, params, {'X-API-Token' => api_token})
|
39
86
|
case resp.status
|
40
87
|
when 200
|
@@ -42,13 +89,24 @@ module Fastlane
|
|
42
89
|
upload_id = json["upload_id"]
|
43
90
|
upload_url = json["uploadURL"]
|
44
91
|
Helper::EmergeHelper.perform_upload(upload_url, upload_id, file_path)
|
45
|
-
when
|
92
|
+
when 403
|
46
93
|
UI.error("Invalid API token")
|
94
|
+
when 400
|
95
|
+
UI.error("Invalid parameters")
|
96
|
+
json = JSON.parse(resp.body)
|
97
|
+
UI.error("Error: #{json["errorMessage"]}")
|
47
98
|
else
|
48
99
|
UI.error("Upload failed")
|
49
100
|
end
|
50
101
|
end
|
51
102
|
|
103
|
+
def self.copy_dsyms(from, to)
|
104
|
+
Dir.glob(from) do |filename|
|
105
|
+
UI.message("Found dSYM: #{Pathname.new(filename).basename}")
|
106
|
+
FileUtils.cp_r(filename, to)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
52
110
|
def self.description
|
53
111
|
"Fastlane plugin for Emerge"
|
54
112
|
end
|
@@ -76,7 +134,7 @@ module Fastlane
|
|
76
134
|
FastlaneCore::ConfigItem.new(key: :file_path,
|
77
135
|
env_name: "EMERGE_FILE_PATH",
|
78
136
|
description: "Path to the zipped xcarchive or app to upload",
|
79
|
-
optional:
|
137
|
+
optional: true,
|
80
138
|
type: String),
|
81
139
|
FastlaneCore::ConfigItem.new(key: :pr_number,
|
82
140
|
description: "The PR number that triggered this upload",
|
@@ -94,6 +152,10 @@ module Fastlane
|
|
94
152
|
description: "Full name of the respository this upload was triggered from. For example: EmergeTools/Emerge",
|
95
153
|
optional: true,
|
96
154
|
type: String),
|
155
|
+
FastlaneCore::ConfigItem.new(key: :gitlab_project_id,
|
156
|
+
description: "Id of the gitlab project this upload was triggered from",
|
157
|
+
optional: true,
|
158
|
+
type: Integer),
|
97
159
|
FastlaneCore::ConfigItem.new(key: :build_type,
|
98
160
|
description: "Type of build, either release or development. Defaults to development",
|
99
161
|
optional: true,
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require 'fastlane_core/print_table'
|
3
|
+
require_relative '../helper/emerge_helper'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
class EmergeComment < Action
|
8
|
+
def self.run(params)
|
9
|
+
url = 'https://api.emergetools.com/getComment'
|
10
|
+
api_token = params[:api_token]
|
11
|
+
gitlab_url = params[:gitlab_url]
|
12
|
+
project_id = params[:gitlab_project_id]
|
13
|
+
pr_number = params[:pr_number]
|
14
|
+
gitlab_access_token = params[:gitlab_access_token]
|
15
|
+
|
16
|
+
requestParams = {
|
17
|
+
buildId: params[:build_id],
|
18
|
+
baseBuildId: params[:base_build_id]
|
19
|
+
}
|
20
|
+
resp = Faraday.get(url, requestParams, {'x-api-token' => api_token})
|
21
|
+
case resp.status
|
22
|
+
when 200
|
23
|
+
UI.message("Received comment from Emerge")
|
24
|
+
baseURL = gitlab_url ? gitlab_url : "https://gitlab.com"
|
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
|
28
|
+
when 200...299
|
29
|
+
UI.message("Successfully posted comment")
|
30
|
+
else
|
31
|
+
UI.error("Received error #{gitlabResponse.status} from Gitlab")
|
32
|
+
end
|
33
|
+
else
|
34
|
+
UI.error("Received error #{resp.status} from Emerge")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.description
|
39
|
+
"Post an Emerge PR comment, currently supports Gitlab only."
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.authors
|
43
|
+
["Emerge Tools"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.available_options
|
47
|
+
[
|
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),
|
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),
|
58
|
+
FastlaneCore::ConfigItem.new(key: :pr_number,
|
59
|
+
description: "The PR number that triggered this upload",
|
60
|
+
optional: false,
|
61
|
+
type: String),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :build_id,
|
63
|
+
description: "A string to identify this build",
|
64
|
+
optional: false,
|
65
|
+
type: String),
|
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),
|
70
|
+
FastlaneCore::ConfigItem.new(key: :gitlab_url,
|
71
|
+
description: "URL of the self hosted gitlab instance",
|
72
|
+
optional: true,
|
73
|
+
type: String),
|
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)
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.is_supported?(platform)
|
82
|
+
platform == :ios
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
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.1
|
4
|
+
version: 0.3.1
|
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: 2021-
|
11
|
+
date: 2021-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- README.md
|
161
161
|
- lib/fastlane/plugin/emerge.rb
|
162
162
|
- lib/fastlane/plugin/emerge/actions/emerge_action.rb
|
163
|
+
- lib/fastlane/plugin/emerge/actions/emerge_comment_action.rb
|
163
164
|
- lib/fastlane/plugin/emerge/helper/emerge_helper.rb
|
164
165
|
- lib/fastlane/plugin/emerge/version.rb
|
165
166
|
homepage: https://github.com/EmergeTools/fastlane-plugin-emerge
|