Class: Fastlane::Actions::AndroidSetVersionNameAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



68
69
70
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 68

def self.authors
  ["futabooo"]
end

.available_optionsObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 32

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :gradle_file,
                                 env_name: "FL_ANDROID_SET_VERSION_NAME_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.kts",
                                 verify_block: proc do |value|
                                   UI.user_error!("Could not find #{value} file") unless File.exist?(value) || Helper.test?
                                 end),
    FastlaneCore::ConfigItem.new(key: :version_name,
                                 env_name: "FL_ANDROID_SET_VERSION_NAME_VERSION_NAME",
                                 description: "(optional) Set specific Version Name",
                                 optional: true,
                                 type: String,
                                 default_value: nil),
    FastlaneCore::ConfigItem.new(key: :bump_type,
                                 env_name: "FL_ANDROID_SET_VERSION_NAME_BUMP_TYPE",
                                 description: "(optional) Type of version bump (major, minor, patch)",
                                 optional: true,
                                 type: String,
                                 default_value: nil)
  ]
end

.descriptionObject



24
25
26
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 24

def self.description
  "Set the Version Name of your Android project"
end

.detailsObject



28
29
30
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 28

def self.details
  "This action will set the new Version Name on your Android project."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 72

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

.outputObject



58
59
60
61
62
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 58

def self.output
  [
    ['ANDROID_NEW_VERSION_NAME', 'The new Version Name of your Android project']
  ]
end

.return_valueObject



64
65
66
# File 'lib/fastlane/plugin/android_version_manage/actions/android_set_version_name.rb', line 64

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

.run(params) ⇒ Object



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

def self.run(params)
  gradle_file_path = Helper::AndroidVersionManageHelper.get_gradle_file_path(params[:gradle_file])
  new_version_name = Helper::AndroidVersionManageHelper.get_new_version_name(gradle_file_path, params[:version_name], params[:bump_type])

  saved = Helper::AndroidVersionManageHelper.save_key_to_gradle_file(gradle_file_path, "versionName", new_version_name)

  if saved == -1
    UI.user_error!("Unable to set the Version Name in #{gradle_file_path}.")
  end

  UI.success("☝️  Android Version Name has been set to: #{new_version_name}")

  # Store the versionName in the shared hash
  Actions.lane_context[SharedValues::ANDROID_NEW_VERSION_NAME] = new_version_name
end