Class: Fastlane::Actions::TryoutsAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::TryoutsAction
- Defined in:
- lib/fastlane/actions/tryouts.rb
Constant Summary collapse
- TRYOUTS_API_BUILD_RELEASE_TEMPLATE =
"https://api.tryouts.io/v1/applications/%s/releases/"
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(params) ⇒ Object
- .upload_build(params) ⇒ Object
Methods inherited from Fastlane::Action
action_name, author, lane_context, method_missing, other_action, return_value, sample_return_value, sh, step_text
Class Method Details
.authors ⇒ Object
138 139 140 |
# File 'lib/fastlane/actions/tryouts.rb', line 138 def self. ["alicertel"] end |
.available_options ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/fastlane/actions/tryouts.rb', line 68 def self. [ FastlaneCore::ConfigItem.new(key: :app_id, env_name: "TRYOUTS_APP_ID", description: "Tryouts application hash", verify_block: proc do |value| UI.user_error!("No application identifier for Tryouts given, pass using `app_id: 'application id'`") unless value and !value.empty? end), FastlaneCore::ConfigItem.new(key: :api_token, env_name: "TRYOUTS_API_TOKEN", description: "API Token for Tryouts Access", verify_block: proc do |value| UI.user_error!("No API token for Tryouts given, pass using `api_token: 'token'`") unless value and !value.empty? end), FastlaneCore::ConfigItem.new(key: :build_file, env_name: "TRYOUTS_BUILD_FILE", description: "Path to your IPA or APK file. Optional if you use the _gym_ or _xcodebuild_ action", default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], verify_block: proc do |value| UI.user_error!("Couldn't find build file at path '#{value}'") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :notes, env_name: "TRYOUTS_NOTES", description: "Release notes", is_string: true, optional: true), FastlaneCore::ConfigItem.new(key: :notes_path, env_name: "TRYOUTS_NOTES_PATH", description: "Release notes text file path. Overrides the :notes paramether", verify_block: proc do |value| UI.user_error!("Couldn't find notes file at path '#{value}'") unless File.exist?(value) end, optional: true), FastlaneCore::ConfigItem.new(key: :notify, env_name: "TRYOUTS_NOTIFY", description: "Notify testers? 0 for no", is_string: false, default_value: 1), FastlaneCore::ConfigItem.new(key: :status, env_name: "TRYOUTS_STATUS", description: "2 to make your release public. Release will be distributed to available testers. 1 to make your release private. Release won't be distributed to testers. This also prevents release from showing up for SDK update", verify_block: proc do |value| = ["1", "2"] UI.user_error!("'#{value}' is not a valid 'status' value. Available options are #{.join(', ')}") unless .include?(value.to_s) end, is_string: false, default_value: 2) ] end |
.category ⇒ Object
128 129 130 |
# File 'lib/fastlane/actions/tryouts.rb', line 128 def self.category :misc end |
.description ⇒ Object
60 61 62 |
# File 'lib/fastlane/actions/tryouts.rb', line 60 def self.description "Upload a new build to Tryouts" end |
.details ⇒ Object
64 65 66 |
# File 'lib/fastlane/actions/tryouts.rb', line 64 def self.details "More information http://tryouts.readthedocs.org/en/latest/releases.html#create-release" end |
.example_code ⇒ Object
118 119 120 121 122 123 124 125 126 |
# File 'lib/fastlane/actions/tryouts.rb', line 118 def self.example_code [ 'tryouts( api_token: "...", app_id: "application-id", build_file: "test.ipa", )' ] end |
.is_supported?(platform) ⇒ Boolean
142 143 144 |
# File 'lib/fastlane/actions/tryouts.rb', line 142 def self.is_supported?(platform) [:ios, :android].include?(platform) end |
.output ⇒ Object
132 133 134 135 136 |
# File 'lib/fastlane/actions/tryouts.rb', line 132 def self.output [ ['TRYOUTS_BUILD_INFORMATION', 'Contains release info like :application_name, :download_url. See http://tryouts.readthedocs.org/en/latest/releases.html#create-release'] ] end |
.run(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/fastlane/actions/tryouts.rb', line 10 def self.run(params) UI.success('Upload to Tryouts has been started. This may take some time.') response = self.upload_build(params) case response.status when 200...300 Actions.lane_context[SharedValues::TRYOUTS_BUILD_INFORMATION] = response.body UI.success('Build successfully uploaded to Tryouts!') UI.("Release download url: #{response.body['download_url']}") if response.body["download_url"] else UI.user_error!("Error when trying to upload build file to Tryouts: #{response.body}") end end |
.upload_build(params) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fastlane/actions/tryouts.rb', line 25 def self.upload_build(params) require 'faraday' require 'faraday_middleware' url = TRYOUTS_API_BUILD_RELEASE_TEMPLATE % params[:app_id] connection = Faraday.new(url) do |builder| builder.request :multipart builder.request :url_encoded builder.response :json, content_type: /\bjson$/ builder.use FaradayMiddleware::FollowRedirects builder.adapter :net_http end = {} [:build] = Faraday::UploadIO.new(params[:build_file], 'application/octet-stream') if params[:notes_path] [:notes] = File.read(params[:notes_path]) elsif params[:notes] [:notes] = params[:notes] end [:notify] = params[:notify].to_s [:status] = params[:status].to_s post_request = connection.post do |req| req.headers['Authorization'] = params[:api_token] req.body = end post_request.on_complete do |env| yield env[:status], env[:body] if block_given? end end |