fastlane-plugin-diawireborn 2.2.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4f8fed09690ad2eac425ae146ca5e56719230c5cd59706e3f10efdcf5aae49a9
4
+ data.tar.gz: 5560239105a727d4cec6473c74eb8559901f9dffc386476800390d07cc6bdabd
5
+ SHA512:
6
+ metadata.gz: 76dbe8a063159cc2e4c844b39f8805c16700434f684cdd1dfcdfd96ad07654cf09c73aee2011bd3213fde427cf0f664c9dfaabf77626f7c5f9f51616d8152c4c
7
+ data.tar.gz: daf7ffec319e121a0f21d2e2dec79d96fb5fd59fa2a7a5fcc2be7cb38488fa9b98075b48067ab9014275415d444bfc2cfffd29f397b8e98af226711ef6f9e553
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 iMokhles <mokhlashussein@aol.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.
data/README.md ADDED
@@ -0,0 +1,65 @@
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-diawireborn`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin diawireborn
11
+ ```
12
+
13
+ ## About diawi
14
+
15
+ Diawi is a tool for developers to deploy Development and In-house applications directly to the devices.
16
+ This plugin can upload .ipa and .apk file to diawi.
17
+
18
+ ## Available options
19
+
20
+ Key | Required | Type | Description
21
+ --- | --- | --- | ---
22
+ **token** | **`true`** | `String` | [API access token](https://dashboard.diawi.io)
23
+ **file** | `false` | `String` | Path to .ipa or .apk file.<br>**Default**: `IPA_OUTPUT_PATH` or `GRADLE_APK_OUTPUT_PATH` based on platform
24
+ **find_by_udid** | `false` | `Boolean` | Allow your testers to find the app on diawi's mobile web app using their UDID (**iOS only**)
25
+ **wall_of_apps** | `false` | `Boolean` | Allow diawi to display the app's icon on the wall of apps
26
+ **password** | `false` | `String` | Protect your app with a password: it will be required to access the installation page
27
+ **comment** | `false` | `String` | Additional information to your users on this build: the comment will be displayed on the installation page
28
+ **callback_url** | `false` | `String` | The URL diawi should call with the result
29
+ **callback_emails** | `false` | `String` | 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"
30
+ **installation_notifications** | `false` | `Boolean` | Receive notifications each time someone installs the app (only starter/premium/enterprise accounts)
31
+ **timeout** | `false` | `Int` | Timeout for checking upload status in seconds.<br>**Default**: 60<br>**Range**: (5, 1800)
32
+ **check_status_delay** | `false` | `Int` | Number of seconds to wait between repeated attempts at checking upload status.<br>**Default**: 3<br>**Range**: (1, 30)
33
+
34
+ ## Result link
35
+
36
+ If file upload successfully, you can access result link by:
37
+
38
+ `lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI]`
39
+
40
+ ## Example
41
+
42
+ Minimal plugin configuration is:
43
+ ```ruby
44
+ diawireborn(
45
+ token: "your_api_token"
46
+ )
47
+ ```
48
+
49
+ For more options see [**Available options**](#available-options) section.
50
+
51
+ ## Issues and Feedback
52
+
53
+ For any other issues and feedback about this plugin, please submit it to this repository.
54
+
55
+ ## Troubleshooting
56
+
57
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
58
+
59
+ ## Using _fastlane_ Plugins
60
+
61
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
62
+
63
+ ## About _fastlane_
64
+
65
+ _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,221 @@
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 DiawirebornAction < Action
11
+
12
+ UPLOAD_URL = "https://upload.diawi.com/"
13
+ STATUS_CHECK_URL = "https://upload.diawi.com/status"
14
+ DIAWI_FILE_LINK = "https://i.diawi.com"
15
+
16
+ def self.run(options)
17
+ Actions.verify_gem!('rest-client')
18
+ require 'rest-client'
19
+ require 'json'
20
+
21
+ if options[:file].nil?
22
+ UI.important("File didn't come to diawi_plugin. Uploading is unavailable.")
23
+ return
24
+ end
25
+
26
+ if options[:token].nil?
27
+ UI.important("Diawi token is nil - uploading is unavailable.")
28
+ UI.important("Try to upload file by yourself. Path: #{options[:file]}")
29
+ return
30
+ end
31
+
32
+ upload_options = options.values.select do |key, value|
33
+ [:password, :comment, :callback_url, :callback_emails].include? key unless value.nil?
34
+ end
35
+
36
+ options.values.each do |key, value|
37
+ if [:find_by_udid, :wall_of_apps, :installation_notifications].include? key
38
+ upload_options[key] = value ? 1 : 0 unless value.nil?
39
+ end
40
+ end
41
+
42
+ upload_options[:token] = options[:token]
43
+ upload_options[:file] = File.new(options[:file], 'rb')
44
+
45
+ UI.success("Start uploading file to diawi. Please, be patient. This could take some time.")
46
+
47
+ response = RestClient.post(UPLOAD_URL, upload_options)
48
+
49
+ begin
50
+ response
51
+ rescue RestClient::ExceptionWithResponse => error
52
+ UI.important("Faild to upload file to diawi, because of:")
53
+ UI.important(error)
54
+ UI.important("Try to upload file by yourself. Path: #{options[:file]}")
55
+ return
56
+ end
57
+
58
+ job = JSON.parse(response.body)['job']
59
+
60
+ if job
61
+ timeout = options[:timeout].clamp(5, 1800)
62
+ check_status_delay = options[:check_status_delay].clamp(1, 30)
63
+
64
+ if check_status_delay > timeout
65
+ UI.important("`check_status_delay` is greater than `timeout`")
66
+ end
67
+
68
+ UI.success("Upload completed successfully.")
69
+ UI.success("\n\nProcessing started with params:\n\njob: #{job}\ntimeout: #{timeout},\ncheck_status_delay: #{check_status_delay}\n")
70
+ return self.check_status(options[:token], options[:file], job, options[:timeout], options[:check_status_delay])
71
+ end
72
+
73
+ UI.important("Something went wrong and `job` value didn't come from uploading request. Check out your dashboard: https://dashboard.diawi.com/. Maybe your file already has been uploaded successfully.")
74
+ UI.important("If not, try to upload file by yourself. Path: #{options[:file]}")
75
+ end
76
+
77
+ def self.check_status(token, file, job, timeout, check_status_delay)
78
+ status_ok = 2000
79
+ status_in_progress = 2001
80
+ status_error = 4000
81
+
82
+ timeout_time = Time.now + timeout
83
+ current_time = Time.now
84
+
85
+ while timeout_time > current_time do
86
+ response = RestClient.get STATUS_CHECK_URL, {params: {token: token, job: job}}
87
+
88
+ begin
89
+ response
90
+ rescue RestClient::ExceptionWithResponse => error
91
+ UI.important("Check file status request error:")
92
+ UI.important(error)
93
+ sleep(check_status_delay)
94
+ current_time = Time.now
95
+ next
96
+ end
97
+
98
+ json = JSON.parse(response.body)
99
+
100
+ case json['status']
101
+ when status_ok
102
+ link = "#{DIAWI_FILE_LINK}/#{json['hash']}"
103
+ UI.success("File successfully uploaded to diawi. Link: #{link}")
104
+ Actions.lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI] = link
105
+ return
106
+
107
+ when status_in_progress
108
+ UI.message("Processing file...")
109
+
110
+ when status_error
111
+ UI.important("Error uploading file to diawi.")
112
+ UI.important(json['message'])
113
+ else
114
+ UI.important("Unknown error uploading file to diawi.")
115
+ end
116
+
117
+ sleep(check_status_delay)
118
+ current_time = Time.now
119
+ end
120
+
121
+ UI.important("File is not processed.")
122
+ UI.important("Try to upload file by yourself: #{file}")
123
+ end
124
+
125
+ def self.default_file_path
126
+ platform = Actions.lane_context[SharedValues::PLATFORM_NAME]
127
+ ios_path = Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]
128
+ android_path = Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
129
+ return platform == :ios ? ios_path : android_path
130
+ end
131
+
132
+ #####################################################
133
+ # @!group Documentation
134
+ #####################################################
135
+
136
+ def self.available_options
137
+ [
138
+ FastlaneCore::ConfigItem.new(key: :token,
139
+ env_name: "DIAWI_TOKEN",
140
+ description: "API access token",
141
+ optional: false),
142
+ FastlaneCore::ConfigItem.new(key: :file,
143
+ env_name: "DIAWI_FILE",
144
+ description: "Path to .ipa or .apk file. Default - `IPA_OUTPUT_PATH` or `GRADLE_APK_OUTPUT_PATH` based on platform",
145
+ optional: true,
146
+ default_value: self.default_file_path),
147
+ FastlaneCore::ConfigItem.new(key: :find_by_udid,
148
+ env_name: "DIAWI_FIND_BY_UDID",
149
+ description: "Allow your testers to find the app on diawi's mobile web app using their UDID (iOS only)",
150
+ is_string: false,
151
+ optional: true),
152
+ FastlaneCore::ConfigItem.new(key: :wall_of_apps,
153
+ env_name: "DIAWI_WALL_OF_APPS",
154
+ description: "Allow diawi to display the app's icon on the wall of apps",
155
+ is_string: false,
156
+ optional: true),
157
+ FastlaneCore::ConfigItem.new(key: :password,
158
+ env_name: "DIAWI_PASSWORD",
159
+ description: "Protect your app with a password: it will be required to access the installation page",
160
+ optional: true),
161
+ FastlaneCore::ConfigItem.new(key: :comment,
162
+ env_name: "DIAWI_COMMENT",
163
+ description: "Additional information to your users on this build: the comment will be displayed on the installation page",
164
+ optional: true),
165
+ FastlaneCore::ConfigItem.new(key: :callback_url,
166
+ env_name: "DIAWI_CALLBACK_URL",
167
+ description: "The URL diawi should call with the result",
168
+ optional: true,
169
+ verify_block: proc do |value|
170
+ UI.user_error!("The `callback_url` not valid.") if value =~ URI::regexp
171
+ end),
172
+ FastlaneCore::ConfigItem.new(key: :callback_emails,
173
+ env_name: "DIAWI_CALLBACK_EMAILS",
174
+ 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\"",
175
+ optional: true),
176
+ FastlaneCore::ConfigItem.new(key: :installation_notifications,
177
+ env_name: "DIAWI_INSTALLATION_NOTIFICATIONS",
178
+ description: "Receive notifications each time someone installs the app (only starter/premium/enterprise accounts)",
179
+ is_string: false,
180
+ optional: true),
181
+ FastlaneCore::ConfigItem.new(key: :timeout,
182
+ env_name: "DIAWI_TIMEOUT",
183
+ description: "Timeout for checking upload status in seconds. Default: 60, range: (5, 1800)",
184
+ is_string: false,
185
+ optional: true,
186
+ default_value: 60),
187
+ FastlaneCore::ConfigItem.new(key: :check_status_delay,
188
+ env_name: "DIAWI_CHECK_STATUS_DELAY",
189
+ description: "Number of seconds to wait between repeated attempts at checking upload status. Default: 3, range: (1, 30)",
190
+ is_string: false,
191
+ optional: true,
192
+ default_value: 3)
193
+ ]
194
+ end
195
+
196
+ def self.output
197
+ [
198
+ ['UPLOADED_FILE_LINK_TO_DIAWI', 'URL to uploaded .ipa or .apk file to diawi.']
199
+ ]
200
+ end
201
+
202
+ def self.description
203
+ "Upload .ipa/.apk file to diawi.com"
204
+ end
205
+
206
+ def self.authors
207
+ ["imokhles"]
208
+ end
209
+
210
+ def self.details
211
+ "This action upload .ipa/.apk file to https://www.diawi.com and return link to uploaded file."
212
+ end
213
+
214
+ def self.is_supported?(platform)
215
+ [:ios, :android].include?(platform)
216
+ end
217
+
218
+ end
219
+
220
+ end
221
+ end
@@ -0,0 +1,12 @@
1
+ module Fastlane
2
+ module Helper
3
+ class DiawirebornHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::DiawirebornHelper.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 Diawireborn
3
+ VERSION = "2.2.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/diawireborn/version'
2
+
3
+ module Fastlane
4
+ module Diawireborn
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::Diawireborn.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-diawireborn
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.0
5
+ platform: ruby
6
+ authors:
7
+ - iMokhles
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
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: bundler
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: rspec
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: rake
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: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fastlane
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.93.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.93.0
111
+ description:
112
+ email: mokhlashussein@aol.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - LICENSE
118
+ - README.md
119
+ - lib/fastlane/plugin/diawireborn.rb
120
+ - lib/fastlane/plugin/diawireborn/actions/diawireborn_action.rb
121
+ - lib/fastlane/plugin/diawireborn/helper/diawireborn_helper.rb
122
+ - lib/fastlane/plugin/diawireborn/version.rb
123
+ homepage: https://github.com/imokhles/fastlane-plugin-diawi-reborn
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubygems_version: 3.1.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Upload .ipa or .apk file to diawi.com
146
+ test_files: []