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



47
48
49
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 47

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

.available_optionsObject



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

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :build_number,
      env_name: "BUILD_NUMBER",
      description: "Build number to be set to the .xcconfig",
      optional: true,
      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



18
19
20
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 18

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 51

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

.outputObject



43
44
45
# File 'lib/fastlane/plugin/yalantis_ci/actions/build_number_set_to_xcconfig.rb', line 43

def self.output
  []
end

.run(options) ⇒ Object



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

def self.run(options)
  build_number = options[:build_number] || Actions.lane_context[SharedValues::BUILD_NUMBER]
  path = options[:xcconfig_path]

  if build_number.nil?
    UI.error("build_number can't be nil")
  else
    contents = File.readlines(path).join.gsub!(/(?<=\bCURRENT_PROJECT_VERSION\s=\s)([\d]+)/, build_number.to_s)
    File.write(path, contents) unless contents.nil?
  end
end