fastlane-plugin-emerge 0.1.3 → 0.3.2

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: 0f542abe602fdc9595e71d1b8a4b8e8bf9bee55a54331a51c33e8636fd1eef71
4
- data.tar.gz: 10a41705f7a6d28043adb141731da2b7a9ec4a6da1bc45923a07fcbb4f7c7ac5
3
+ metadata.gz: 5991226e9529aa61b445bc73aef532f57a26e950b9320b0159d7067901673a9c
4
+ data.tar.gz: cb8ecbb578d8e5a03039656e462843df2f09d032e3380bf799343b66f219adbc
5
5
  SHA512:
6
- metadata.gz: 0e0f04590f3dc09a384e5368f76beb7e4841e14996536d49bdd1730bf4c20bf8e9d852f308a2f93df51ef729a3f90561e91169868a64ef6648f0d00544434f57
7
- data.tar.gz: f98a707293e57a51b5a85bef78cbfa737320e4d1fb051f1bac04014225ebea807e8bad5cf2018e6f30b8e89805e6a71663dd18807d860a5f8c771d3479ff4aa0
6
+ metadata.gz: b67186ed2de48af52dc3a5c3b9607d18c8c5554de8fede7177dba78e325b4d960d4c01e7a8f20e308d4170d93b5db8583404467f5c2fa80af1e1a4a8f37f915f
7
+ data.tar.gz: ed497c0b96d56e20814c3ea220b96b4a0f80e8794c9d6c4c81afc18966ac93b7338c10a363b28e3cbafff1dd6b3257dac3b957903bbd6de9cce339eae00acc8f
@@ -1,19 +1,58 @@
1
1
  require 'fastlane/action'
2
2
  require 'fastlane_core/print_table'
3
3
  require_relative '../helper/emerge_helper'
4
+ require 'pathname'
5
+ require 'tmpdir'
6
+ require 'fileutils'
4
7
 
5
8
  module Fastlane
6
9
  module Actions
7
10
  class EmergeAction < Action
8
11
  def self.run(params)
9
12
  api_token = params[:api_token]
10
- 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
11
18
  pr_number = params[:pr_number]
12
19
  build_id = params[:build_id]
13
20
  base_build_id = params[:base_build_id]
14
21
  repo_name = params[:repo_name]
22
+ gitlab_project_id = params[:gitlab_project_id]
15
23
  build_type = params[:build_type]
16
- if !File.exist?(file_path) || !File.extname(file_path) == '.zip'
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'
17
56
  UI.error("Invalid input file")
18
57
  return
19
58
  end
@@ -35,6 +74,9 @@ module Fastlane
35
74
  if repo_name
36
75
  params[:repoName] = repo_name
37
76
  end
77
+ if gitlab_project_id
78
+ params[:gitlabProjectId] = gitlab_project_id
79
+ end
38
80
  params[:buildType] = build_type || "development"
39
81
  FastlaneCore::PrintTable.print_values(
40
82
  config: params,
@@ -58,6 +100,13 @@ module Fastlane
58
100
  end
59
101
  end
60
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
+
61
110
  def self.description
62
111
  "Fastlane plugin for Emerge"
63
112
  end
@@ -85,7 +134,7 @@ module Fastlane
85
134
  FastlaneCore::ConfigItem.new(key: :file_path,
86
135
  env_name: "EMERGE_FILE_PATH",
87
136
  description: "Path to the zipped xcarchive or app to upload",
88
- optional: false,
137
+ optional: true,
89
138
  type: String),
90
139
  FastlaneCore::ConfigItem.new(key: :pr_number,
91
140
  description: "The PR number that triggered this upload",
@@ -103,6 +152,10 @@ module Fastlane
103
152
  description: "Full name of the respository this upload was triggered from. For example: EmergeTools/Emerge",
104
153
  optional: true,
105
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),
106
159
  FastlaneCore::ConfigItem.new(key: :build_type,
107
160
  description: "Type of build, either release or development. Defaults to development",
108
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Emerge
3
- VERSION = "0.1.3"
3
+ VERSION = "0.3.2"
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.1.3
4
+ version: 0.3.2
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-03-27 00:00:00.000000000 Z
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.0
19
+ version: '1.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.0
26
+ version: '1.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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