Skip to content

Commit

Permalink
Use named block parameters in new_hotfix_release lane (#13947)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokagio authored Sep 13, 2024
2 parents ca239d5 + 7138e16 commit 6cc6bb1
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -387,42 +387,38 @@ platform :ios do
# bundle exec fastlane new_hotfix_release skip_confirm:true version:10.6.1
#####################################################################################
desc 'Creates a new hotfix branch for the given version:x.y.z. The branch will be cut from the tag x.y of the previous release'
lane :new_hotfix_release do |options|
lane :new_hotfix_release do |version:, skip_confirm: false|
# Verify that there's nothing in progress in the working copy
ensure_git_status_clean

new_version = options[:version] || UI.input('Version number for the new hotfix?')

# Parse the provided version into an AppVersion object
parsed_version = VERSION_FORMATTER.parse(new_version)
parsed_version = VERSION_FORMATTER.parse(version)
build_code_hotfix = BUILD_CODE_FORMATTER.build_code(version: parsed_version)
previous_version = VERSION_FORMATTER.release_version(VERSION_CALCULATOR.previous_patch_version(version: parsed_version))

# Check versions
UI.important <<-MESSAGE
New hotfix version: #{new_version}
New hotfix version: #{version}
New build code: #{build_code_hotfix}
Branching from tag: #{previous_version}
MESSAGE
unless options[:skip_confirm] || UI.confirm('Do you want to continue?')
UI.user_error!("Terminating as requested. Don't forget to run the remainder of this automation manually.")
end
UI.user_error!("Terminating as requested. Don't forget to run the remainder of this automation manually.") unless skip_confirm || UI.confirm('Do you want to continue?')

# Check tags
UI.user_error!("Version #{new_version} already exists! Abort!") if git_tag_exists(tag: new_version)
UI.user_error!("Version #{version} already exists! Abort!") if git_tag_exists(tag: version)
UI.user_error!("Version #{previous_version} is not tagged! A hotfix branch cannot be created.") unless git_tag_exists(tag: previous_version)

# Create the hotfix branch
UI.message('Creating hotfix branch...')
Fastlane::Helper::GitHelper.create_branch("release/#{new_version}", from: previous_version)
Fastlane::Helper::GitHelper.create_branch("release/#{version}", from: previous_version)
UI.success("Done! New hotfix branch is: #{git_branch}")

# Bump the hotfix version and build code and write it to the `xcconfig` file
UI.message('Bumping hotfix version and build code...')
VERSION_FILE.write(
version_short: new_version,
version_short: version,
version_long: build_code_hotfix
)
commit_version_bump
Expand Down

0 comments on commit 6cc6bb1

Please sign in to comment.