fastlane-plugin-applivery 2.0.0 → 2.1.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
  SHA1:
3
- metadata.gz: c7f94a50ce21432b54c1100817072d934bbc53f2
4
- data.tar.gz: 801b81a79fc877bf8d2186d0c4cc501cd904ee46
3
+ metadata.gz: 9789cd976f727caacd42f7cb660a5d8cb2b74f5b
4
+ data.tar.gz: ec67e1d5065ab11f00bbd79efbe013b1a4de508f
5
5
  SHA512:
6
- metadata.gz: fbfd2f77db4858ec13e7630acf12ae3d55c546935e071abc9dbeae6e7431431898837c849e19e0f9028e87952b7399730f23df27b08e53338fe1d34e9273df80
7
- data.tar.gz: 775b30f9d0fdc5915ab14cf3ec4f0e1a28bcc4207505d283575d6b7a4146781f449f4c3894f317afe28ce381f1ccc85b36ea59006eafde7655b0a74c631192cc
6
+ metadata.gz: 24247b746914b30fbd908983639f11f06fa6c0e6ba0aba820be2082bb9a247d63c18fb2838f3ab9d9f4e264c71d284594fe965af5c9662d840698e07f2b96885
7
+ data.tar.gz: 7cb863833920e40e49eab5eed4f9527bd9e8b5d21533c033f2e778b11cd6f6a9313dae6b67d9cff8c06136344d7e2e5d31f5ecdc51a2cf106f446418afacb3f2
data/README.md CHANGED
@@ -37,8 +37,7 @@ lane :applivery_ios do
37
37
  scheme: "YOUR_APP_SCHEME", # Your App Scheme
38
38
  export_method: 'enterprise') # Choose between: enterprise or ad-hoc
39
39
  applivery(
40
- app_token: "YOUR_APP_TOKEN" # Your Applivery App Token
41
- )
40
+ app_token: "YOUR_APP_TOKEN") # Your Applivery App Token
42
41
  end
43
42
  ```
44
43
 
@@ -49,8 +48,7 @@ Next you'll find a `lane` with two steps: `gradle()` that will build the Android
49
48
  lane :applivery_android do
50
49
  gradle(task: "assembleRelease")
51
50
  applivery(
52
- appToken: "YOUR_APP_TOKEN" # Your Applivery App Token
53
- )
51
+ appToken: "YOUR_APP_TOKEN") # Your Applivery App Token
54
52
  end
55
53
  ```
56
54
 
@@ -70,6 +68,28 @@ The above examples are the most simple configuration you can have but you can ad
70
68
  | `tags` | Tags to identify the build | NO | string -> comma separated. i.e.: "RC1, QA" |
71
69
  | `build_path` | Build path to the APK / IPA file | NO | string -> by default it takes the IPA/APK build path |
72
70
 
71
+ ## Shared Value
72
+ Once your build is uploaded successfuly, the new generated build ID is provided by a Shared Value `APPLIVERY_BUILD_ID` that can be accesed in your lane with `lane_context[SharedValues::APPLIVERY_BUILD_ID]`
73
+
74
+ Example:
75
+
76
+ ```ruby
77
+ lane :applivery_ios do
78
+ gym(
79
+ scheme: "YOUR_APP_SCHEME", # Your App Scheme
80
+ export_method: 'enterprise') # Choose between: enterprise or ad-hoc
81
+ applivery(
82
+ app_token: "YOUR_APP_TOKEN" # Your Applivery App Token)
83
+ puts "BUILD ID: #{lane_context[SharedValues::APPLIVERY_BUILD_ID]}"
84
+ end
85
+ ```
86
+
87
+ You could use this id to open your build information in applivery like:
88
+
89
+ ```
90
+ https://dashboard.applivery.io/apps/apps/{YOUR_APP_SLUG}/builds?id={THIS_BUILD_ID}
91
+ ```
92
+
73
93
  ## Run tests for this plugin
74
94
 
75
95
  To run both the tests, and code style validation, run
@@ -1,31 +1,67 @@
1
+ require 'faraday'
2
+
1
3
  module Fastlane
2
4
  module Actions
5
+
6
+ module SharedValues
7
+ APPLIVERY_BUILD_ID = :APPLIVERY_BUILD_ID
8
+ end
9
+
3
10
  class AppliveryAction < Action
4
11
 
5
12
  def self.run(params)
6
- app_token = params[:app_token]
7
- name = params[:name]
8
- changelog = Helper::AppliveryHelper.escape(params[:changelog])
9
- notify_message = Helper::AppliveryHelper.escape(params[:notify_message])
10
- tags = params[:tags]
11
13
  build_path = params[:build_path]
