Commit 790f13ad authored by Vadim Vlasov's avatar Vadim Vlasov

Added appgate_upload action

parent 93994e7f
......@@ -32,4 +32,6 @@ Gem::Specification.new do |spec|
spec.add_development_dependency('rubocop-require_tools')
spec.add_development_dependency('simplecov')
spec.add_development_dependency('fastlane', '>= 2.129.0')
spec.add_runtime_dependency 'faraday', '~> 1.0'
end
module Fastlane
module Actions
class AppgateUploadAction < Action
def self.run(params)
app_id = params[:app_id]
file_path = params[:file_path]
api_key = "bearer " + params[:api_key]
url = "https://apps.furylion.net/api/app/#{app_id}/upload"
UI.message("Uploading binary...")
conn = Faraday.new(url: url) do |faraday|
faraday.request :multipart
faraday.request :url_encoded
faraday.adapter Faraday.default_adapter
end
payload = { file: Faraday::UploadIO.new(file_path, 'application/octet-stream') }
response = conn.post do |req|
req.headers['Authorization'] = api_key
req.body = payload
end
case response.status
when 200..205
UI.success("Upload complete!")
when 401
UI.user_error!("Auth Error, provided invalid token")
when 400...407, 409...428, 430...499
UI.user_error!("Client error: #{response.status}: #{response.body}")
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Upload build to AppGate"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :app_id,
env_name: "APPGATE_APP_ID",
description: "AppGate App ID",
optional: false,
default_value: ""),
FastlaneCore::ConfigItem.new(key: :file_path,
env_name: "APPGATE_FILE_PATH",
description: "Path to your build file",
verify_block: proc do |value|
UI.user_error!("Could not find file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_name: "APPGATE_API_KEY",
description: "API key for AppGate",
sensitive: true)
]
end
def self.authors
["Vadim Vlasov"]
end
def self.is_supported?(platform)
[:ios, :android].include?(platform)
end
end
end
end
module Fastlane
module Furylion
VERSION = "1.1.2"
VERSION = "1.1.3"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment