Skip to content

Commit a0725a3

Browse files
committed
Fix Swift header script to work with multiple URLs.
1 parent eb4b0d7 commit a0725a3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

.github/workflows/update-dependencies.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,29 @@ jobs:
127127
core_version=$(grep "pod 'Firebase/Core'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/")
128128
echo "Getting Swift header files from Firebase iOS SDK ${core_version} zip distribution"
129129
ziptmp="$(mktemp -d)"
130-
curl -H 'Authorization: token ${{ github.token }}' "https://github.com/firebase/firebase-ios-sdk/releases/download/v${core_version}/Firebase.zip" -o "${ziptmp}/Firebase.zip"
130+
# The version might be named vX.Y.Z or simply X.Y.Z, check which exists.
131+
declare -a zip_urls
132+
zip_urls=("https://github.com/firebase/firebase-ios-sdk/releases/download/v${core_version}/Firebase.zip" "https://github.com/firebase/firebase-ios-sdk/releases/download/${core_version}/Firebase.zip")
133+
for try_url in ${zip_urls[@]} error; do
134+
curl -H 'Authorization: token ${{ github.token }}' -L -f "${try_url}" -o "${ziptmp}/Firebase.zip" 2> /dev/null && break
135+
done
136+
if [[ "${try_url}" == "error" ]]; then
137+
echo "::error ::Could not download Firebase iOS prebuilt zip file."
138+
fi
131139
cd "${ziptmp}"
132140
echo "Unzipping..."
133141
unzip -q Firebase.zip '*-Swift.h'
134142
cd -
135143
# Copy all *-Swift.h header files into ios_pod/swift_headers/
136-
echo Copying headers..."
144+
echo "Copying headers..."
137145
find "${ziptmp}" -name '*-Swift.h' -print0 | xargs -0 -n 1 -J REPLACETEXT cp -f REPLACETEXT ios_pod/swift_headers/
138146
copyright_line="// Copyright $(date +%Y) Google LLC"
139147
# Add a note to each file about its source.
140148
for ios_header in ios_pod/swift_headers/*.h; do
141149
if ! grep -q "^// Copied from Firebase iOS SDK" "${ios_header}"; then
142150
sed -i~ "s|^// Generated by Apple Swift|${copyright_line}\n// Copied from Firebase iOS SDK ${core_version}.\n\n// Generated by Apple Swift|" "${ios_header}"
143151
fi
144-
python scripts/format_code.py --f "${ios_header}"
152+
python3 scripts/format_code.py --f "${ios_header}"
145153
done
146154
rm -rf ${ziptmp}
147155

0 commit comments

Comments
 (0)