Class: Fastlane::Actions::PgyerUploadV2Action
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::PgyerUploadV2Action
- Defined in:
- lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
-
.return_value ⇒ Object
def self.output # Define the shared values you are going to provide # Example [ [‘PGYER_V2_CUSTOM_VALUE’, ‘A description of what this value contains’] ] end.
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
188 189 190 191 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 188 def self. # So no one will ever forget your contribution to fastlane :) You are awesome btw! ["Jiahao"] end |
.available_options ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 105 def self. # Define all options your action supports. # Below a few examples [ FastlaneCore::ConfigItem.new(key: :api_key, env_name: "FL_PGYER_UPLOAD_V2_API_KEY", description: "api_key in your pgyer account", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :apk, env_name: "FL_PGYER_UPLOAD_V2_APK", description: "Path to your APK file", default_value: Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH], optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find apk file at path '#{value}'") unless File.exist?(value) end, conflicting_options: [:ipa], conflict_block: proc do |value| UI.user_error!("You can't use 'apk' and '#{value.key}' options in one run") end), FastlaneCore::ConfigItem.new(key: :ipa, env_name: "FL_PGYER_UPLOAD_V2_IPA", description: "Path to your IPA file. Optional if you use the _gym_ or _xcodebuild_ action. For Mac zip the .app. For Android provide path to .apk file", default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH], optional: true, verify_block: proc do |value| UI.user_error!("Couldn't find ipa file at path '#{value}'") unless File.exist?(value) end, conflicting_options: [:apk], conflict_block: proc do |value| UI.user_error!("You can't use 'ipa' and '#{value.key}' options in one run") end), FastlaneCore::ConfigItem.new(key: :buildPassword, env_name: "FL_PGYER_UPLOAD_V2_BUILD_Password", description: "set buildPassword to protect app", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :buildUpdateDescription, env_name: "FL_PGYER_UPLOAD_V2_BUILD_UPDATE_DESCRIPTION", description: "set update description for app", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :buildInstallType, env_name: "FL_PGYER_UPLOAD_V2_BUILD_INSTALL_TYPE", description: "set install type for app (1=public, 2=password, 3=invite). Please set as a string", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :buildChannelShortcut, env_name: "FL_PGYER_UPLOAD_V2_BUILD_CHANNEL_SHORTCUT", description: "set the download short link of designated channel. MUST Sure the channel exsit ", optional: true, type: String) # FastlaneCore::ConfigItem.new(key: :api_token, # env_name: "FL_PGYER_UPLOAD_V2_API_TOKEN", # The name of the environment variable # description: "API Token for PgyerV2Action", # a short description of this parameter # verify_block: proc do |value| # UI.user_error!("No API token for PgyerV2Action given, pass using `api_token: 'token'`") unless (value and not value.empty?) # # UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value) # end), # FastlaneCore::ConfigItem.new(key: :development, # env_name: "FL_PGYER_UPLOAD_V2_DEVELOPMENT", # description: "Create a development certificate instead of a distribution one", # is_string: false, # true: verifies the input is a string, false: every kind of value # default_value: false) # the default value if the user didn't provide one ] end |
.description ⇒ Object
95 96 97 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 95 def self.description "distribute app to pgyer_upload_v2 beta testing service" end |
.details ⇒ Object
99 100 101 102 103 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 99 def self.details # Optional: # this is your chance to provide a more detailed description of this action "distribute app to pgyer_upload__v2 by API V2 beta testing service." end |
.is_supported?(platform) ⇒ Boolean
193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 193 def self.is_supported?(platform) # you can do things like # # true # # platform == :ios # # [:ios, :mac].include?(platform) # [:ios, :mac, :android].include?(platform) true end |
.return_value ⇒ Object
def self.output
# Define the shared values you are going to provide
# Example
[
['PGYER_V2_CUSTOM_VALUE', 'A description of what this value contains']
]
end
184 185 186 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 184 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/fastlane/plugin/pgyer_upload_v2/actions/pgyer_upload_v2_action.rb', line 10 def self.run(params) # fastlane will take care of reading in the parameter and fetching the environment variable: # UI.message "Parameter API Token: #{params[:api_token]}" UI.("The PgyerUploadV2 Action is working.") api_host = "https://www.pgyer.com/apiv2/app/upload" api_key = params[:api_key] # sh "shellcommand ./path" build_file = [ params[:ipa], params[:apk] ].detect { |e| !e.to_s.empty? } if build_file.nil? UI.user_error!("You have to provide a build file") end UI. "build_file: #{build_file}" buildPassword = params[:buildPassword] if buildPassword.nil? buildPassword = "" end buildUpdateDescription = params[:buildUpdateDescription] if buildUpdateDescription.nil? buildUpdateDescription = "PgyerSecond Action Default build_Update_Description " end buildInstallType = params[:buildInstallType] if buildInstallType.nil? buildInstallType = "1" end buildChannelShortcut = params[:buildChannelShortcut] # start upload = { request: { timeout: 1000, open_timeout: 300 } } pgyer_client = Faraday.new(nil, ) do |c| c.request :multipart c.request :url_encoded c.response :json, content_type: /\bjson$/ c.adapter :net_http end params = { '_api_key' => api_key, 'buildPassword' => buildPassword, 'buildUpdateDescription' => buildUpdateDescription, 'buildInstallType' => buildInstallType, 'buildChannelShortcut' => buildChannelShortcut, 'file' => Faraday::UploadIO.new(build_file, 'application/octet-stream') } if buildChannelShortcut.nil? # UI.message "🚑️🚑️ the buildChannelShortcut => #{buildChannelShortcut} 为nil 将其delete 🚑️🚑️🚑️" params.delete('buildChannelShortcut') else UI. "🚧 🚧🚧🚧 the buildChannelShortcut #{buildChannelShortcut}🚧🚧🚧🚧" # 也可以动态添加 params.store("buildChannelShortcut", buildChannelShortcut) end UI. "Start upload #{build_file} to pgyer by APIV2..." # UI.message "🚀 🚀 Start upload #{params} to pgyer by APIV2...🚀" response = pgyer_client.post api_host, params info = response.body if info['code'] != 0 UI.user_error!("PGYER Plugin Error: #{info['message']}") end UI.success "Upload success. Visit this URL to see: https://www.pgyer.com/#{info['data']['buildShortcutUrl']}" # Actions.lane_context[SharedValues::PGYER_V2_CUSTOM_VALUE] = "my_val" end |