release_testing_setup.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. set -xe
  15. TESTINGMODE=${1-}
  16. if [ -f "${HOME}/.cocoapods/repos" ]; then
  17. find "${HOME}/.cocoapods/repos" -type d -maxdepth 1 -exec sh -c 'pod repo remove $(basename {})' \;
  18. fi
  19. mkdir -p "${local_sdk_repo_dir}"
  20. echo "git clone ${podspec_repo_branch} from github.com/firebase/firebase-ios-sdk.git to ${local_sdk_repo_dir}"
  21. set +x
  22. git clone -q https://"${BOT_TOKEN}"@github.com/firebase/firebase-ios-sdk.git "${local_sdk_repo_dir}"
  23. set -x
  24. cd "${local_sdk_repo_dir}"
  25. # This is to search Cocoapods-X.Y.Z tags from all branches of the sdk repo and test_version is X.Y.Z
  26. test_version=$(git tag -l --sort=-version:refname CocoaPods-*[0-9] | head -n 1 | sed -n 's/CocoaPods-//p')
  27. # Check if release-X.Y.Z branch exists in the remote repo.
  28. release_branch=$(git branch -r -l "origin/release-${test_version}")
  29. if [ -z $release_branch ];then
  30. echo "release-${test_version} branch does not exist in the sdk repo."
  31. exit 1
  32. fi
  33. # Get release branch, release-X.Y.Z.
  34. podspec_repo_branch=$(echo $release_branch | sed -n 's/\s*origin\///p')
  35. git config --global user.email "google-oss-bot@example.com"
  36. git config --global user.name "google-oss-bot"
  37. if [ "$TESTINGMODE" = "nightly_testing" ]; then
  38. tag_version="nightly-test-${test_version}"
  39. echo "A new tag, ${tag_version},for nightly release testing will be created."
  40. fi
  41. if [ "$TESTINGMODE" = "RC_testing" ]; then
  42. tag_version="CocoaPods-${test_version}.nightly"
  43. echo "A new tag, ${tag_version},for prerelease testing will be created."
  44. fi
  45. # Update a tag.
  46. if [ -n "$tag_version" ]; then
  47. git checkout "${podspec_repo_branch}"
  48. set +e
  49. # If tag_version is new to the remote, remote cannot delete a non-existent
  50. # tag, so error is allowed here.
  51. git push origin --delete "${tag_version}"
  52. set -e
  53. git tag -f -a "${tag_version}" -m "release testing"
  54. git push origin "${tag_version}"
  55. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  56. # ":tag => test"
  57. sed -i "" "s/\s*:tag.*/:tag => '${tag_version}'/" *.podspec
  58. fi
  59. if [ -n "$sdk_version_config" ]; then
  60. cd "${GITHUB_WORKSPACE}/ZipBuilder"
  61. swift build
  62. # Update Pod versions.
  63. ./.build/debug/firebase-pod-updater --git-root "${local_sdk_repo_dir}" --releasing-pods "${sdk_version_config}"
  64. echo "sdk versions are updated based on ${sdk_version_config}."
  65. fi