Class: Fastlane::Actions::IncrementVersionCodeAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::IncrementVersionCodeAction
- Defined in:
- lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb
Overview
Action to increment version code in gradle.properties
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
- .return_value ⇒ Object
Class Method Summary collapse
Class Method Details
.authors ⇒ Object
73 74 75 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 73 def self. ['quebin31'] end |
.available_options ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 48 def self. [ FastlaneCore::ConfigItem.new(key: :version_code, env_name: 'FL_INCREMENT_VERSION_CODE_VERSION_CODE', description: 'Value for version code', optional: true, skip_type_validation: true), FastlaneCore::ConfigItem.new(key: :project_dir, env_name: 'FL_INCREMENT_VERSION_CODE_PROJECT_DIR', description: 'Android project dir', is_string: true, default_value: '.') ] end |
.description ⇒ Object
40 41 42 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 40 def self.description 'Increment version code for Android in gradle.properties' end |
.details ⇒ Object
44 45 46 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 44 def self.details "The updated value is located in the property 'version.code' inside gradle.properties file" end |
.get_version_code(contents) ⇒ Object
31 32 33 34 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 31 def self.get_version_code(contents) extracted_version = contents.match(/^\s*version\.code\s*=\s*(\S+)/)&.[](1) || '0' extracted_version.to_i + 1 end |
.is_supported?(platform) ⇒ Boolean
77 78 79 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 77 def self.is_supported?(platform) platform == :android end |
.output ⇒ Object
63 64 65 66 67 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 63 def self.output [ ['INCREMENT_VERSION_CODE_VALUE', 'The new version code value'] ] end |
.return_value ⇒ Object
69 70 71 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 69 def self.return_value 'The incremented version code value' end |
.run(params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_version_code_action.rb', line 12 def self.run(params) project_dir = params[:project_dir] properties_file = File.join(project_dir, 'gradle.properties') properties_contents = File.read(properties_file) version_code = params[:version_code] version_code = get_version_code(properties_contents) if blank?(version_code) version_code = [version_code.to_i, 1].max updated_contents = properties_contents.gsub!(/^\s*version\.code\s*=\s*\S+/, "version.code=#{version_code}") updated_contents = properties_contents + "\nversion.code=#{version_code}" if blank?(updated_contents) # noinspection RubyMismatchedArgumentType File.write(properties_file, updated_contents) Actions.lane_context[SharedValues::INCREMENT_VERSION_CODE_VALUE] = version_code end |