Class: Fastlane::Actions::IncrementExpoVersionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::IncrementExpoVersionAction
- Defined in:
- lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb
Overview
Action to increment version of Expo projects (in app.json)
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .output ⇒ Object
Class Method Summary collapse
- .increment_android_version_code(version_code) ⇒ Object
- .increment_ios_build_number(build_number) ⇒ Object
- .read_app_json_config ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
93 94 95 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 93 def self. ['quebin31'] end |
.available_options ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 62 def self. [ FastlaneCore::ConfigItem.new(key: :android_version_code, env_name: 'FL_INCREMENT_EXPO_VERSION_ANDROID_VERSION_CODE', description: 'Version code value for Android', optional: true, skip_type_validation: true), FastlaneCore::ConfigItem.new(key: :ios_build_number, env_name: 'FL_INCREMENT_EXPO_VERSION_IOS_BUILD_NUMBER', description: 'Build number value for iOS', optional: true, skip_type_validation: true), FastlaneCore::ConfigItem.new(key: :platform, env_name: 'FL_INCREMENT_EXPO_VERSION_PLATFORM', description: 'Platform to apply this change to (values: android, ios, both)', type: String, default_value: 'both', verify_block: proc do |value| is_valid = %w[android ios both].include?(value) UI.user_error!("Invalid platform value '#{value}'") unless is_valid end) ] end |
.description ⇒ Object
54 55 56 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 54 def self.description 'Increment version code and/or build number in app.json for Expo projects' end |
.details ⇒ Object
58 59 60 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 58 def self.details 'Increment version code (for Android) or build number (for iOS) for projects using Expo' end |
.increment_android_version_code(version_code) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 22 def self.increment_android_version_code(version_code) app_config = read_app_json_config android_config = app_config.fetch('expo', {}).fetch('android', {}) version_code = android_config.fetch('versionCode', 0) + 1 if blank?(version_code) android_config['versionCode'] = version_code Actions.lane_context[SharedValues::INCREMENT_EXPO_VERSION_ANDROID_VALUE] = version_code # noinspection RubyMismatchedArgumentType File.write('app.json', JSON.pretty_generate(app_config)) end |
.increment_ios_build_number(build_number) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 33 def self.increment_ios_build_number(build_number) app_config = read_app_json_config ios_config = app_config.fetch('expo', {}).fetch('ios', {}) build_number = (Integer(ios_config['buildNumber'], exception: false) || 0) + 1 if blank?(build_number) ios_config['buildNumber'] = build_number.to_s Actions.lane_context[SharedValues::INCREMENT_EXPO_VERSION_IOS_VALUE] = build_number.to_s # noinspection RubyMismatchedArgumentType File.write('app.json', JSON.pretty_generate(app_config)) end |
.is_supported?(platform) ⇒ Boolean
97 98 99 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 97 def self.is_supported?(platform) %i[ios android].include?(platform) end |
.output ⇒ Object
86 87 88 89 90 91 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 86 def self.output [ ['INCREMENT_EXPO_VERSION_ANDROID_VALUE', 'Android version code value'], ['INCREMENT_EXPO_VERSION_IOS_VALUE', 'iOS build number value'] ] end |
.read_app_json_config ⇒ Object
44 45 46 47 48 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 44 def self.read_app_json_config JSON.parse(File.read('app.json')) rescue StandardError {} end |
.run(params) ⇒ Object
16 17 18 19 20 |
# File 'lib/fastlane/plugin/ravn_mobile/actions/increment_expo_version_action.rb', line 16 def self.run(params) platform = params[:platform] increment_android_version_code(params[:android_version_code]) if %w[android both].include?(platform) increment_ios_build_number(params[:ios_build_number]) if %w[ios both].include?(platform) end |