Method: Fastlane::Actions::DeploygateAction.upload_build

Defined in:
fastlane/lib/fastlane/actions/deploygate.rb

.upload_build(api_token, user_name, binary, options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'fastlane/lib/fastlane/actions/deploygate.rb', line 16

def self.upload_build(api_token, user_name, binary, options)
  require 'faraday'
  require 'faraday_middleware'

  connection = Faraday.new(url: DEPLOYGATE_URL_BASE, request: { timeout: 120 }) do |builder|
    builder.request(:multipart)
    builder.request(:json)
    builder.response(:json, content_type: /\bjson$/)
    builder.use(FaradayMiddleware::FollowRedirects)
    builder.adapter(:net_http)
  end

  options.update({
    token: api_token,
    file: Faraday::UploadIO.new(binary, 'application/octet-stream'),
    message: options[:message] || ''
  })
  options[:disable_notify] = 'yes' if options[:disable_notify]

  connection.post("/api/users/#{user_name}/apps", options)
rescue Faraday::TimeoutError
  UI.crash!("Timed out while uploading build. Check https://deploygate.com/ to see if the upload was completed.")
end