Class: Fastlane::Actions::IncrementVersionCodeAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authors ⇒ Object



57
58
59
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 57

def self.authors
  ["Manabu OHTAKE"]
end

.available_options ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 25

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :app_folder_name,
                              env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
                           description: "The name of the application source folder in the Android project (default: app)",
                              optional: true,
                                  type: String,
                         default_value: "app"),
    FastlaneCore::ConfigItem.new(key: :version_code,
                            env_name: "ANDROID_VERSIONING_VERSION_CODE",
                         description: "Change to a specific version (optional)",
                            optional: true,
                                type: Integer)
  ]
end

.description ⇒ Object



41
42
43
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 41

def self.description
  "Increment the version code of your project"
end

.details ⇒ Object



45
46
47
48
49
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 45

def self.details
  [
    "This action will increment the version code directly in build.gradle . "
  ].join("\n")
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 61

def self.is_supported?(platform)
  platform == :android
end

.output ⇒ Object



51
52
53
54
55
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 51

def self.output
  [
    ['VERSION_CODE', 'The new version code']
  ]
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb', line 10

def self.run(params)
  current_version_code = GetVersionCodeAction.run(params)
  new_version_code = params[:version_code].nil? || params[:version_code].empty? ? current_version_code.to_i + 1 : params[:version_code].to_i
  SetValueInBuildAction.run(
    app_folder_name: params[:app_folder_name],
    key: "versionCode",
    value: new_version_code
  )
  Actions.lane_context[SharedValues::VERSION_CODE] = new_version_code.to_s
  new_version_code.to_s
end