12
- notify_collaborators = params[:notify_collaborators]
13
- notify_employees = params[:notify_employees]
14
-
15
- command = "curl \"https://api.applivery.io/v1/integrations/builds\""
16
- command += " -H \"Authorization: bearer #{app_token}\""
17
- command += " -F versionName=\"#{name}\""
18
- command += " -F changelog=\"#{changelog}\""
19
- command += " -F notifyCollaborators=#{notify_collaborators}"
20
- command += " -F notifyEmployees=#{notify_employees}"
21
- command += " -F tags=\"#{tags}\""
22
- command += " -F notifyMessage=\"#{notify_message}\""
23
- command += " -F build=@\"#{build_path}\""
24
- command += " -F deployer.name=fastlane"
25
- command += Helper::AppliveryHelper.add_integration_number
26
- command += Helper::AppliveryHelper.add_git_params
27
-
28
- Actions.sh(command)
14
+ build = Faraday::UploadIO.new(build_path, 'application/octet-stream') if build_path && File.exist?(build_path)
15
+
16
+ conn = Faraday.new(url: 'https://api.applivery.io') do |faraday|
17
+ faraday.request :multipart
18
+ faraday.request :url_encoded
19
+ # faraday.response :logger
20
+ faraday.use FaradayMiddleware::ParseJson
21
+ faraday.adapter :net_http
22
+ end
23
+
24
+ response = conn.post do |req|
25
+ req.url '/v1/integrations/builds'
26
+ req.headers['Content-Type'] = 'multipart/form-data'
27
+ req.headers['Accept'] = 'application/json'
28
+ req.headers['Authorization'] = "bearer #{params[:app_token]}"
29
+ request_body = {
30
+ changelog: params[:changelog],
31
+ notifyCollaborators: params[:notify_collaborators],
32
+ notifyEmployees: params[:notify_employees],
33
+ notifyMessage: params[:notify_message],
34
+ build: build,
35
+ deployer: {
36
+ name: "fastlane",
37
+ info: {
38
+ buildNumber: Helper::AppliveryHelper.get_integration_number,
39
+ branch: Helper::AppliveryHelper.git_branch,
40
+ commit: Helper::AppliveryHelper.git_commit,
41
+ commitMessage: Helper::AppliveryHelper.git_message,
42
+ repositoryUrl: Helper::AppliveryHelper.add_git_remote,
43
+ tag: Helper::AppliveryHelper.git_tag,
44
+ triggerTimestamp: Time.now.getutc.to_i
45
+ }
46
+ }
47
+ }
48
+ request_body[:versionName] = params[:name] if !params[:name].nil?
49
+ request_body[:tags] = params[:tags] if !params[:tags].nil?
50
+
51
+ req.body = request_body
52
+ UI.message "Uploading to Applivery... 🛫"
53
+ UI.verbose("Request Body: #{req.body}")
54
+ end
55
+ UI.verbose "Response Body: #{response.body}"
56
+ status = response.body["status"]
57
+ Actions.lane_context[SharedValues::APPLIVERY_BUILD_ID] = response.body["data"]["id"]
58
+ if status
59
+ UI.success "Build uploaded succesfully! 💪"
60
+ else
61
+ UI.error "Oops! Something went wrong.... 🔥"
62
+ Helper::AppliveryHelper.parse_error(response.error)
63
+ end
64
+
29
65
  end
30
66
 
31
67
  def self.build_path
@@ -104,6 +140,12 @@ module Fastlane
104
140
  ]
105
141
  end
106
142
 
143
+ def self.output
144
+ [
145
+ ['APPLIVERY_BUILD_ID', 'The id for the new build generated. You can open your build in https://dashboard.applivery.io/apps/apps/<YOUR_APP_SLUG>/builds?id=${APPLIVERY_BUILD_ID}']
146
+ ]
147
+ end
148
+
107
149
  def self.is_supported?(platform)
108
150
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
109
151
  # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
@@ -118,8 +160,7 @@ module Fastlane
118
160
 
119
161
  def self.example_code
120
162
  [
121
- 'applivery(
122
- app_token: "YOUR_APP_TOKEN")'
163
+ 'applivery(app_token: "YOUR_APP_TOKEN")'
123
164
  ]
124
165
  end
125
166
 
@@ -8,10 +8,6 @@ module Fastlane
8
8
  UI.message("Hello from the applivery plugin helper!")
9
9
  end
10
10
 
11
- def self.escape(string)
12
- return URI.encode(string.sub(/@/, '\@'))
13
- end
14
-
15
11
  def self.platform
16
12
  platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
17
13
  if platform == :ios or platform.nil?
@@ -21,69 +17,77 @@ module Fastlane
21
17
  end
22
18
  end
23
19
 
