Skip to content

Commit 75fd868

Browse files
authored
Update Podfile.lock when upgrading phc (#946)
We added Podfile.lock to be able to use iOS caches in dbd26a3 But we were not updating the file when updating phc I added a private function that will update the Pod, with a retry, because it's possible the Pod is not distributed yet
1 parent a87c277 commit 75fd868

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

fastlane/Fastfile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package_name = 'react-native-purchases'
2121
changelog_latest_path = './CHANGELOG.latest.md'
2222
changelog_path = './CHANGELOG.md'
2323
versions_path = './VERSIONS.md'
24+
sample_path = 'examples/purchaseTesterTypescript'
2425

2526
before_all do
2627
setup_circle_ci
@@ -123,7 +124,7 @@ lane :build_example do |options|
123124
Dir.chdir(get_root_folder) do
124125
sh("yarn")
125126
end
126-
Dir.chdir(File.expand_path('examples/purchaseTesterTypescript', get_root_folder)) do
127+
Dir.chdir(File.expand_path(sample_path, get_root_folder)) do
127128
sh("npx pod-install")
128129
end
129130
end
@@ -161,6 +162,10 @@ lane :update_hybrid_common do |options|
161162
# Update `yarn.lock` too
162163
sh('yarn install --no-immutable')
163164
commit_current_changes(commit_message: 'Update yarn.lock')
165+
166+
# This will update both PurchasesHybridCommonUI and PurchasesHybridCommon
167+
update_sample_podfile_lock_with_retry('PurchasesHybridCommonUI')
168+
164169
push_to_git_remote(set_upstream: true)
165170
end
166171

@@ -245,7 +250,7 @@ end
245250

246251
def parse_pod_version
247252
Dir.chdir(get_root_folder) do
248-
return sh("cat examples/purchaseTesterTypescript/ios/Podfile.lock | grep \' Purchases (=\' | awk \'{print($4)}\' | sed \"s/)//g\"").strip
253+
return sh("cat #{sample_path}/ios/Podfile.lock | grep \' Purchases (=\' | awk \'{print($4)}\' | sed \"s/)//g\"").strip
249254
end
250255
end
251256

@@ -262,3 +267,24 @@ def check_no_git_tag_exists(version_number)
262267
raise "git tag with version #{version_number} already exists!"
263268
end
264269
end
270+
271+
def update_sample_podfile_lock_with_retry(pod_name)
272+
retry_attempts = 4 # Total of 4 retries, with the first attempt considered, equals 5 attempts over 20 minutes
273+
Dir.chdir(File.expand_path("#{sample_path}/ios", get_root_folder)) do
274+
begin
275+
UI.message("ℹ️ Updating Podfile.lock with new version for #{pod_name}")
276+
sh("pod update #{pod_name}")
277+
commit_current_changes(commit_message: "Update Podfile.lock for #{pod_name}")
278+
rescue => e
279+
if retry_attempts > 0
280+
UI.message("⚠️ Failed to update Podfile.lock for #{pod_name}: #{e.message}")
281+
UI.message("⚠️ Retrying in 5 minutes...")
282+
sleep(300) # wait for 5 minutes
283+
retry_attempts -= 1
284+
retry
285+
else
286+
UI.message("⚠️ Final attempt to update Podfile.lock for #{pod_name} failed. It's possible the pod has not been distributed yet. Proceeding without update.")
287+
end
288+
end
289+
end
290+
end

0 commit comments

Comments
 (0)