Class: Fastlane::Actions::PgyerAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::PgyerAction
- Defined in:
- lib/fastlane/plugin/pgyer/actions/pgyer_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
127 128 129 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 127 def self. ["rexshi"] end |
.available_options ⇒ Object
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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 140 def self. [ FastlaneCore::ConfigItem.new(key: :api_key, env_name: "PGYER_API_KEY", description: "api_key in your pgyer account", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :apk, env_name: "PGYER_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: "PGYER_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: :password, env_name: "PGYER_PASSWORD", description: "Set password to protect app", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :update_description, env_name: "PGYER_UPDATE_DESCRIPTION", description: "Set update description for app", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :save_uploaded_info_json, env_name: "PGYER_SAVE_UPLOADED_INFO_JSON", description: "Save uploaded info json to file named pgyer-fastlane-uploaded-app-info.json", optional: true, default_value: false, type: Boolean), FastlaneCore::ConfigItem.new(key: :install_type, env_name: "PGYER_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: :install_date, env_name: "PGYER_INSTALL_DATE", description: "Set install type for app (1=Set valid time, 2=Long-term effective, other=Do not modify the last setting). Please set as a string", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :install_start_date, env_name: "PGYER_INSTALL_START_DATE", description: "The value is a string of characters, for example, 2018-01-01", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :install_end_date, env_name: "PGYER_INSTALL_END_DATE", description: "The value is a string of characters, such as 2018-12-31", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :oversea, env_name: "PGYER_OVERSEA", description: "Whether to use overseas acceleration. 1 for overseas accelerated upload, 0 for domestic accelerated upload, not filled in for automatic judgment based on IP", optional: true, type: Numeric), FastlaneCore::ConfigItem.new(key: :channel, env_name: "PGYER_SPECIFIED_CHANNEL", description: "Need to update the specified channel of the download short link, can specify only one channel, string type, such as: ABCD", optional: true, type: String), ] end |
.description ⇒ Object
123 124 125 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 123 def self.description "distribute app to pgyer beta testing service" end |
.details ⇒ Object
135 136 137 138 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 135 def self.details # Optional: "distribute app to pgyer beta testing service" end |
.is_supported?(platform) ⇒ Boolean
224 225 226 227 228 229 230 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 224 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md # [:ios, :mac, :android].include?(platform) true end |
.return_value ⇒ Object
131 132 133 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 131 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
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 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 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 |
# File 'lib/fastlane/plugin/pgyer/actions/pgyer_action.rb', line 7 def self.run(params) UI.("The pgyer plugin is working.") api_key = params[:api_key] 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 type = params[:ipa].nil? ? "android" : "ios" UI. "build_file: #{build_file}, type: #{type}" install_type = params[:install_type] if install_type.nil? install_type = "1" end password = params[:password] if password.nil? password = "" end request_params = { "_api_key" => api_key, "buildType" => type, "buildInstallType" => install_type, "buildPassword" => password, } request_params["oversea"] = params[:oversea] unless params[:oversea].nil? update_description = params[:update_description] if update_description != nil request_params["buildUpdateDescription"] = update_description end install_date = params[:install_date] if install_date != nil if install_date == "1" request_params["buildInstallDate"] = install_date install_start_date = params[:install_start_date] request_params["buildInstallStartDate"] = install_start_date install_end_date = params[:install_end_date] request_params["buildInstallEndDate"] = install_end_date elsif install_date == "2" request_params["buildInstallDate"] = install_date end end channel = params[:channel] if channel != nil request_params["buildChannelShortcut"] = channel end # start upload = { request: { timeout: 1000, open_timeout: 300, }, } api_host = "https://www.pgyer.com/apiv2/app" 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 response = pgyer_client.post "#{api_host}/getCOSToken", request_params info = response.body if info["code"] != 0 UI.user_error!("Get token is failed, info: #{info}") end key = info["data"]["key"] endpoint = info["data"]["endpoint"] request_params = info["data"]["params"] if key.nil? || endpoint.nil? || request_params.nil? UI.user_error!("Get token is failed") end content_type = type == "android" ? "application/vnd.android.package-archive" : "application/octet-stream" request_params["file"] = Faraday::UploadIO.new(build_file, content_type) UI. "Start upload #{build_file} to pgyer..." response = pgyer_client.post endpoint, request_params if response.status != 204 UI.user_error!("PGYER Plugin Upload Error: #{response.body}") end answer = self.checkPublishStatus(pgyer_client, api_host, api_key, key) if params[:save_uploaded_info_json] File.open("pgyer-fastlane-uploaded-app-info.json", "w") do |f| f.write(answer.to_json) end end answer end |