class Fastlane::Actions::AndroidGetVersionCodeAction

Public Class Methods

available_options() click to toggle source
# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 38
def self.available_options
  [
    app_project_dir_action,
    FastlaneCore::ConfigItem.new(key: :key,
                                 env_name: "FL_ANDROID_GET_VERSION_CODE_KEY",
                                 description: "The property key",
                                 optional: true,
                                 type: String,
                                 default_value: "versionCode"),
  ]
end
category() click to toggle source
# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 56
def self.category
  # https://github.com/fastlane/fastlane/blob/051e5012984d97257571a76627c1261946afb8f8/fastlane/lib/fastlane/action.rb#L6-L21
  :project
end
description() click to toggle source

@!group Documentation

# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 30
def self.description
  "Returns the version code of the android project"
end
details() click to toggle source
# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 34
def self.details
  "Based on the provided params, returns the value of the version code of the build.gradle file as a number"
end
output() click to toggle source
# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 50
def self.output
  [
    ["ANDROID_VERSION_CODE", "The version code specified on the build.gradle file of the project"],
  ]
end
return_type() click to toggle source
# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 75
def self.return_type
  # https://github.com/fastlane/fastlane/blob/051e5012984d97257571a76627c1261946afb8f8/fastlane/lib/fastlane/action.rb#L23-L30
  :int
end
return_value() click to toggle source

def self.example_code

[
  'version = get_version_number(xcodeproj: "Project.xcodeproj")',
  'version = get_version_number(
    xcodeproj: "Project.xcodeproj",
    target: "App"
  )'
]

end

# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 71
def self.return_value
  "The Android app version code"
end
run(params) click to toggle source
# File lib/fastlane/plugin/android_version_manager/actions/android_get_version_code_action.rb, line 12
def self.run(params)
  # fastlane will take care of reading in the parameter and fetching the environment variable:
  UI.message("Parameter app_project_dir: #{params[:app_project_dir]}")
  UI.message("Parameter key: #{params[:key]}")

  file_path = find_build_gradle(params[:app_project_dir])
  # We can expect version_code to be an existing and valid version code
  version_code = Helper::AndroidVersionManagerHelper.get_version_code_from_gradle_file(file_path, params[:key])

  Actions.lane_context[Fastlane::Actions::SharedValues::ANDROID_VERSION_CODE] = version_code

  return version_code
end