|
16 | 16 |
|
17 | 17 |
|
18 | 18 | # Modify a .xcodeproj to use a specific branch.
|
19 |
| -# TODO: Update to transform from a release, as well as from `main`. |
20 | 19 |
|
21 | 20 | set -xeuo pipefail
|
22 | 21 |
|
23 | 22 | SAMPLE=$1
|
24 |
| -XCODEPROJ=${SAMPLE}/${SAMPLE}Example.xcodeproj/project.pbxproj |
| 23 | +SAMPLE_DIR=$(echo "$SAMPLE" | perl -ne 'print lc') |
| 24 | +XCODEPROJ=${SAMPLE_DIR}/${SAMPLE}Example.xcodeproj/project.pbxproj |
25 | 25 |
|
26 |
| -if grep -q "branch = main;" "$XCODEPROJ"; then |
27 |
| - sed -i "" "s#branch = main;#branch = $BRANCH_NAME;#" "$XCODEPROJ" |
| 26 | +# Regex matches SemVer `firebase-ios-sdk` dependency in project.pbxproj: |
| 27 | +# { |
| 28 | +# isa = XCRemoteSwiftPackageReference; |
| 29 | +# repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git"; |
| 30 | +# requirement = { |
| 31 | +# kind = upToNextMajorVersion; |
| 32 | +# minimumVersion = xx.yy.zz; |
| 33 | +# }; |
| 34 | +# }; |
| 35 | +REQUIREMENT_REGEX='({'\ |
| 36 | +'\s*isa = XCRemoteSwiftPackageReference;'\ |
| 37 | +'\s*repositoryURL = "https://github\.com/firebase/firebase-ios-sdk\.git";'\ |
| 38 | +'\s*requirement = {\s*)kind = upToNextMajorVersion;'\ |
| 39 | +'\s*minimumVersion = \d+\.\d+\.\d+;'\ |
| 40 | +'(\s*};'\ |
| 41 | +'\s*};)' |
28 | 42 |
|
29 |
| - # Point SPM CI to the tip of `main` of |
30 |
| - # https://github.com/google/GoogleAppMeasurement so that the release process |
31 |
| - # can defer publishing the `GoogleAppMeasurement` tag until after testing. |
32 |
| - export FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1 |
33 |
| -else |
34 |
| - echo "Failed to update quickstart's Xcode project to the current branch" |
| 43 | +# Replaces the minimumVersion requirement with a branch requirement. |
| 44 | +REPLACEMENT_REGEX="\1branch = $BRANCH_NAME;\n\t\t\t\tkind = branch;\2" |
| 45 | + |
| 46 | +# Performs the replacement using Perl. |
| 47 | +# |
| 48 | +# -0777 Enables reading all input in one go (slurp), rather than line-by-line. |
| 49 | +# -p Causes Perl to loop through the input line by line. |
| 50 | +# -i Edits the file in place. |
| 51 | +# -e Provides the expression to execute. |
| 52 | +perl -0777 -i -pe "s#$REQUIREMENT_REGEX#$REPLACEMENT_REGEX#g" "$XCODEPROJ" || { |
| 53 | + echo "Failed to update quickstart's Xcode project to the branch: $BRANCH_NAME" |
35 | 54 | exit 1
|
36 |
| -fi |
| 55 | +} |
| 56 | + |
| 57 | +# Point SPM CI to the tip of `main` of |
| 58 | +# https://github.com/google/GoogleAppMeasurement so that the release process |
| 59 | +# can defer publishing the `GoogleAppMeasurement` tag until after testing. |
| 60 | +export FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT=1 |
0 commit comments