Class: Fastlane::Actions::IncrementBuildNumberAction

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/actions/increment_build_number.rb

Class Method Summary collapse

Class Method Details

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

def self.run(params)
  # More information about how to set up your project and how it works:
  # https://developer.apple.com/library/ios/qa/qa1827/_index.html
  # Attention: This is NOT the version number - but the build number

  begin
    custom_number = (params.first rescue nil)

    command = nil
    if custom_number
      command = "agvtool new-version -all #{custom_number}"
    else
      command = 'agvtool next-version -all'
    end

    if Helper.test?
      Actions.lane_context[SharedValues::BUILD_NUMBER] = command
    else

      Actions.sh command

      # Store the new number in the shared hash
      build_number = `agvtool what-version`.split("\n").last.to_i

      Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number

    end
  rescue => ex
    Helper.log.error 'Make sure to to follow the steps to setup your Xcode project: https://developer.apple.com/library/ios/qa/qa1827/_index.html'.yellow
    raise ex
  end
end