Class: Fastlane::Actions::AndroidGetVersionCodeAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb

Class Method Summary collapse

Class Method Details

.authorsObject



54
55
56
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 54

def self.authors
  ["Igor Lamoš"]
end

.available_optionsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 30

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :gradle_file,
                            env_name: "FL_ANDROID_GET_VERSION_CODE_GRADLE_FILE",
                         description: "(optional) Specify the path to your app build.gradle if it isn't in the default location",
                            optional: true,
                                type: String,
                       default_value: "app/build.gradle",
                        verify_block: proc do |value|
                          UI.user_error!("Could not find app build.gradle file") unless File.exist?(value) || Helper.test?
                        end)
  ]
end

.descriptionObject



22
23
24
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 22

def self.description
  "Get the Version Code of your Android project"
end

.detailsObject



26
27
28
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 26

def self.details
  "This action will return current Version Code of your Android project."
end

.example_codeObject



62
63
64
65
66
67
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 62

def self.example_code
  [
    'version_code = android_get_version_code # build.gradle is in the default location',
    'version_code = android_get_version_code(gradle_file: "/path/to/build.gradle")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 58

def self.is_supported?(platform)
  [:android].include?(platform)
end

.outputObject



44
45
46
47
48
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 44

def self.output
  [
    ['ANDROID_VERSION_CODE', 'The Version Code of your Android project']
  ]
end

.return_valueObject



50
51
52
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 50

def self.return_value
  "The Version Code of your Android project"
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/plugin/versioning_android/actions/android_get_version_code.rb', line 8

def self.run(params)
  gradle_file_path = Helper::VersioningAndroidHelper.get_gradle_file_path(params[:gradle_file])
  version_code = Helper::VersioningAndroidHelper.read_key_from_gradle_file(gradle_file_path, "versionCode")

  if version_code == false
    UI.user_error!("Unable to find the versionCode in build.gradle file at #{gradle_file_path}.")
  end

  UI.success("👍  Current Android Version Code is: #{version_code}")

  # Store the Version Code in the shared hash
  Actions.lane_context[SharedValues::ANDROID_VERSION_CODE] = version_code
end