fastlane-plugin-diawi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8329ba8e7b59cf817ba781e59dc4423a66923ccd
4
+ data.tar.gz: c95f5d2b43afaa5b37b845214eede85ebddf79cd
5
+ SHA512:
6
+ metadata.gz: c4a9a1e121f59a42b6fc1c174bb85f38aa238af466d7767692c5ebcb114e77bebff4f0352d4b323ecb52ecde8271bebc5e4f163c230663ab430284307f35ac87
7
+ data.tar.gz: a6d738eb24bd50be9c99ba6b09489cc68a62626645e1fe263be0da298253fd45a9b6c2e3fb5ec87ed3711a858a3b2cde3970966ced830866af6b54733c8a1757
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 pacification <dmitry.lyaschuck@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # diawi plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-diawi)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-diawi`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin diawi
11
+ ```
12
+
13
+ ## About diawi
14
+
15
+ Upload .ipa file to diawi.com
16
+
17
+ **Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
18
+
19
+ ## Example
20
+
21
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
+
23
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
+
25
+ ## Run tests for this plugin
26
+
27
+ To run both the tests, and code style validation, run
28
+
29
+ ```
30
+ rake
31
+ ```
32
+
33
+ To automatically fix many of the styling issues, use
34
+ ```
35
+ rubocop -a
36
+ ```
37
+
38
+ ## Issues and Feedback
39
+
40
+ For any other issues and feedback about this plugin, please submit it to this repository.
41
+
42
+ ## Troubleshooting
43
+
44
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
45
+
46
+ ## Using _fastlane_ Plugins
47
+
48
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
49
+
50
+ ## About _fastlane_
51
+
52
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/diawi/version'
2
+
3
+ module Fastlane
4
+ module Diawi
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Diawi.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,216 @@
1
+ # based on https://dashboard.diawi.com/docs/apis/upload
2
+
3
+ module Fastlane
4
+ module Actions
5
+
6
+ module SharedValues
7
+ UPLOADED_FILE_LINK_TO_DIAWI = :UPLOADED_FILE_LINK_TO_DIAWI
8
+ end
9
+
10
+ class DiawiAction < Action
11
+
12
+ ENDPOINT = "https://upload.diawi.com/"
13
+
14
+ #####################################################
15
+ # @!group Connection
16
+ #####################################################
17
+
18
+ def self.status_connection(token, job)
19
+ require 'faraday'
20
+ require 'faraday_middleware'
21
+
22
+ connection = Faraday.new(:url => ENDPOINT) do |builder|
23
+ builder.request :url_encoded
24
+ builder.response :json, content_type: /\bjson$/
25
+ builder.use FaradayMiddleware::FollowRedirects
26
+ builder.adapter :net_http
27
+ end
28
+ connection.get "/status", { :token => token, :job => job }
29
+ end
30
+
31
+ def self.upload_connection
32
+ require 'faraday'
33
+ require 'faraday_middleware'
34
+
35
+ Faraday.new(url: ENDPOINT) do |builder|
36
+ builder.request :multipart
37
+ builder.request :url_encoded
38
+ builder.response :json, content_type: /\bjson$/
39
+ builder.use FaradayMiddleware::FollowRedirects
40
+ builder.adapter :net_http
41
+ end
42
+ end
43
+
44
+ #####################################################
45
+ # @!group Data logic
46
+ #####################################################
47
+
48
+ def self.check_status_for_upload(file, token, job)
49
+ # from diawi's documendation:
50
+ # Polling frequence
51
+ # Usually, processing of an upload will take from 0.5 to 5 seconds, so the best polling frequence would be every 1 second for up to 10 times.
52
+ # If the status is still 2001 after 10 seconds, there probably is a problem, let us know.
53
+ availableRequestCount = 5 # 2 sec * 5 times = 10 sec for status check request else raise an error
54
+ requestCount = 0
55
+
56
+ status_ok = 2000
57
+ status_in_progress = 2001
58
+ status_error = 4000
59
+
60
+ while availableRequestCount > requestCount do
61
+ response = self.status_connection(token, job)
62
+
63
+ case response.body["status"]
64
+ when status_ok
65
+ link = "https://i.diawi.com/#{response.body['hash']}"
66
+ UI.success("File successfully uploaded to diawi. Link: #{link}")
67
+ Actions.lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI] = link
68
+ return
69
+ when status_in_progress
70
+ UI.message("Uploading...")
71
+ when status_error
72
+ UI.error("Error uploading file to diawi. Message: #{response.body['message']}")
73
+ UI.error("Try to upload file by yourself: #{file}")
74
+ return
75
+ else
76
+ UI.error("Unknown error uploading file to diawi.")
77
+ UI.error("Try to upload file by yourself: #{file}")
78
+ return
79
+ end
80
+
81
+ requestCount += 1
82
+ sleep(2)
83
+ end
84
+
85
+ UI.error("`In progress` status took more than 10 sec, so raise error. Check out the https://dashboard.diawi.com/. Maybe your file has been uploaded successfully.")
86
+ UI.error("If not, try to upload file by yourself: #{file}")
87
+ end
88
+
89
+ def self.upload(file, token, options)
90
+ connection = self.upload_connection
91
+
92
+ options.update({
93
+ token: token,
94
+ file: Faraday::UploadIO.new(file, "application/octet-stream")
95
+ })
96
+
97
+ post_request = connection.post do |request|
98
+ request.body = options
99
+ end
100
+
101
+ post_request.on_complete do |response|
102
+ if response.body && response.body.key?("job")
103
+ return response.body["job"]
104
+ else
105
+ UI.error("Error uploading file to diawi: #{response.body['message']}")
106
+ return
107
+ end
108
+ end
109
+ end
110
+
111
+ #####################################################
112
+ # @!group Run
113
+ #####################################################
114
+
115
+ def self.run(options)
116
+ token = options[:token]
117
+ file = options[:file]
118
+
119
+ upload_options = options.values.select do |key, value|
120
+ [:password, :comment, :callback_url, :callback_emails].include? key unless value.nil?
121
+ end
122
+
123
+ options.values.each do |key, value|
124
+ if [:find_by_udid, :wall_of_apps, :installation_notifications].include? key
125
+ upload_options[key] = value ? 1 : 0 unless value.nil?
126
+ end
127
+ end
128
+
129
+ UI.success("Starting with app upload to diawi... this could take some time ⏳")
130
+
131
+ job = self.upload(file, token, upload_options)
132
+
133
+ if job
134
+ self.check_status_for_upload(file, token, job)
135
+ end
136
+ end
137
+
138
+ #####################################################
139
+ # @!group Documentation
140
+ #####################################################
141
+
142
+ def self.available_options
143
+ [
144
+ FastlaneCore::ConfigItem.new(key: :token,
145
+ env_name: "DIAWI_TOKEN",
146
+ description: "API access token",
147
+ optional: false),
148
+ FastlaneCore::ConfigItem.new(key: :file,
149
+ env_name: "DIAWI_FILE",
150
+ description: "Path to .ipa or .apk file",
151
+ optional: false,
152
+ verify_block: proc do |value|
153
+ UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value)
154
+ end),
155
+ FastlaneCore::ConfigItem.new(key: :find_by_udid,
156
+ env_name: "DIAWI_FIND_BY_UDID",
157
+ description: "Allow your testers to find the app on diawi's mobile web app using their UDID (iOS only)",
158
+ is_string: false,
159
+ optional: true),
160
+ FastlaneCore::ConfigItem.new(key: :wall_of_apps,
161
+ env_name: "DIAWI_WALL_OF_APPS",
162
+ description: "Allow diawi to display the app's icon on the wall of apps",
163
+ is_string: false,
164
+ optional: true),
165
+ FastlaneCore::ConfigItem.new(key: :password,
166
+ env_name: "DIAWI_PASSWORD",
167
+ description: "Protect your app with a password: it will be required to access the installation page",
168
+ optional: true),
169
+ FastlaneCore::ConfigItem.new(key: :comment,
170
+ env_name: "DIAWI_COMMENT",
171
+ description: "Additional information to your users on this build: the comment will be displayed on the installation page",
172
+ optional: true),
173
+ FastlaneCore::ConfigItem.new(key: :callback_url,
174
+ env_name: "DIAWI_CALLBACK_URL",
175
+ description: "The URL diawi should call with the result",
176
+ optional: true,
177
+ verify_block: proc do |value|
178
+ UI.user_error!("The `callback_url` not valid.") if value =~ URI::regexp
179
+ end),
180
+ FastlaneCore::ConfigItem.new(key: :callback_emails,
181
+ env_name: "DIAWI_CALLBACK_EMAILS",
182
+ description: "The email addresses diawi will send the result to (up to 5 separated by commas for starter/premium/enterprise accounts, 1 for free accounts). Emails should be a string. Ex: \"example@test.com,example1@test.com\"",
183
+ optional: true),
184
+ FastlaneCore::ConfigItem.new(key: :installation_notifications,
185
+ env_name: "DIAWI_INSTALLATION_NOTIFICATIONS",
186
+ description: "Receive notifications each time someone installs the app (only starter/premium/enterprise accounts)",
187
+ is_string: false,
188
+ optional: true)
189
+ ]
190
+ end
191
+
192
+ def self.output
193
+ [
194
+ ['UPLOADED_FILE_LINK_TO_DIAWI', 'URL to uploaded .ipa or .apk file to diawi.']
195
+ ]
196
+ end
197
+
198
+ def self.description
199
+ "Upload .ipa/.apk file to diawi.com"
200
+ end
201
+
202
+ def self.authors
203
+ ["pacification"]
204
+ end
205
+
206
+ def self.details
207
+ "This action upload .ipa/.apk file to https://www.diawi.com and return link to uploaded file."
208
+ end
209
+
210
+ def self.is_supported?(platform)
211
+ [:ios, :android].include?(platform)
212
+ end
213
+
214
+ end
215
+ end
216
+ end
@@ -0,0 +1,12 @@
1
+ module Fastlane
2
+ module Helper
3
+ class DiawiHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::DiawiHelper.your_method`
6
+ #
7
+ def self.show_message
8
+ UI.message("Hello from the diawi plugin helper!")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Diawi
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-diawi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - pacification
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fastlane
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.26.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.26.1
97
+ description:
98
+ email: dmitry.lyaschuck@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - LICENSE
104
+ - README.md
105
+ - lib/fastlane/plugin/diawi.rb
106
+ - lib/fastlane/plugin/diawi/actions/diawi_action.rb
107
+ - lib/fastlane/plugin/diawi/helper/diawi_helper.rb
108
+ - lib/fastlane/plugin/diawi/version.rb
109
+ homepage: https://github.com/pacification/fastlane-plugin-diawi
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.11
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Upload .ipa or .apk file to diawi.com
133
+ test_files: []