Class: Fastlane::Actions::BuildNumberSetToXcconfigAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



49
50
51
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 49

def self.authors
  ["Dima Vorona", "Yalantis"]
end

.available_optionsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 25

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :build_number,
      env_name: "BUILD_NUMBER",
      description: "Build number to be set to the .xcconfig",
      type: Integer
    ),
    FastlaneCore::ConfigItem.new(
      key: :xcconfig_path,
      env_name: "BUILD_NUMBER_XCCONFIG_PATH",
      description: "Path to the xcconfig file with Build Number",
      type: String,
      verify_block: proc do |value|
        UI.user_error!("Couldn't find .xcconfig file at path '#{value}'") unless File.exist?(File.expand_path(value))
      end
    )
  ]
end

.descriptionObject



21
22
23
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 21

def self.description
  "Stores a specified Build Number in the passed xcconfig"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 53

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

.outputObject



45
46
47
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 45

def self.output
  []
end

.run(options) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 6

def self.run(options)
  build_number = options[:build_number]
  path = options[:xcconfig_path]

  File.open(path, 'r+') do |file|
    contents = file.read
    unless contents.nil?
      contents.gsub!(/(?<=\bCURRENT_PROJECT_VERSION\s=\s)([\d]+)/, build_number.to_s)

      file.truncate(0)
      file.write(contents)
    end
  end
end