release_testing_setup.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. # Note: This script uses the currently checked out repo.
  15. set -xe
  16. TESTINGMODE=${1-}
  17. if [ -f "${HOME}/.cocoapods/repos" ]; then
  18. find "${HOME}/.cocoapods/repos" -type d -maxdepth 1 -exec sh -c 'pod repo remove $(basename {})' \;
  19. fi
  20. git fetch --tags --quiet origin main
  21. git checkout main
  22. # The chunk below is to determine the latest version by searching
  23. # Get the latest released tag Cocoapods-X.Y.Z for release and prerelease
  24. # testing, beta version will be excluded.
  25. # Note: If the nightly tag was not updated, check that the next release's tag
  26. # is on the main branch.
  27. test_version=$(git tag -l --sort=-version:refname --merged main 'CocoaPods-*[0-9]' | head -n 1)
  28. if [ -z "$test_version" ]; then
  29. echo "Latest tag could not be found. Exiting." >&2
  30. exit 1
  31. fi
  32. git config --global user.email "google-oss-bot@example.com"
  33. git config --global user.name "google-oss-bot"
  34. git checkout "${podspec_repo_branch}"
  35. # Ensure the tag version including pod version to avoid warnings.
  36. # https://github.com/CocoaPods/Core/blob/e6451e172c33f3aa77a3f8baa7b6b5b8c3b5da14/lib/cocoapods-core/specification/linter.rb#L372-L374
  37. pod_testing_version=`echo "${test_version}" | sed "s/CocoaPods-//"`
  38. if [ "$TESTINGMODE" = "release_testing" ]; then
  39. git checkout "${test_version}"
  40. echo "Podspecs tags of Nightly release testing will be updated to ${test_version}."
  41. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  42. # ":tag => 'CocoaPods-7.9.0'"
  43. sed -i "" "s/\s*:tag.*/:tag => '${test_version}'/" *.podspec
  44. sed -i "" "s/s\.version[[:space:]]*=.*/s\.version='${pod_testing_version}'/" *.podspec
  45. elif [ "$TESTINGMODE" = "prerelease_testing" ]; then
  46. tag_version="${test_version}.nightly"
  47. echo "A new tag, ${tag_version}, for prerelease testing will be created."
  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}" > /dev/null 2>&1
  52. set -e
  53. git tag -f -a "${tag_version}" -m "release testing"
  54. git push origin "${tag_version}" > /dev/null 2>&1 || echo "Push failed due to expired or insufficient token."
  55. # Update source and tag, e.g. ":tag => 'CocoaPods-' + s.version.to_s" to
  56. # ":tag => ${test_version}.nightly"
  57. sed -i "" "s/\s*:tag.*/:tag => '${tag_version}'/" *.podspec
  58. sed -i "" "s/s\.version[[:space:]]*=.*/s\.version='${pod_testing_version}'/" *.podspec
  59. fi