Skip to content

Commit 9bb6870

Browse files
authored
Add check for zipfile to "update C++ SDK" workflow. (#9761)
Also modify the workflow to accept version numbers without leading 'v'.
1 parent acbd85d commit 9bb6870

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

.github/workflows/update-cpp-sdk-on-release.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,41 @@ jobs:
4141

4242
- name: Ensure Cocoapods repo has been updated
4343
run: |
44-
# If the new version is simply vX.Y.Z, wait up to an hour for its podspec to be present.
45-
if [[ "$GITHUB_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
46-
echo "Checking Cocoapods repo for associated Firebase ${GITHUB_REF:1} podspec."
47-
podspec_url="https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/${GITHUB_REF:1}/Firebase.podspec.json"
44+
# If the new version is simply vX.Y.Z or X.Y.Z, wait up to an hour each for its podspec and prebuilt zip file to be present.
45+
if [[ "$GITHUB_REF" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
46+
version=$(echo "$GITHUB_REF" | sed s/^v//) # remove leading v if present
47+
echo "Checking Cocoapods repo for associated Firebase ${version} podspec."
48+
podspec_url="https://github.com/CocoaPods/Specs/blob/master/Specs/0/3/5/Firebase/${version}/Firebase.podspec.json"
4849
for retry in {1..12} error; do
4950
# Check every 5 minutes, up to an hour, for the new podspec to be present.
5051
# If it's still not present, trigger the update anyway.
5152
if [[ $retry == "error" ]]; then
52-
echo "::warning ::Firebase ${GITHUB_REF:1} podspec not found, updating anyway."
53+
echo "::warning ::Firebase ${version} podspec not found, updating anyway."
5354
exit 0
5455
fi
5556
echo -n "Check ${podspec_url} (attempt ${retry}) ..."
56-
curl -L -f -o /dev/null "${podspec_url}" 2> /dev/null && echo " success!" && break
57+
curl -H 'Authorization: token ${{ github.token }}' -L -f -o /dev/null "${podspec_url}" 2> /dev/null && echo " success!" && break
58+
echo " failed."
59+
sleep 300
60+
done
61+
echo "Checking firebase-ios-sdk repo for ${version} prebuilt zip."
62+
# Check for the zip file on this actual release URL (which might include the leading v)
63+
zipfile_url="https://github.com/firebase/firebase-ios-sdk/releases/download/${GITHUB_REF}/Firebase.zip"
64+
for retry in {1..12} error; do
65+
# Check every 5 minutes, up to an hour, for the new zip file to be present.
66+
# If it's still not present, trigger the update anyway.
67+
if [[ $retry == "error" ]]; then
68+
echo "::warning ::Firebase ${version} zip file not found, updating anyway."
69+
exit 0
70+
fi
71+
echo -n "Check ${zipfile_url} (attempt ${retry}) ..."
72+
# curl's "-r 0-0" option means only download the first byte, this prevents us from downloading 300+ MB.
73+
curl -H 'Authorization: token ${{ github.token }}' -L -f -o /dev/null -r 0-0 "${zipfile_url}" 2> /dev/null && echo " success!" && break
5774
echo " failed."
5875
sleep 300
5976
done
6077
else
61-
echo "Tag '$GITHUB_REF' doesn't match the 'vX.Y.Z' format, skipping Cocoapods repo check."
78+
echo "Tag '$GITHUB_REF' doesn't match the 'vX.Y.Z' or 'X.Y.Z' format, skipping Cocoapods repo and release zip check."
6279
fi
6380
6481
- name: Trigger firebase-cpp-sdk update

0 commit comments

Comments
 (0)