24
- def self.add_integration_number
20
+ def self.get_integration_number
25
21
  xcodeIntegrationNumber = ENV["XCS_INTEGRATION_NUMBER"] # XCode Server
26
22
  jenkinsIntegrationNumber = ENV["BUILD_NUMBER"] # Jenkins
27
23
  travisIntegrationNumber = ENV["TRAVIS_BUILD_NUMBER"] # Travis
28
- command = ""
24
+ integrationNumber = ""
29
25
 
30
26
  if !xcodeIntegrationNumber.nil?
31
- command += " -F deployer.info.buildNumber=\"#{xcodeIntegrationNumber}\""
27
+ integrationNumber += xcodeIntegrationNumber
32
28
  elsif !jenkinsIntegrationNumber.nil?
33
- command += " -F deployer.info.buildNumber=\"#{jenkinsIntegrationNumber}\""
29
+ integrationNumber += jenkinsIntegrationNumber
34
30
  elsif !travisIntegrationNumber.nil?
35
- command += " -F deployer.info.buildNumber=\"#{travisIntegrationNumber}\""
31
+ integrationNumber += travisIntegrationNumber
36
32
  end
37
33
 
38
- return command
34
+ return integrationNumber
39
35
  end
40
36
 
41
37
 
42
38
  ### GIT Methods ###
43
39
 
44
- def self.is_git?
45
- Actions.sh('git rev-parse HEAD')
46
- return true
40
+ def self.git_branch
41
+ return Actions.git_branch
47
42
  rescue
48
- return false
43
+ return ""
49
44
  end
50
45
 
51
- def self.add_git_params
52
- command = ""
53
- if self.is_git?
54
- UI.message "Detected repo: git"
55
- gitBranch = Actions.git_branch
56
- gitCommit = Actions.sh('git rev-parse --short HEAD')
57
- gitMessage = Actions.last_git_commit_message
58
-
59
- command += " -F deployer.info.branch=\"#{gitBranch}\""
60
- command += " -F deployer.info.commit=\"#{gitCommit}\""
61
- command += " -F deployer.info.commitMessage=\"#{self.escape(gitMessage)}\""
62
- command += self.add_git_remote
63
- command += self.add_git_tag
64
- end
65
- return command
46
+ def self.git_commit
47
+ return `git rev-parse --short HEAD`
48
+ rescue
49
+ return ""
66
50
  end
67
51
 
68
- def self.add_git_tag
69
- gitTag = Actions.sh('git describe --abbrev=0 --tags')
70
- gitTagCommit = Actions.sh("git rev-list -n 1 --abbrev-commit #{gitTag}")
71
- gitCommit = Actions.sh('git rev-parse --short HEAD')
72
- if gitTagCommit == gitCommit
73
- return " -F deployer.info.tag=\"#{gitTag}\""
74
- end
75
- return ""
52
+ def self.git_message
53
+ return Actions.last_git_commit_message
76
54
  rescue
77
55
  return ""
78
56
  end
79
57
 
80
58
  def self.add_git_remote
81
- gitRepositoryURL = Actions.sh('git config --get remote.origin.url')
82
- return " -F deployer.info.repositoryUrl=\"#{gitRepositoryURL}\""
59
+ return `git config --get remote.origin.url`
83
60
  rescue
84
61
  return ""
85
62
  end
86
63
 
64
+ def self.git_tag
65
+ gitTag = `git describe --abbrev=0 --tags`
66
+ gitTagCommit = `git rev-list -n 1 --abbrev-commit #{gitTag}`
67
+ gitCommit = `git rev-parse --short HEAD`
68
+ return gitTag if gitTagCommit == gitCommit
69
+ return ""
70
+ rescue
71
+ return ""
72
+ end
73
+
74
+ def self.parse_error(error)
75
+ if error
76
+ case error["code"]
77
+ when 5006
78
+ UI.user_error! "Upload fail. The build path seems to be wrong or file is invalid"
79
+ when 4004
80
+ UI.user_error! "The app_token is not valid. Please, go to your app settings and doble-check the integration tokens"
81
+ when 4002
82
+ UI.user_error! "The app_token is empty. Please, go to your app Settings->Integrations to generate a token"
83
+ else
84
+ UI.user_error! "Upload fail. [#{error["code"]}]: #{error["message"]}"
85
+ end
86
+ else
87
+ UI.crash! "Upload fails unexpectedly. [#{response.status}]"
88
+ end
89
+ end
90
+
87
91
  end
88
92
  end
89
93
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Applivery
3
- VERSION = "2.0.0"
3
+ VERSION = "2.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-applivery
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Jimenez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-11 00:00:00.000000000 Z
11
+ date: 2019-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry