Class: Fastlane::Actions::FivIncrementBuildNoAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 50

def self.authors
  ["Gary Großgarten"]
end

.available_optionsObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 64

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ios,
                            env_name: "FIV_INCREMENT_BUILD_NO_IOS",
                         description: "---",
                            optional: false,
                                type: Boolean),
    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



46
47
48
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 46

def self.description
  "fastlane plugin for ionic 4"
end

.detailsObject



59
60
61
62
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 59

def self.details
  # Optional:
  ""
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
88
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 82

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



54
55
56
57
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 54

def self.return_value
  "returns the new build number"

end

.run(params) ⇒ Object



7
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
36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/plugin/fiv_increment_build_no/actions/fiv_increment_build_no_action.rb', line 7

def self.run(params)
  UI.message("The fiv_increment_build_no plugin is working!")
  text = File.read("./config.xml")

  isIos = params[:ios]
  if (isIos)
    app_build_number = sh "echo \"cat //*[local-name()='widget']/@ios-CFBundleVersion\" | xmllint --shell #{params[:pathToConfigXML]}|  awk -F'[=\"]' '!/>/{print $(NF-1)}'"
    puts app_build_number.length

    if(app_build_number.length == 0)
      new_contents = text
                     .gsub(/<widget /, "<widget ios-CFBundleVersion=\"#{1}\" ")
    else
    build_number = app_build_number.to_i +  1
    new_contents = text
                     .gsub(/ios-CFBundleVersion="[0-9]*"/, "ios-CFBundleVersion=\"#{build_number}\"")
    end
  else
    app_build_number = sh "echo \"cat //*[local-name()='widget']/@android-versionCode\" | xmllint --shell #{params[:pathToConfigXML]}|  awk -F'[=\"]' '!/>/{print $(NF-1)}'"
    puts app_build_number.length


    if(app_build_number.length == 0)
      new_contents = text
                     .gsub(/<widget /, "<widget android-versionCode=\"#{1}\" ")
    else
    build_number = app_build_number.to_i +  1
    new_contents = text
                     .gsub(/android-versionCode="[0-9]*"/, "android-versionCode=\"#{build_number}\"")
    end

  end

  puts build_number

  File.open("./config.xml", "w") {|file| file.puts new_contents}    
  return build_number  
end