Class: Fastlane::Actions::IncrementVersionCodeAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



83
84
85
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 83

def self.authors
  ['Manabu OHTAKE']
end

.available_optionsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 38

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :app_project_dir,
      env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
      description: 'The path to the application source folder
        in the Android project (default: android/app)',
      optional: true,
      type: String,
      default_value: 'android/app'
    ),
    FastlaneCore::ConfigItem.new(
      key: :flavor,
      env_name: 'ANDROID_VERSIONING_FLAVOR',
      description: 'The product flavor name (optional)',
      optional: true,
      type: String
    ),
    FastlaneCore::ConfigItem.new(
      key: :version_code,
      env_name: 'ANDROID_VERSIONING_VERSION_CODE',
      description: 'Change to a specific version (optional)',
      optional: true,
      type: Integer
    )
  ]
end

.descriptionObject



66
67
68
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 66

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

.detailsObject



70
71
72
73
74
75
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 70

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 87

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

.outputObject



77
78
79
80
81
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 77

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

.run(params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb', line 13

def self.run(params)
  current_version_code = GetVersionCodeAction.run(params)

  new_version_code =
    if params[:version_code].nil?
      current_version_code.to_i + 1
    elsif params[:version_code] == -1
      ((Time.now.to_f * 1000).to_i / (60 * 1000)).to_i
    else
      params[:version_code].to_i
    end

  SetValueInBuildAction.run(
    app_project_dir: params[:app_project_dir],
    flavor: params[:flavor],
    key: 'versionCode',
    value: new_version_code
  )
  Actions.lane_context[SharedValues::VERSION_CODE] = new_version_code.to_s
  new_version_code.to_s
end