check_protobuf_pod_version.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Copyright 2019 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -ex
  16. cd `dirname $0`/../..
  17. # get the version of protobuf in /third_party/protobuf
  18. pushd third_party/protobuf
  19. version1=$(git describe --tags | cut -f 1 -d'-')
  20. v1=${version1:1}
  21. popd
  22. # get the version of protobuf in /src/objective-c/!ProtoCompiler.podspec
  23. v2=$(cat src/objective-c/\!ProtoCompiler.podspec | egrep "v = " | cut -f 2 -d"'")
  24. # get the version of protobuf in /src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
  25. v3=$(cat src/objective-c/\!ProtoCompiler-gRPCPlugin.podspec | egrep 'dependency.*!ProtoCompiler' | cut -f 4 -d"'")
  26. # compare and emit error
  27. ret=0
  28. if [ $v1 != $v2 ]; then
  29. echo 'Protobuf version in src/objective-c/!ProtoCompiler.podspec does not match protobuf version in third_party/protobuf.'
  30. ret=1
  31. fi
  32. if [ $v1 != $v3 ]; then
  33. echo 'Protobuf version in src/objective-c/!ProtoCompiler-gRPCPlugin.podspec does not match protobuf version in third_party/protobuf.'
  34. ret=1
  35. fi
  36. exit $ret