bundle-plugins-for-release.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. # Copyright 2020, gRPC Authors All rights reserved.
  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 -eu
  16. # This script bundles up the gRPC and Protobuf protoc plugins into a zip file
  17. # suitable for the 'gRPC-Swift-Plugins' CocoaPod.
  18. #
  19. # The contents of thie zip should look like this:
  20. #
  21. # ├── LICENSE
  22. # └── bin
  23. # ├── protoc-gen-grpc-swift
  24. # └── protoc-gen-swift
  25. if [[ $# -lt 1 ]]; then
  26. echo "Usage: $0 RELEASE_VERSION"
  27. exit 1
  28. fi
  29. version=$1
  30. zipfile="protoc-grpc-swift-plugins-${version}.zip"
  31. # Where are we?
  32. here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  33. # The root of the repo is just above us.
  34. root="${here}/.."
  35. # Make a staging area.
  36. stage=$(mktemp -d)
  37. stage_bin="${stage}/bin"
  38. mkdir -p "${stage_bin}"
  39. # Make the plugins.
  40. swift build -c release --arch arm64 --arch x86_64 --product protoc-gen-grpc-swift
  41. swift build -c release --arch arm64 --arch x86_64 --product protoc-gen-swift
  42. binpath=$(swift build -c release --arch arm64 --arch x86_64 --show-bin-path)
  43. # Copy them to the stage.
  44. cp "${binpath}/protoc-gen-grpc-swift" "${stage_bin}"
  45. cp "${binpath}/protoc-gen-swift" "${stage_bin}"
  46. # Copy the LICENSE to the stage.
  47. cp "${root}/LICENSE" "${stage}"
  48. # Zip it up.
  49. pushd "${stage}" || exit
  50. zip -r "${zipfile}" .
  51. popd || exit
  52. # Tell us where it is.
  53. echo "Created ${stage}/${zipfile}"