From 7b3b9374d921f27d287fa4b59da38e3d56eb5103 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 11:53:31 -0800 Subject: [PATCH 01/11] Add Analytics header update to iOS SDK update. --- .github/workflows/update-dependencies.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 956f1e092d..9181f46911 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -78,6 +78,23 @@ jobs: # iOS: Update Firestore external version to match Firestore Cocoapod version. firestore_version=$(grep "pod 'Firebase/Firestore'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") sed -i~ "s/^set(version [^)]*)/set(version CocoaPods-${firestore_version})/i" cmake/external/firestore.cmake + # iOS: Update Analytics header files, used for generating constants. + analytics_version=$(grep "pod 'Firebase/Analytics ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") + # Download the Firebase Analytics cocoapod. + podtmp=$(mktemp -d) + cd ${podtmp} + echo "platform :ios, '14.0'" > Podfile + echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile + pod repo update + pod install || true # ignore error since there is no Xcode project + declare -a header_dirs + header_dirs=(Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/*/FirebaseAnalytics.framework/Headers) + header_dir="${header_dirs[0]}" # headers should all be the same + cd - + for ios_header in FIREventNames.h FIRParameterNames.h FIRUserPropertyNames.h; do + cp -vf ${podtmp}/${header_dir}/${ios_header} analytics/ios_headers/${ios_header} + done + rm -rf ${podtmp} elif [[ ${{ github.event.inputs.updateAndroid }} -eq 1 ]]; then # Update Android only echo "Updating Android dependencies only" From c5751e102f2f18c6d9ce7dc54da0729f60b4bdd2 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 11:56:33 -0800 Subject: [PATCH 02/11] Fix script --- .github/workflows/update-dependencies.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 9181f46911..e384c3a658 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -79,10 +79,10 @@ jobs: firestore_version=$(grep "pod 'Firebase/Firestore'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") sed -i~ "s/^set(version [^)]*)/set(version CocoaPods-${firestore_version})/i" cmake/external/firestore.cmake # iOS: Update Analytics header files, used for generating constants. - analytics_version=$(grep "pod 'Firebase/Analytics ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") + analytics_version=$(grep "pod 'Firebase/Analytics'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") # Download the Firebase Analytics cocoapod. - podtmp=$(mktemp -d) - cd ${podtmp} + podtmp="$(mktemp -d)" + cd "${podtmp}" echo "platform :ios, '14.0'" > Podfile echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile pod repo update From 811e3428d4df79ff647a6bf427986463dc305deb Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:01:30 -0800 Subject: [PATCH 03/11] Change dependency updater to run on iOS. --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index e384c3a658..37a2bb5c96 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -25,7 +25,7 @@ env: jobs: update_dependencies: name: update-deps - runs-on: ubuntu-latest + runs-on: macos-latest steps: - name: Get token for firebase-workflow-trigger uses: tibdex/github-app-token@v1 From 7b2f93bef9ad96f86d14ebc3c19d417bc4f723b4 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:21:07 -0800 Subject: [PATCH 04/11] Remove explicit list of filenames --- .github/workflows/update-dependencies.yml | 42 +++++++++++++++-------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 37a2bb5c96..3ad3764f8b 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -80,21 +80,33 @@ jobs: sed -i~ "s/^set(version [^)]*)/set(version CocoaPods-${firestore_version})/i" cmake/external/firestore.cmake # iOS: Update Analytics header files, used for generating constants. analytics_version=$(grep "pod 'Firebase/Analytics'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") - # Download the Firebase Analytics cocoapod. - podtmp="$(mktemp -d)" - cd "${podtmp}" - echo "platform :ios, '14.0'" > Podfile - echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile - pod repo update - pod install || true # ignore error since there is no Xcode project - declare -a header_dirs - header_dirs=(Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/*/FirebaseAnalytics.framework/Headers) - header_dir="${header_dirs[0]}" # headers should all be the same - cd - - for ios_header in FIREventNames.h FIRParameterNames.h FIRUserPropertyNames.h; do - cp -vf ${podtmp}/${header_dir}/${ios_header} analytics/ios_headers/${ios_header} - done - rm -rf ${podtmp} + if [[ "$(uname)" == "Darwin"* ]]; then + # Unfortunately we can't just download these headers from GitHub, as + # Analytics is closed-source. If it becomes open-source, we could just + # download the header files from the iOS SDK's release branch. So instead, + # download the Firebase Analytics cocoapod (via a stub project) and get the + # header from there. + podtmp="$(mktemp -d)" + cd "${podtmp}" + echo "platform :ios, '14.0'" > Podfile + echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile + pod repo update + pod install || true # ignore error since there is no Xcode project + declare -a header_dirs + # Get all of the framework header directories from the xcframework. + header_dirs=(Pods/FirebaseAnalytics/Frameworks/FirebaseAnalytics.xcframework/*/FirebaseAnalytics.framework/Headers) + # Just use the first directory found, the headers should be the same across + # all of the frameworks. + header_dir="${header_dirs[0]}" + cd - + cd analytics/ios_headers + for ios_header in *.h; do + # Each file in this directory matches a file in the Analytics iOS SDK. + cp -vf "${podtmp}/${header_dir}/${ios_header}" . + done + cd - + rm -rf "${podtmp}" + fi elif [[ ${{ github.event.inputs.updateAndroid }} -eq 1 ]]; then # Update Android only echo "Updating Android dependencies only" From 77b79f6fd3dfc67fb04f3d900aa482c16603844e Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:25:07 -0800 Subject: [PATCH 05/11] Add explanatory logs --- .github/workflows/update-dependencies.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 3ad3764f8b..da4e4068ba 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -77,10 +77,12 @@ jobs: fi # iOS: Update Firestore external version to match Firestore Cocoapod version. firestore_version=$(grep "pod 'Firebase/Firestore'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") + echo "Setting Firestore external version to ${firestore_version}" sed -i~ "s/^set(version [^)]*)/set(version CocoaPods-${firestore_version})/i" cmake/external/firestore.cmake # iOS: Update Analytics header files, used for generating constants. analytics_version=$(grep "pod 'Firebase/Analytics'" ios_pod/Podfile | sed "s/.*'\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)'.*/\1/") if [[ "$(uname)" == "Darwin"* ]]; then + echo "Updating Analytics iOS headers from version ${analytics_version}" # Unfortunately we can't just download these headers from GitHub, as # Analytics is closed-source. If it becomes open-source, we could just # download the header files from the iOS SDK's release branch. So instead, From 97c6413abc08eedfb8890dd2015f733a4608daad Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:34:56 -0800 Subject: [PATCH 06/11] Add explanatory note to copied header files, and autoformat them. --- .github/workflows/update-dependencies.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index da4e4068ba..e8cf2de2e5 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -105,6 +105,10 @@ jobs: for ios_header in *.h; do # Each file in this directory matches a file in the Analytics iOS SDK. cp -vf "${podtmp}/${header_dir}/${ios_header}" . + # Add a note to each file about its source. + sed -i~ 's|^/// @file|// Copied from Firebase Analytics iOS SDK '${analytics_version}'.\n\n/// @file|' "${ios_header}" + rm -f "${ios_header}~" # remove backup file that sed generated + ../../scripts/gha/format_code.py --f "${ios_header}" done cd - rm -rf "${podtmp}" From 6c27c9f8ef94a5a2b81296dc182750b7167baa73 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:55:15 -0800 Subject: [PATCH 07/11] Use the github CocoaPod source. --- .github/workflows/update-dependencies.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index e8cf2de2e5..bc267fdb1d 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -90,7 +90,10 @@ jobs: # header from there. podtmp="$(mktemp -d)" cd "${podtmp}" - echo "platform :ios, '14.0'" > Podfile + # Generate a CocoaPod for Firebase/Analytics. Use the Specs.git + # source to avoid any propagation delays due to CocoaPods mirror. + echo "source 'https://github.com/CocoaPods/Specs.git'" > Podfile + echo "platform :ios, '14.0'" >> Podfile echo "pod 'Firebase/Analytics', '${analytics_version}'" >> Podfile pod repo update pod install || true # ignore error since there is no Xcode project From 307dbd89ffaf0c8493ad5ac1a563b913b8cc229b Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:57:59 -0800 Subject: [PATCH 08/11] Fix comment. --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index bc267fdb1d..824c84ccc4 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -90,7 +90,7 @@ jobs: # header from there. podtmp="$(mktemp -d)" cd "${podtmp}" - # Generate a CocoaPod for Firebase/Analytics. Use the Specs.git + # Generate a Podfile for Firebase/Analytics. Use the Specs.git # source to avoid any propagation delays due to CocoaPods mirror. echo "source 'https://github.com/CocoaPods/Specs.git'" > Podfile echo "platform :ios, '14.0'" >> Podfile From f3cb738494fc1d0280147b1365c6f2fe9cb19945 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 12:59:52 -0800 Subject: [PATCH 09/11] Fix format code call. --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 824c84ccc4..ab28dfc820 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -111,7 +111,7 @@ jobs: # Add a note to each file about its source. sed -i~ 's|^/// @file|// Copied from Firebase Analytics iOS SDK '${analytics_version}'.\n\n/// @file|' "${ios_header}" rm -f "${ios_header}~" # remove backup file that sed generated - ../../scripts/gha/format_code.py --f "${ios_header}" + python ../../scripts/format_code.py --f "${ios_header}" done cd - rm -rf "${podtmp}" From 912fb040ee8d3cab18b07935aa4d7620459272e5 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 13:06:03 -0800 Subject: [PATCH 10/11] Add note --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index ab28dfc820..09d988e408 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -87,7 +87,7 @@ jobs: # Analytics is closed-source. If it becomes open-source, we could just # download the header files from the iOS SDK's release branch. So instead, # download the Firebase Analytics cocoapod (via a stub project) and get the - # header from there. + # header from there. This will only work on macOS. podtmp="$(mktemp -d)" cd "${podtmp}" # Generate a Podfile for Firebase/Analytics. Use the Specs.git From a5ecb18f18c928627bf9368e9e84abf30f411345 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Wed, 1 Dec 2021 13:11:15 -0800 Subject: [PATCH 11/11] Quote variable. --- .github/workflows/update-dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 09d988e408..bedcc3d20c 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -109,7 +109,7 @@ jobs: # Each file in this directory matches a file in the Analytics iOS SDK. cp -vf "${podtmp}/${header_dir}/${ios_header}" . # Add a note to each file about its source. - sed -i~ 's|^/// @file|// Copied from Firebase Analytics iOS SDK '${analytics_version}'.\n\n/// @file|' "${ios_header}" + sed -i~ 's|^/// @file|// Copied from Firebase Analytics iOS SDK '"${analytics_version}"'.\n\n/// @file|' "${ios_header}" rm -f "${ios_header}~" # remove backup file that sed generated python ../../scripts/format_code.py --f "${ios_header}" done