Skip to content

Commit dc22d99

Browse files
authored
ci(fastlane): fix retry logic and perform a git fetch before lane (#708)
1 parent 8eef5aa commit dc22d99

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

fastlane/Fastfile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ default_platform(:ios)
66
PLIST_KEY = "CFBundleShortVersionString"
77

88
platform :ios do
9+
before_all do
10+
# Perform a fetch before inferring the next version
11+
# to reduce race conditions with simultaneous pipelines attempting to create the same tag
12+
sh('git', 'fetch', '--tags')
13+
sh('git', 'fetch')
14+
end
915
desc "Create a pre-release version by pushing a tag to GitHub, and pushing pods to CocoaPods"
1016
lane :unstable do
1117
next_version = calculate_next_canary_version
@@ -104,8 +110,8 @@ platform :ios do
104110
with_retry do
105111
begin
106112
pod_push(path: pod[:spec], allow_warnings: true, synchronous: true)
107-
rescue exception
108-
raise exception unless exception.message =~ /Unable to accept duplicate entry/i
113+
rescue StandardError => e
114+
raise e unless e.message =~ /Unable to accept duplicate entry/i
109115
UI.warn("Version already exists. Ignoring")
110116
end
111117
end
@@ -146,13 +152,13 @@ platform :ios do
146152
end
147153
end
148154

149-
def with_retry(retries=5, wait=10)
155+
def with_retry(retries=5, wait=60)
150156
begin
151157
yield
152-
rescue e
158+
rescue StandardError => e
153159
retries -= 1
154160
raise e if retries.zero?
155-
UI.error("Error occurred: #{exception}; retrying...")
161+
UI.error("Error occurred: #{e}; retrying...")
156162
sleep(wait)
157163
retry
158164
end

0 commit comments

Comments
 (0)