Skip to content

Instantly share code, notes, and snippets.

@ryparker
Last active March 25, 2021 21:28
Show Gist options
  • Save ryparker/ef07d0f23a6a2be7ba28c7700c7aed7b to your computer and use it in GitHub Desktop.
Save ryparker/ef07d0f23a6a2be7ba28c7700c7aed7b to your computer and use it in GitHub Desktop.
Fastlane `Bump` lane
desc "Bumps the version and build number on the project"
desc "#### Example:"
desc "```\nfastlane ios bump version:2.0.1 build_number:23\n```"
desc "#### Options"
desc " * **`version`**: The version to set in the Info.plist (`CFBundleShortVersionString`)"
desc " * **`build_number`**: The build number to set in the Info.plist (`CFBundleVersion`)"
desc ""
lane :bump do |options|
# Prompt version number
version = nil
loop do
version = options[:version] || UI.input("Version?")
break if version && !version.empty?
end
# Prompt build number
build_number = options[:build_number] || UI.input("Build number (defaults to current timestamp)?")
build_number = Time.now.to_i if build_number.nil? || build_number.empty?
# Update plist with new version and build number
update_info_plist(
xcodeproj: 'Test.xcodeproj',
plist_path: 'Test/Info.plist',
block: proc do |plist|
plist["CFBundleShortVersionString"] = version
plist["CFBundleVersion"] = build_number
end
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment