fastlane-plugin-appcircle_testing_distribution 0.4.3.beta.3 → 0.5.0.beta.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: d29253d3bd644428e3c3403ec7de545a6570cf3e2b470c58ba50ddb6c211da9d
4
- data.tar.gz: 3e8298d2f5d547d5891a9f5d34a043c05fdfedf2c5c3c2d66f43def751a372d0
3
+ metadata.gz: 83c9d8655326e41c07f7b6d927fb63441c01059e2c29c2658338931c5a2ae718
4
+ data.tar.gz: fc194ce33b458182af4725f5e21b525666c9cab85cc41b9c5a2d29444251488d
5
5
  SHA512:
6
- metadata.gz: f5d216ec25e3c4162fcad0da1bcd5c2dc28fd9711d973d987c3841b1473f903b83fa2b827bcc894082b1006ce30c811ef6599138816d5455970599418ab8ffa6
7
- data.tar.gz: 0c4280025c48eda9e4b54fdbe44bd7f839cca35bdd2439cd5ab7b0784a0f7d43d6a908df98617891b8f64e489078fb107b63954dc3cf8c80f81059b0cc2204b0
6
+ metadata.gz: 2a0568378f254b846f291bc6dc9bb0b149b8590f8945fa521f91d670eca5bca37818af392cf9028cc3580ff6bb92ad6cb07a5c606e016b7a0da07fac215bf1a4
7
+ data.tar.gz: 4a64eab748b2a2163b464ac87793982687940e8c9df4cb1ca8ca7501f42e7d91472b91c66eb627b0fa07fb7bb2b8bb7f77bae07608bb6b866d04737f7defda10
@@ -8,6 +8,29 @@ BASE_URL = "https://api.appcircle.io"
8
8
  module TDUploadService
9
9
  UI = FastlaneCore::UI
10
10
 
11
+ def self.put_with_retry(url, body, headers, max_retries: 5)
12
+ attempt = 0
13
+ delay = 1.0
14
+
15
+ begin
16
+ RestClient.put(url, body, headers)
17
+ rescue => e
18
+ status = e.respond_to?(:http_code) ? e.http_code : nil
19
+ retryable = status == 503 ||
20
+ e.is_a?(RestClient::ServerBrokeConnection) ||
21
+ e.is_a?(Errno::ECONNRESET) ||
22
+ (defined?(RestClient::Exceptions::OpenTimeout) && e.is_a?(RestClient::Exceptions::OpenTimeout)) ||
23
+ (defined?(RestClient::Exceptions::ReadTimeout) && e.is_a?(RestClient::Exceptions::ReadTimeout))
24
+
25
+ raise e if !retryable || attempt >= max_retries
26
+
27
+ attempt += 1
28
+ sleep(delay + rand(0.3))
29
+ delay *= 2
30
+ retry
31
+ end
32
+ end
33
+
11
34
  def self.upload_artifact(token:, message:, app:, dist_profile_id:, api_endpoint: BASE_URL)
12
35
  file_path = app
13
36
  file_name = File.basename(file_path)
@@ -38,14 +61,25 @@ module TDUploadService
38
61
  end
39
62
  file_id = upload_info['fileId']
40
63
  upload_url = upload_info['uploadUrl']
64
+ configuration = upload_info['configuration']
65
+ http_method = (configuration && configuration['httpMethod']) ? configuration['httpMethod'].to_s.upcase : 'PUT'
41
66
 
42
- file_content = File.binread(file_path)
43
67
  UI.message("Uploading file to Appcircle...")
44
- response = RestClient.put(
45
- upload_url,
46
- file_content,
47
- { content_type: 'application/octet-stream' }
48
- )
68
+ if http_method == 'POST'
69
+ sign_parameters = configuration['signParameters'] || {}
70
+ payload = {}
71
+ sign_parameters.each { |key, value| payload[key] = value }
72
+ payload['file'] = File.new(file_path, 'rb')
73
+ response = RestClient.post(upload_url, payload)
74
+ else
75
+ file_content = File.binread(file_path)
76
+ response = put_with_retry(
77
+ upload_url,
78
+ file_content,
79
+ { content_type: 'application/octet-stream' }
80
+ )
81
+ end
82
+
49
83
  if response.code.between?(200, 299)
50
84
  UI.success("File upload finished successfully with status code: #{response.code}")
51
85
  else
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AppcircleTestingDistribution
3
- VERSION = "0.4.3.beta.3"
3
+ VERSION = "0.5.0.beta.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appcircle_testing_distribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3.beta.3
4
+ version: 0.5.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - appcircleio