Skip to content

Commit a8f9c16

Browse files
committed
fix: Improve fastlane auto_prod to handle existing tags gracefully
- Fix version detection to use highest semantic version instead of most recent tag - Handle existing tags in auto_prod lane without failing - Now correctly detects v1.0.0 as current version instead of v0.1.0
1 parent 0a48c6a commit a8f9c16

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

fastlane/Fastfile

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,22 +262,23 @@ platform :mac do
262262
prod_tag = "v#{version}"
263263

264264
# Check if tag already exists
265+
tag_exists = false
265266
begin
266-
existing_tag = sh("git rev-list -n 1 #{prod_tag} 2>/dev/null", log: false).strip
267-
if !existing_tag.empty?
268-
UI.user_error!("❌ Tag #{prod_tag} already exists. Use a different version or delete the existing tag.")
269-
end
267+
sh("git rev-parse --verify #{prod_tag} >/dev/null 2>&1", log: false)
268+
tag_exists = true
270269
rescue
271270
# Tag doesn't exist, which is what we want
272271
end
273272

274-
UI.message "🏷️ Creating tag: #{prod_tag}"
275-
276-
# Create and push tag
277-
sh("git tag #{prod_tag}")
278-
sh("git push origin #{prod_tag}")
279-
280-
UI.success "✅ Tag created and pushed: #{prod_tag}"
273+
if tag_exists
274+
UI.message "🏷️ Tag #{prod_tag} already exists, skipping tag creation"
275+
else
276+
UI.message "🏷️ Creating tag: #{prod_tag}"
277+
# Create and push tag
278+
sh("git tag #{prod_tag}")
279+
sh("git push origin #{prod_tag}")
280+
UI.success "✅ Tag created and pushed: #{prod_tag}"
281+
end
281282

282283
# Now run the production release
283284
sh("make prod")

0 commit comments

Comments
 (0)