Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use named block parameters in new_hotfix_release lane #13947

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading