Class: Fastlane::Actions::PaperToolsBuildsUploadAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::PaperToolsBuildsUploadAction
- Defined in:
- lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb
Overview
Uploads a build by shelling out to the builds binary.
The binary is the single upload path, so the lane inherits its resumable multipart upload, its exit codes, and its staging-or-production default without reimplementing any of it.
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
-
.parse(stdout) ⇒ Object
The
--jsonupload response, or an empty hash if it was not JSON. - .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
73 74 75 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 73 def self. ['paper.tools'] end |
.available_options ⇒ Object
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 117 118 119 120 121 122 123 124 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 77 def self. [ FastlaneCore::ConfigItem.new(key: :file, description: 'Path to the .ipa, .apk, or .aab', verify_block: proc do |value| UI.user_error!("No file at #{value}") unless File.exist?(value) end), FastlaneCore::ConfigItem.new(key: :channel, description: 'The channel to land on'), FastlaneCore::ConfigItem.new(key: :token, description: 'A builds:write API token', sensitive: true), FastlaneCore::ConfigItem.new(key: :to, description: 'Comma-separated recipients to distribute to', optional: true), FastlaneCore::ConfigItem.new(key: :org, description: 'The organisation id'), FastlaneCore::ConfigItem.new(key: :app, description: 'The app id'), FastlaneCore::ConfigItem.new(key: :version, description: 'The marketing version', optional: true), FastlaneCore::ConfigItem.new(key: :build_number, description: 'The build number', optional: true), FastlaneCore::ConfigItem.new(key: :release_notes, description: 'Release notes for this build', optional: true), FastlaneCore::ConfigItem.new(key: :tags, description: 'Comma-separated tags', optional: true), FastlaneCore::ConfigItem.new(key: :format, description: 'Force the format when the extension does not name it', optional: true), FastlaneCore::ConfigItem.new(key: :notify, description: 'Notify recipients; defaults to the channel setting', optional: true, is_string: false), FastlaneCore::ConfigItem.new(key: :concurrency, description: 'How many parts to upload at once', optional: true, type: Integer), FastlaneCore::ConfigItem.new(key: :binary, description: 'Path to the builds binary', optional: true, default_value: 'builds'), ] end |
.category ⇒ Object
130 131 132 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 130 def self.category :building end |
.description ⇒ Object
59 60 61 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 59 def self.description 'Upload a build to Builds by paper.tools' end |
.details ⇒ Object
63 64 65 66 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 63 def self.details 'Wraps the `builds` CLI. Install it first (brew install ' \ 'paper-tools/tap/builds), then pass a builds:write token as `token`.' end |
.example_code ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 134 def self.example_code [ 'paper_tools_builds_upload( file: lane_context[SharedValues::IPA_OUTPUT_PATH], channel: "qa", org: "your-org-id", app: "your-app-id", token: ENV["BUILDS_TOKEN"], version: get_version_number, build_number: get_build_number )', ] end |
.is_supported?(platform) ⇒ Boolean
126 127 128 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 126 def self.is_supported?(platform) [:ios, :mac, :android].include?(platform) end |
.parse(stdout) ⇒ Object
The --json upload response, or an empty hash if it was not JSON. A
non-JSON stdout is not fatal — the upload succeeded — so the id is simply
unavailable rather than an error.
53 54 55 56 57 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 53 def self.parse(stdout) JSON.parse(stdout) rescue JSON::ParserError {} end |
.return_value ⇒ Object
68 69 70 71 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 68 def self.return_value 'The id of the accepted build, also stored in ' \ 'lane_context[SharedValues::PAPER_TOOLS_BUILDS_BUILD_ID].' end |
.run(params) ⇒ Object
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 45 46 47 48 |
# File 'lib/fastlane/plugin/paper_tools_builds/actions/paper_tools_builds_upload_action.rb', line 17 def self.run(params) command = [params[:binary], 'upload', params[:file], '--channel', params[:channel], '--json'] command += ['--to', params[:to]] unless params[:to].nil? command += ['--version', params[:version]] unless params[:version].nil? command += ['--build-number', params[:build_number].to_s] unless params[:build_number].nil? command += ['--release-notes', params[:release_notes]] unless params[:release_notes].nil? command += ['--tags', params[:tags]] unless params[:tags].nil? command += ['--format', params[:format]] unless params[:format].nil? command += ['--concurrency', params[:concurrency].to_s] unless params[:concurrency].nil? command += ['--org', params[:org], '--app', params[:app]] command += (params[:notify] ? ['--notify'] : ['--no-notify']) unless params[:notify].nil? # The token is a `--token` flag the caller passes in, not a variable the # plugin reads from the environment behind the caller's back. command += ['--token', params[:token]] UI.("Uploading #{params[:file]} to channel #{params[:channel]}…") stdout, stderr, status = Open3.capture3(*command) unless status.success? UI.error(stderr.strip) unless stderr.strip.empty? # The binary's exit code names the failure class — auth, quota, # network — and the lane fails with it rather than swallowing it. UI.user_error!("builds upload failed (exit #{status.exitstatus}).") end build = parse(stdout) build_id = build['build_id'] Actions.lane_context[SharedValues::PAPER_TOOLS_BUILDS_BUILD_ID] = build_id UI.success("Uploaded. Build #{build_id} is #{build['status']}.") build_id end |