Class: Fastlane::Actions::IncrementVersionAndTagAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



65
66
67
68
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 65

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["Your GitHub/Twitter Name"]
end

.available_optionsObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 38

def self.available_options
  # Define all options your action supports.

  # Below a few examples
  [
    FastlaneCore::ConfigItem.new(key: :version_pattern,
                                 env_name: "version_pattern", # The name of the repository
                                 description: "The version pattern (regexp)", # a short description of this parameter
                                 default_value: "v[0-9]*\.[0-9]*\.[0-9]*",
                                 optional: true)

  ]
end

.descriptionObject



28
29
30
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 28

def self.description
  "Increment the version by looking for latest version tag"
end

.detailsObject



32
33
34
35
36
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 32

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
  "The details here"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 70

def self.is_supported?(platform)
  # you can do things like
  #
  #  true
  #
  #  platform == :ios
  #
  #  [:ios, :mac].include?(platform)
  #

  platform == :ios
end

.outputObject



52
53
54
55
56
57
58
59
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 52

def self.output
  # Define the shared values you are going to provide
  # Example
  [
    ['NEW_VERSION', 'The new version'],
    ['NEW_VERSION_NUMBERS', 'The new version, only numbers and periods']
  ]
end

.return_valueObject



61
62
63
# File 'lib/fastlane/plugin/elux_actions/actions/increment_version_and_tag.rb', line 61

def self.return_value
  # If you method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



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

def self.run(params)
  # Get next version number
  cmd = "git tag --sort=v:refname | grep \"#{params[:version_pattern]}\"  | tail -1  | awk -F. '{printf(\"%s.%s.0\", $1, $2+1)}'"
  STDOUT.puts cmd
  STDOUT.flush
  version = `#{cmd}`
  Actions.lane_context[SharedValues::NEW_VERSION] = version
  Actions.lane_context[SharedValues::NEW_VERSION_NUMBERS] = version.gsub(/[a-zA-Z]/, '')

  # Create the tag
  cmd = "git tag -a \"#{version}\" -m \"Version #{version}\""
  STDOUT.puts cmd
  STDOUT.flush
end