Class: Fastlane::Actions::BumpAndroidVersionAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::BumpAndroidVersionAction
- Defined in:
- lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
32 33 34 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 32 def self. ["Seán Labastille"] end |
.available_options ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 45 def self. [ FastlaneCore::ConfigItem.new(key: :bump_version_code, env_name: "BUMP_ANDROID_VERSION_NAME", description: "If the version name should be bumped", optional: true), FastlaneCore::ConfigItem.new(key: :manifest_path, env_name: "BUMP_ANDROID_VERSION_MANIFEST_PATH", description: "The path to the AndroidManifest.xml to be bumped", optional: false, type: String) ] end |
.description ⇒ Object
28 29 30 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 28 def self.description "Bump Android Manifest Version" end |
.details ⇒ Object
40 41 42 43 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 40 def self.details # Optional: "Bumps the versionCode or versionName in AndroidManifest.xml" end |
.is_supported?(platform) ⇒ Boolean
59 60 61 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 59 def self.is_supported?(platform) [:android].include?(platform) end |
.return_value ⇒ Object
36 37 38 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 36 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb', line 4 def self.run(params) UI.("Bumping version code and version name for Android Manifest at #{File.absolute_path(params[:manifest_path])}") IO.write(File.absolute_path(params[:manifest_path]), File.open(File.absolute_path(params[:manifest_path])) do |f| manifest = f.read version_code = /android:versionCode=\"(\d+)\"/.match(manifest)[1].to_i UI.("Bumping version code from #{version_code} to #{version_code + 1}") manifest.gsub!(/android:versionCode=\"\d+\"/, "android:versionCode=\"#{version_code + 1}\"") manifest end) if params[:bump_version_code] then IO.write(File.absolute_path(params[:manifest_path]), File.open(File.absolute_path(params[:manifest_path])) do |f| manifest = f.read require 'sem_version' version_name = SemVersion.new(/android:versionName=\"(\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b)\"/.match(manifest)[1]) bumped_version = version_name.clone bumped_version.patch = (bumped_version.patch + 1) UI.("Bumping version code from #{version_name} to #{bumped_version}") manifest.gsub!(/android:versionName=\"(\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?\b)\"/, "android:versionName=\"#{bumped_version}\"") manifest end) end end |