Class: Fastlane::Actions::IncrementVersionNumberAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::IncrementVersionNumberAction
- Defined in:
- lib/fastlane/actions/increment_version_number.rb
Class Method Summary collapse
- .author ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .run(params) ⇒ Object
Methods inherited from Fastlane::Action
Class Method Details
.author ⇒ Object
124 125 126 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 124 def self. "serluca" end |
.available_options ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 92 def self. [ FastlaneCore::ConfigItem.new(key: :bump_type, env_name: "FL_VERSION_NUMBER_BUMP_TYPE", description: "The type of this version bump. Available: patch, minor, major", default_value: "patch", verify_block: Proc.new do |value| raise "Available values are 'patch', 'minor' and 'major'" unless ['patch', 'minor', 'major'].include?value end), FastlaneCore::ConfigItem.new(key: :version_number, env_name: "FL_VERSION_NUMBER_VERSION_NUMBER", description: "Change to a specific version. This will replace the bump type value", optional: true, verify_block: Proc.new do |value| raise "Invalid version '#{value}' given. Must be x.y.z".red unless value.split(".").count == 3 end), FastlaneCore::ConfigItem.new(key: :xcodeproj, env_name: "FL_VERSION_NUMBER_PROJECT", description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory", verify_block: Proc.new do |value| raise "Please pass the path to the project, not the workspace".red if value.include?"workspace" raise "Could not find Xcode project".red unless File.exists?(value) end) ] end |
.description ⇒ Object
80 81 82 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 80 def self.description "Increment the version number of your project" end |
.details ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 84 def self.details [ "This action will increment the version number. ", "You first have to set up your Xcode project, if you haven't done it already:", "https://developer.apple.com/library/ios/qa/qa1827/_index.html" ].join(' ') end |
.is_supported?(platform) ⇒ Boolean
10 11 12 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 10 def self.is_supported?(platform) platform == :ios end |
.output ⇒ Object
118 119 120 121 122 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 118 def self.output [ ['VERSION_NUMBER', 'The new version number'] ] end |
.run(params) ⇒ Object
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fastlane/actions/increment_version_number.rb', line 14 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 begin folder = '.' #Current folder is the default folder command_prefix = [ 'cd', File.(folder).shellescape, '&&' ].join(' ') if Helper.test? version_array = [1,0,0] else current_version = `#{command_prefix} agvtool what-marketing-version -terse1`.split("\n").last raise 'Your current version (#{current_version}) does not respect the format A.B.C' unless current_version.match(/\d.\d.\d/) # Check if CFBundleShortVersionString is the same for each occurrence allBundles = `#{command_prefix} agvtool what-marketing-version -terse`.split("\n") allBundles.each do |bundle| raise 'Ensure all you CFBundleShortVersionString are equals in your project ' unless bundle.end_with? "=#{current_version}" end version_array = current_version.split(".").map(&:to_i) end if params[:version_number] # Specific version next_version_number = params[:version_number] else case params[:bump_type] when "patch" version_array[2] = version_array[2] + 1 next_version_number = version_array.join(".") when "minor" version_array[1] = version_array[1] + 1 version_array[2] = version_array[2] = 0 next_version_number = version_array.join(".") when "major" version_array[0] = version_array[0] + 1 version_array[1] = version_array[1] = 0 version_array[1] = version_array[2] = 0 next_version_number = version_array.join(".") when "specific_version" next_version_number = specific_version_number end end command = [ command_prefix, "agvtool new-marketing-version #{next_version_number}" ].join(' ') if Helper.test? Actions.lane_context[SharedValues::VERSION_NUMBER] = command else Actions.sh command Actions.lane_context[SharedValues::VERSION_NUMBER] = next_version_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 |