Skip to content

Commit b493b3c

Browse files
committed
Add hotfix version validation and check tags on remote
1 parent 26e90ba commit b493b3c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

fastlane/Fastfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,20 @@ platform :ios do
418418

419419
# Parse the provided version into an AppVersion object
420420
parsed_version = VERSION_FORMATTER.parse(version)
421+
# Validate that this is a hotfix version (must have a patch component > 0)
422+
UI.user_error!("Invalid hotfix version '#{version}'. Must include a patch number.") unless parsed_version.patch.to_i.positive?
421423
build_code_hotfix = BUILD_CODE_FORMATTER.build_code(version: parsed_version)
422424
previous_version = VERSION_FORMATTER.release_version(VERSION_CALCULATOR.previous_patch_version(version: parsed_version))
423425
previous_release_branch = "release/#{previous_version}"
424426

425427
# Determine the base for the hotfix branch: either a tag or a release branch
426-
base_ref_for_hotfix = if git_tag_exists(tag: previous_version)
428+
base_ref_for_hotfix = if git_tag_exists(tag: previous_version, remote: true)
427429
previous_version
428430
elsif Fastlane::Helper::GitHelper.branch_exists_on_remote?(branch_name: previous_release_branch)
429-
UI.message("ℹ️ Tag #{previous_version} not found. Using release branch #{previous_release_branch} as the base for hotfix instead.")
431+
UI.message("ℹ️ Tag '#{previous_version}' not found on the remote. Using release branch '#{previous_release_branch}' as the base for hotfix instead.")
430432
previous_release_branch
431433
else
432-
UI.user_error!("Neither tag #{previous_version} nor branch #{previous_release_branch} exists! A hotfix branch cannot be created.")
434+
UI.user_error!("Neither tag '#{previous_version}' nor branch '#{previous_release_branch}' exists on the remote! A hotfix branch cannot be created.")
433435
end
434436

435437
# Check versions
@@ -443,12 +445,12 @@ platform :ios do
443445
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?')
444446

445447
# Check tags
446-
UI.user_error!("Version #{version} already exists! Abort!") if git_tag_exists(tag: version)
448+
UI.user_error!("Version '#{version}' already exists on the remote! Abort!") if git_tag_exists(tag: version, remote: true)
447449

448450
# Create the hotfix branch
449-
UI.message("Creating hotfix branch from #{base_ref_for_hotfix}...")
451+
UI.message("Creating hotfix branch from '#{base_ref_for_hotfix}'...")
450452
Fastlane::Helper::GitHelper.create_branch("release/#{version}", from: base_ref_for_hotfix)
451-
UI.success("Done! New hotfix branch is: #{git_branch}")
453+
UI.success("Done! New hotfix branch is: '#{git_branch}'")
452454

453455
# Bump the hotfix version and build code and write it to the `xcconfig` file
454456
UI.message('Bumping hotfix version and build code...')
@@ -461,7 +463,7 @@ platform :ios do
461463
# Push the newly created hotfix branch
462464
push_to_git_remote(tags: false)
463465

464-
UI.success("Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}")
466+
UI.success("Done! New Release Version: '#{release_version_current}'. New Build Code: '#{build_code_current}'")
465467
end
466468

467469
# This lane finalizes the hotfix branch, triggering a release build.

0 commit comments

Comments
 (0)