Class: Fastlane::Actions::VersionBumpPodspecAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/version_bump_podspec.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, lane_context, method_missing, other_action, return_value, sample_return_value, sh, step_text

Class Method Details

.authorsObject



70
71
72
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 70

def self.authors
  ["Liquidsoul", "KrauseFx"]
end

.available_optionsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 41

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FL_VERSION_BUMP_PODSPEC_PATH",
                                 description: "You must specify the path to the podspec file to update",
                                 default_value: Dir["*.podspec"].last,
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass a path to the `version_bump_podspec` action") if value.length == 0
                                 end),
    FastlaneCore::ConfigItem.new(key: :bump_type,
                                 env_name: "FL_VERSION_BUMP_PODSPEC_BUMP_TYPE",
                                 description: "The type of this version bump. Available: patch, minor, major",
                                 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_number,
                                 env_name: "FL_VERSION_BUMP_PODSPEC_VERSION_NUMBER",
                                 description: "Change to a specific version. This will replace the bump type value",
                                 optional: true)
  ]
end

.categoryObject



85
86
87
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 85

def self.category
  :misc
end

.descriptionObject



30
31
32
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 30

def self.description
  "Increment or set the version in a podspec file"
end

.detailsObject



34
35
36
37
38
39
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 34

def self.details
  [
    "You can use this action to manipulate any 'version' variable contained in a ruby file.",
    "For example, you can use it to bump the version of a cocoapods' podspec file."
  ].join("\n")
end

.example_codeObject



78
79
80
81
82
83
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 78

def self.example_code
  [
    'version = version_bump_podspec(path: "TSMessages.podspec", bump_type: "patch")',
    'version = version_bump_podspec(path: "TSMessages.podspec", version_number: "1.4")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 74

def self.is_supported?(platform)
  [:ios, :mac].include? platform
end

.outputObject



64
65
66
67
68
# File 'lib/fastlane/actions/version_bump_podspec.rb', line 64

def self.output
  [
    ['PODSPEC_VERSION_NUMBER', 'The new podspec version number']
  ]
end

.run(params) ⇒ Object



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

def self.run(params)
  podspec_path = params[:path]

  UI.user_error!("Could not find podspec file at path #{podspec_path}") unless File.exist? podspec_path

  version_podspec_file = Helper::PodspecHelper.new(podspec_path)

  if params[:version_number]
    new_version = params[:version_number]
  else
    new_version = version_podspec_file.bump_version(params[:bump_type])
  end

  version_podspec_file.update_podspec(new_version)

  Actions.lane_context[SharedValues::PODSPEC_VERSION_NUMBER] = new_version
end