Class: Fastlane::Actions::FivUpdateVersionAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



78
79
80
81
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 78

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

.available_optionsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 51

def self.available_options
  # Define all options your action supports. 
  
  [
    FastlaneCore::ConfigItem.new(key: :pathToConfigXML,
                            env_name: "FIV_INCREMENT_BUILD_CONFIG",
                         description: "---",
                            optional: false,
                            verify_block: proc do | value |
                              UI.user_error!("Couldnt find config.xml! Please change your path.") unless File.exist?(value)
                            end  ,
                                type: String)
  ]
end

.descriptionObject



41
42
43
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 41

def self.description
  "A short description with <= 80 characters of what this action does"
end

.detailsObject



45
46
47
48
49
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 45

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
  "You can use this action to do cool things..."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 83

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

  platform == :ios
end

.outputObject



66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 66

def self.output
  # Define the shared values you are going to provide
  # Example
  [
    ['FIV_UPDATE_VERSION_CUSTOM_VALUE', 'A description of what this value contains']
  ]
end

.return_valueObject



74
75
76
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 74

def self.return_value
  "returns the new version specified in config.xml"
end

.run(params) ⇒ Object



8
9
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
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_update_version.rb', line 8

def self.run(params)
  # fastlane will take care of reading in the parameter and fetching the environment variable:
  old_version = sh "echo \"cat //*[local-name()='widget']/@version\" | xmllint --shell #{params[:pathToConfigXML]}|  awk -F'[=\"]' '!/>/{print $(NF-1)}'"
  old_version = old_version.delete!("\n")
  puts "current version: #{old_version}"

  puts "Insert new version number, current version in config.xml is '#{old_version}' (Leave empty and press enter to skip this step): "
  new_version_number = STDIN.gets.strip
  puts "new version: #{new_version_number}"

  if new_version_number.length > 0
    puts "take new version number"
    version = new_version_number
  else
    puts "take old version number"
    version = old_version
  end

  text = File.read(params[:pathToConfigXML])

  new_contents = text
               .gsub(/version="[0-9.]*"/, "version=\"#{version}\"")
  
  File.open(params[:pathToConfigXML], "w") {|file| file.puts new_contents}

  return version

end