release_testing_setup.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2020 Google LLC
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # This script will `git clone` the SDK repo to local and look for the latest
  15. # release branch
  16. set -xe
  17. TESTINGMODE=${1-}
  18. if [ -f "${HOME}/.cocoapods/repos" ]; then
  19. find "${HOME}/.cocoapods/repos" -type d -maxdepth 1 -exec sh -c 'pod repo remove $(basename {})' \;
  20. fi
  21. mkdir -p "${local_sdk_repo_dir}"
  22. echo "git clone ${podspec_repo_branch} from github.com/firebase/firebase-ios-sdk.git to ${local_sdk_repo_dir}"
  23. set +x
  24. # Using token here to update tags later.
  25. git clone -q https://"${BOT_TOKEN}"@github.com/firebase/firebase-ios-sdk.git "${local_sdk_repo_dir}"
  26. set -x
  27. cd "${local_sdk_repo_dir}"
  28. # The chunk below is to determine the latest version by searching
  29. # Cocoapods-X.Y.Z tags from all branches of the sdk repo and test_version is X.Y.Z
  30. test_version=$(git tag -l --sort=-version:refname CocoaPods-*[0-9] | head -n 1 | sed -n 's/CocoaPods-//p')
  31. # Check if release-X.Y.Z branch exists in the remote repo.
  32. release_branch=$(git branch -r -l "origin/release-${test_version}")
  33. if [ -z $release_branch ];then
  34. echo "release-${test_version} branch does not exist in the sdk repo."
  35. # Get substring before the last ".", e.g. "release-7.0.0" -> "release-7.0"
  36. minor_test_version=${test_version%.*}
  37. echo "search for release-${minor_test_version} branch."
  38. release_branch=$(git branch -r -l "origin/release-${minor_test_version}")
  39. if [ -z $release_branch ];then
  40. echo "release-${minor_test_version} branch does not exist in the sdk repo."
  41. exit 1
  42. fi
  43. fi
  44. if [ -z $podspec_repo_branch ];then
  45. # Get release branch, origin/release-X.Y.Z.
  46. podspec_repo_branch=$(echo $release_branch | sed -n 's/\s*//p')
  47. fi
  48. git config --global user.email "google-oss-bot@example.com"
  49. git config --global user.name "google-oss-bot"
  50. git checkout "${podspec_repo_branch}"
  51. if [ "$TESTINGMODE" = "release_testing" ]; then
  52. # Latest Cocoapods tag on the repo, e.g. Cocoapods-7.9.0
  53. latest_cocoapods_tag=$(git tag -l --sort=-version:refname CocoaPods-*[0-9] | head -n 1 )
  54. echo "Podspecs tags of Nightly release testing will be updated to ${latest_cocoapods_tag}."
  55. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  56. # ":tag => 'CocoaPods-7.9.0'"
  57. sed -i "" "s/\s*:tag.*/:tag => '${latest_cocoapods_tag}'/" *.podspec
  58. elif [ "$TESTINGMODE" = "prerelease_testing" ]; then
  59. tag_version="CocoaPods-${test_version}.nightly"
  60. echo "A new tag, ${tag_version},for prerelease testing will be created."
  61. set +e
  62. # If tag_version is new to the remote, remote cannot delete a non-existent
  63. # tag, so error is allowed here.
  64. git push origin --delete "${tag_version}"
  65. set -e
  66. git tag -f -a "${tag_version}" -m "release testing"
  67. git push origin "${tag_version}"
  68. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  69. # ":tag => test"
  70. sed -i "" "s/\s*:tag.*/:tag => '${tag_version}'/" *.podspec
  71. fi