Skip to content

Commit 019fa3e

Browse files
committed
IOS-2532 Fix version pattern matching and hotfix tag resolution in FastfileDeploy
1 parent 181493c commit 019fa3e

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

fastlane/FastfileDeploy

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,22 @@ platform :ios do
107107
# For incremental builds (e.g., 0.41.0/26 -> 0.41.0/27), use the previous build number
108108
old_tag_name = "#{prefix}/#{version}/#{build_number.to_i - 1}"
109109
else
110-
# For the first build of a new version (e.g., 0.41.1/1), find the last tag of the previous version
111-
# Get all tags for the current major version (e.g., all 0.41.x tags), sorted by version
112-
all_version_tags = sh("git tag -l '#{prefix}/#{version.split('.')[0]}.*/*' | sort -V").split("\n")
113-
114-
# Find the index of the current version in the sorted list
115-
current_idx = all_version_tags.index { |t| t.start_with?("#{prefix}/#{version}/") }
116-
# Use the tag immediately before the current version, or fallback to current tag if not found
117-
old_tag_name = current_idx && current_idx > 0 ? all_version_tags[current_idx - 1] : tag_name
110+
# For the first build of a new version (e.g., 0.41.1/1), find the last tag of the previous patch version
111+
# Get major.minor version (e.g., "0.41" from "0.41.1")
112+
version_parts = version.split('.')
113+
major_minor = "#{version_parts[0]}.#{version_parts[1]}"
114+
current_patch = version_parts[2].to_i
115+
116+
# Get all tags for the current major.minor (e.g., all 0.41.x tags), sorted by version
117+
all_version_tags = sh("git tag -l '#{prefix}/#{major_minor}.*/*' | sort -V").split("\n")
118+
119+
# Find tags for versions less than current patch, take the last one
120+
previous_version_tags = all_version_tags.select do |t|
121+
tag_patch = t.match(/#{Regexp.escape(prefix)}\/#{Regexp.escape(major_minor)}\.(\d+)\//)
122+
tag_patch && tag_patch[1].to_i < current_patch
123+
end
124+
125+
old_tag_name = previous_version_tags.last || tag_name
118126
end
119127

120128
add_linear_comment(

0 commit comments

Comments
 (0)