class Fastlane::Actions::BumpAndroidVersionAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb, line 45 def self.available_options [ 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()
click to toggle source
# File lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb, line 28 def self.description "Bump Android Manifest Version" end
details()
click to toggle source
# 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)
click to toggle source
# 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()
click to toggle source
# 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)
click to toggle source
# File lib/fastlane/plugin/bump_android_version/actions/bump_android_version_action.rb, line 4 def self.run(params) UI.message("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.message("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.message("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