Created
April 20, 2023 04:29
-
-
Save zhgchgli0718/42f6326225e393e20616ce15f3390c88 to your computer and use it in GitHub Desktop.
A simply extend the Fastlane Action to enable downloading the uploaded Universal APK from the Google Play Console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File location: /actions/apk_downloader.rb | |
module Fastlane | |
module Actions | |
module SharedValues | |
APK_DOWNLOADER_CUSTOM_VALUE = :APK_DOWNLOADER_CUSTOM_VALUE | |
end | |
class ApkDownloaderAction < Action | |
def self.run(params) | |
require 'supply' | |
require 'supply/options' | |
Supply.config = params | |
supplyClient = Supply::Client.make_from_config | |
googleClient = supplyClient.client | |
apks = googleClient.list_generatedapks(params[:package_name], params[:version_code]) | |
downloadID = apks.generated_apks[0].generated_universal_apk.download_id | |
UI.message("ApkDownloaderAction...\npackageName: #{params[:package_name]}\nversionCode: #{params[:version_code]}\nDownloadID: #{downloadID}") | |
UI.message("🕗 Downloading APK...") | |
apk = googleClient.download_generatedapk(params[:package_name], params[:version_code], downloadID, download_dest: params[:export_file_path]) { | |
UI.success("✅ Successfully download apk in '#{params[:export_file_path]}'") | |
} | |
end | |
##################################################### | |
# @!group Documentation | |
##################################################### | |
def self.description | |
"Download generated Apk from google play console." | |
end | |
def self.details | |
"Download generated Apk from google play console." | |
end | |
def self.available_options | |
require 'supply' | |
require 'supply/options' | |
defaultOptions = [ | |
:package_name, | |
:track, | |
:json_key, | |
:json_key_data, | |
:root_url, | |
:timeout, | |
:key, | |
:version_code | |
] | |
result = Supply::Options.available_options.select do |option| | |
defaultOptions.include?(option.key) | |
end | |
result.append(FastlaneCore::ConfigItem.new(key: :export_file_path, | |
env_name: "FL_APK_EXPORT_FILE_PATH", | |
description: "APK Export File Path", | |
is_string: true, | |
default_value: "")) | |
end | |
def self.output | |
[ | |
] | |
end | |
def self.return_value | |
end | |
def self.authors | |
["zhgchgli"] | |
end | |
def self.is_supported?(platform) | |
platform == :android | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lane :test do | options | | |
apk_downloader(json_key: "./[email protected]", package_name: "m.zhgchg.li", version_code:1000, export_file_path: "./zhgchgli.apk") | |
end |
Author
zhgchgli0718
commented
Apr 20, 2023
i receive "The following App Bundle version code could not be found." when i call list_generatedapks method,can you help me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment