Class: Fastlane::Actions::GetAndroidVersionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::GetAndroidVersionAction
- Defined in:
- lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
60 61 62 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 60 def self. ["MaximusMcCann"] end |
.available_options ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 73 def self. [ FastlaneCore::ConfigItem.new(key: :apk, env_name: "GET_ANDROID_VERSION_APK", description: "The apk to get the versionName and versionCode from", optional: false, type: String) ] end |
.description ⇒ Object
56 57 58 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 56 def self.description "Gets the android versionName, versionCode and parsed appName (label) from AndroidManifest.xml file in provided apk" end |
.details ⇒ Object
68 69 70 71 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 68 def self.details # Optional: "Gets the android versionName, versionCode and parsed appName (label) from AndroidManifest.xml file in provided apk" end |
.is_supported?(platform) ⇒ Boolean
91 92 93 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 91 def self.is_supported?(platform) platform == :android end |
.output ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 83 def self.output [ ['GET_ANDROID_VERSION_NAME', 'The versionName extracted from the apk\'s manifest file.'], ['GET_ANDROID_VERSION_CODE', 'The versionCode extracted from the apk\'s manifest file. Hex values are converted to ints.'], ['GET_ANDROID_VERSION_APP_NAME', 'The appNmae extracted from the apk\'s manifest file.'] ] end |
.return_value ⇒ Object
64 65 66 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 64 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
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 |
# File 'lib/fastlane/plugin/get_android_version/actions/get_android_version_action.rb', line 9 def self.run(params) require 'apktools/apkxml' apk_file = params[:apk] # NOTE!! ALL CREDIT DUE HERE: https://github.com/devunwired/apktools/blob/master/bin/get_app_version.rb # Load the XML data parser = ApkXml.new(apk_file) parser.parse_xml("AndroidManifest.xml", false, true) elements = parser.xml_elements versionCode = nil versionName = nil appName = nil elements.each do |element| if element.name == "manifest" element.attributes.each do |attr| if attr.name == "versionCode" versionCode = attr.value elsif attr.name == "versionName" versionName = attr.value end end elsif element.name == "application" element.attributes.each do |attr| if attr.name == "label" appName = attr.value end end end end if versionCode =~ /^0x[0-9A-Fa-f]+$/ #if is hex versionCode = versionCode.to_i(16) end Actions.lane_context[SharedValues::GET_ANDROID_VERSION_NAME] = "#{versionName}" Actions.lane_context[SharedValues::GET_ANDROID_VERSION_CODE] = "#{versionCode}" Actions.lane_context[SharedValues::GET_ANDROID_VERSION_APP_NAME] = "#{appName}" UI.("Data pulled from: #{apk_file}") UI.("extracted versionName: #{versionName} & versionCode: #{versionCode} & appName: #{appName}") end |