Skip to content

Commit 49c2fcd

Browse files
committed
Add hotfix version validation and check tags on remote
1 parent 96d5386 commit 49c2fcd

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
@@ -413,18 +413,20 @@ platform :ios do
413413

414414
# Parse the provided version into an AppVersion object
415415
parsed_version = VERSION_FORMATTER.parse(version)
416+
# Validate that this is a hotfix version (must have a patch component > 0)
417+
UI.user_error!("Invalid hotfix version '#{version}'. Must include a patch number.") unless parsed_version.patch.to_i.positive?
416418
build_code_hotfix = BUILD_CODE_FORMATTER.build_code(version: parsed_version)
417419
previous_version = VERSION_FORMATTER.release_version(VERSION_CALCULATOR.previous_patch_version(version: parsed_version))
418420
previous_release_branch = "release/#{previous_version}"
419421

420422
# Determine the base for the hotfix branch: either a tag or a release branch
421-
base_ref_for_hotfix = if git_tag_exists(tag: previous_version)
423+
base_ref_for_hotfix = if git_tag_exists(tag: previous_version, remote: true)
422424
previous_version
423425
elsif Fastlane::Helper::GitHelper.branch_exists_on_remote?(branch_name: previous_release_branch)
424-
UI.message("ℹ️ Tag #{previous_version} not found. Using release branch #{previous_release_branch} as the base for hotfix instead.")
426+
UI.message("ℹ️ Tag '#{previous_version}' not found on the remote. Using release branch '#{previous_release_branch}' as the base for hotfix instead.")
425427
previous_release_branch
426428
else
427-
UI.user_error!("Neither tag #{previous_version} nor branch #{previous_release_branch} exists! A hotfix branch cannot be created.")
429+
UI.user_error!("Neither tag '#{previous_version}' nor branch '#{previous_release_branch}' exists on the remote! A hotfix branch cannot be created.")
428430
end
429431

430432
# Check versions
@@ -438,12 +440,12 @@ platform :ios do
438440
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?')
439441

440442
# Check tags
441-
UI.user_error!("Version #{version} already exists! Abort!") if git_tag_exists(tag: version)
443+
UI.user_error!("Version '#{version}' already exists on the remote! Abort!") if git_tag_exists(tag: version, remote: true)
442444

443445
# Create the hotfix branch
444-
UI.message("Creating hotfix branch from #{base_ref_for_hotfix}...")
446+
UI.message("Creating hotfix branch from '#{base_ref_for_hotfix}'...")
445447
Fastlane::Helper::GitHelper.create_branch("release/#{version}", from: base_ref_for_hotfix)
446-
UI.success("Done! New hotfix branch is: #{git_branch}")
448+
UI.success("Done! New hotfix branch is: '#{git_branch}'")
447449

448450
# Bump the hotfix version and build code and write it to the `xcconfig` file
449451
UI.message('Bumping hotfix version and build code...')
@@ -456,7 +458,7 @@ platform :ios do
456458
# Push the newly created hotfix branch
457459
push_to_git_remote(tags: false)
458460

459-
UI.success("Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}")
461+
UI.success("Done! New Release Version: '#{release_version_current}'. New Build Code: '#{build_code_current}'")
460462
end
461463

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

0 commit comments

Comments
 (0)