release_testing_setup.sh 3.3 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. # 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. if [ "$TESTINGMODE" = "release_testing" ]; then
  22. mkdir -p "${local_sdk_repo_dir}"
  23. echo "git clone from github.com/firebase/firebase-ios-sdk.git to ${local_sdk_repo_dir}"
  24. set +x
  25. # Using token here to update tags later.
  26. git clone -q https://"${BOT_TOKEN}"@github.com/firebase/firebase-ios-sdk.git "${local_sdk_repo_dir}"
  27. set -x
  28. cd "${local_sdk_repo_dir}"
  29. elif [ "$TESTINGMODE" = "prerelease_testing" ]; then
  30. git fetch --tags --quiet origin main
  31. fi
  32. # The chunk below is to determine the latest version by searching
  33. # Get the latest released tag Cocoapods-X.Y.Z for release and prerelease testing, beta version will be excluded.
  34. test_version=$(git tag -l --sort=-version:refname --merged main 'CocoaPods-*[0-9]' | head -n 1)
  35. git for-each-ref --sort=-creatordate --format '%(creatordate:short) %(refname:short)' refs/tags | head -n 3
  36. if [ -z "$test_version" ]; then
  37. echo "Latest tag could not be found. Exiting." >&2
  38. exit 1
  39. fi
  40. git config --global user.email "google-oss-bot@example.com"
  41. git config --global user.name "google-oss-bot"
  42. git checkout "${podspec_repo_branch}"
  43. # Ensure the tag version including pod version to avoid warnings.
  44. # https://github.com/CocoaPods/Core/blob/e6451e172c33f3aa77a3f8baa7b6b5b8c3b5da14/lib/cocoapods-core/specification/linter.rb#L372-L374
  45. pod_testing_version=`echo "${test_version}" | sed "s/CocoaPods-//"`
  46. if [ "$TESTINGMODE" = "release_testing" ]; then
  47. git checkout "${test_version}"
  48. echo "Podspecs tags of Nightly release testing will be updated to ${test_version}."
  49. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  50. # ":tag => 'CocoaPods-7.9.0'"
  51. sed -i "" "s/\s*:tag.*/:tag => '${test_version}'/" *.podspec
  52. sed -i "" "s/s\.version[[:space:]]*=.*/s\.version='${pod_testing_version}'/" *.podspec
  53. elif [ "$TESTINGMODE" = "prerelease_testing" ]; then
  54. tag_version="${test_version}.nightly"
  55. echo "A new tag, ${tag_version}, for prerelease testing will be created."
  56. set +e
  57. # If tag_version is new to the remote, remote cannot delete a non-existent
  58. # tag, so error is allowed here.
  59. git push origin --delete "${tag_version}" > /dev/null 2>&1
  60. set -e
  61. git tag -f -a "${tag_version}" -m "release testing"
  62. git push origin "${tag_version}" > /dev/null 2>&1 || echo "Push failed due to expired or insufficient token."
  63. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  64. # ":tag => ${test_version}.nightly"
  65. sed -i "" "s/\s*:tag.*/:tag => '${tag_version}'/" *.podspec
  66. sed -i "" "s/s\.version[[:space:]]*=.*/s\.version='${pod_testing_version}'/" *.podspec
  67. fi