Class: Fastlane::Actions::FivIncrementBuildNoAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



61
62
63
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 61

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

.available_optionsObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 74

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|
          unless File.exist?(value)
            UI.user_error!(
              'Couldnt find config.xml! Please change your path.'
            )
          end
        end,
      type: String
    )
  ]
end

.descriptionObject



57
58
59
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 57

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

.detailsObject



69
70
71
72
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 69

def self.details
  # Optional:
  ''
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


101
102
103
104
105
106
107
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 101

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



65
66
67
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 65

def self.return_value
  'returns the new build number'
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_increment_build_no.rb', line 8

def self.run(params)
  text = File.read(params[:pathToConfigXML])
  puts "test #{text}"

  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

  File.open(params[:pathToConfigXML], 'w') do |file|
    file.puts new_contents
  end
  return build_number
end