Class: Fastlane::Actions::NappDistributionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::NappDistributionAction
- Defined in:
- lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .connection(base_url) ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
67 68 69 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 67 def self. ["Mads Møller"] end |
.available_options ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 80 def self. [ FastlaneCore::ConfigItem.new(key: :api_key, env_name: "NAPP_DISTRIBUTION_API_KEY", description: "API Key", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :client_id, env_name: "NAPP_DISTRIBUTION_CLIENT_ID", optional: false, description: "Client name", type: String), FastlaneCore::ConfigItem.new(key: :file_path, env_name: "NAPP_DISTRIBUTION_FILE_PATH", optional: false, description: "File path of the app build", type: String), FastlaneCore::ConfigItem.new(key: :base_url, env_name: "NAPP_DISTRIBUTION_BASE_URL", optional: true, type: String, description: "Private cloud option") ] end |
.connection(base_url) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 47 def self.connection(base_url) require 'faraday' require 'faraday_middleware' = { url: base_url } Faraday.new() do |builder| builder.request :multipart builder.request :url_encoded builder.response :json, content_type: /\bjson$/ builder.use FaradayMiddleware::FollowRedirects builder.adapter :net_http end end |
.description ⇒ Object
63 64 65 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 63 def self.description "Upload builds to Napp Distribution Center" end |
.details ⇒ Object
75 76 77 78 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 75 def self.details # Optional: "Upload builds to Napp Distribution Center" end |
.is_supported?(platform) ⇒ Boolean
105 106 107 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 105 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.return_value ⇒ Object
71 72 73 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 71 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fastlane/plugin/napp_distribution/actions/napp_distribution_action.rb', line 4 def self.run(params) UI.("The napp_distribution plugin is working!") # set the base url base_url = "https://i.napp.dk" if params[:base_url] base_url = params[:base_url] end file_path = params[:file_path] client_id = params[:client_id] api_key = params[:api_key] connection = self.connection(base_url) if !File.exist?(file_path) UI.user_error("App build file not found 🚫") abort end # setting the payload payload = {} payload[:file] = Faraday::UploadIO.new(file_path, 'application/octet-stream') payload[:client] = client_id response = connection.post do |req| req.url("/api/clients/upload") req.headers['X-NAPP-API-KEY'] = api_key req.body = payload end case response.status when 200...300 app_version_id = response.body['version'] platform = response.body['platform'] UI.("Successfully created new app build version: #{app_version_id} for #{platform}") else UI.error("Error trying to upload new app build: #{response.status} - #{response.body}") end end |