Class: Fastlane::Actions::IncrementVersionNameAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authors ⇒ Object



85
86
87
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 85

def self.authors
  ["Manabu OHTAKE"]
end

.available_options ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 44

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: :bump_type,
                            env_name: "ANDROID_VERSIONING_BUMP_TYPE",
                         description: "Change to a specific type (optional)",
                            optional: true,
                                type: String,
                       default_value: "patch",
                        verify_block: proc do |value|
                                        UI.user_error!("Available values are 'patch', 'minor' and 'major'") unless ['patch', 'minor', 'major'].include? value
                                      end),
    FastlaneCore::ConfigItem.new(key: :version_name,
                            env_name: "ANDROID_VERSIONING_VERSION_NAME",
                         description: "Change to a specific version (optional)",
                            optional: true,
                                type: String)
  ]
end

.description ⇒ Object



69
70
71
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 69

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

.details ⇒ Object



73
74
75
76
77
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 73

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 89

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

.output ⇒ Object



79
80
81
82
83
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 79

def self.output
  [
    ['VERSION_NAME', 'The new version name']
  ]
end

.run(params) ⇒ Object



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
# File 'lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb', line 10

def self.run(params)
  if params[:version_name].nil? or params[:version_name].empty?
    current_version = GetVersionNameAction.run(params)
    UI.user_error!("Your current version (#{current_version}) does not respect the format A.B.C") unless current_version =~ /\d+.\d+.\d+/
    version = current_version.split(".").map(&:to_i)
    case params[:bump_type]
    when "patch"
      version[2] = version[2] + 1
      new_version = version.join(".")
    when "minor"
      version[1] = version[1] + 1
      version[2] = version[2] = 0
      new_version = version.join(".")
    when "major"
      version[0] = version[0] + 1
      version[1] = 0
      version[2] = 0
      new_version = version.join(".")
    end
  else
    new_version = params[:version_name]
  end
  SetValueInBuildAction.run(
    app_folder_name: params[:app_folder_name],
    key: "versionName",
    value: new_version
  )
  Actions.lane_context[SharedValues::VERSION_NAME] = new_version
  new_version
end