collect_all_artifacts.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. set -ex
  3. # Change to repo root.
  4. cd $(dirname $0)/../..
  5. # Initialize any submodules.
  6. git submodule update --init --recursive
  7. # The directory with all resulting artifacts
  8. mkdir -p artifacts
  9. # Artifacts from all predecessor jobs get copied to this directory by kokoro
  10. INPUT_ARTIFACTS_DIR="${KOKORO_GFILE_DIR}/github/protobuf"
  11. # TODO(jtattermusch): remove listing the files, but for now it make it easier
  12. # to iterate on the script.
  13. ls -R ${INPUT_ARTIFACTS_DIR}
  14. # ====================================
  15. # Copy to expose all the artifacts from the predecessor jobs to the output
  16. # TODO(jtattermusch): the directory layout of the artifact builds is pretty messy,
  17. # so will be the output artifacts of this job.
  18. cp -r ${INPUT_ARTIFACTS_DIR}/* artifacts
  19. # ====================================
  20. # Build Google.Protobuf.Tools C# nuget
  21. # The reason it's being done in this script is that we need access to protoc binaries
  22. # built on multiple platform (the build is performed by the "build artifact" step)
  23. # and adding and extra chained build just for building the Google.Protobuf.Tools
  24. # nuget seems like an overkill.
  25. cd csharp
  26. mkdir -p protoc/windows_x86
  27. mkdir -p protoc/windows_x64
  28. cp ${INPUT_ARTIFACTS_DIR}/build32/Release/protoc.exe protoc/windows_x86/protoc.exe
  29. cp ${INPUT_ARTIFACTS_DIR}/build64/Release/protoc.exe protoc/windows_x64/protoc.exe
  30. mkdir -p protoc/linux_x86
  31. mkdir -p protoc/linux_x64
  32. # Because of maven unrelated reasonse the linux protoc binaries have a dummy .exe extension.
  33. # For the Google.Protobuf.Tools nuget, we don't want that exception, so we just remove it.
  34. cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_32/protoc.exe protoc/linux_x86/protoc
  35. cp ${INPUT_ARTIFACTS_DIR}/protoc-artifacts/target/linux/x86_64/protoc.exe protoc/linux_x64/protoc
  36. mkdir -p protoc/macosx_x64
  37. cp ${INPUT_ARTIFACTS_DIR}/build64/src/protoc protoc/macosx_x64/protoc
  38. # Install nuget (will also install mono)
  39. # TODO(jtattermusch): use "mono:5.14" docker image instead so we don't have to apt-get install
  40. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  41. echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
  42. sudo apt update
  43. sudo apt-get install -y nuget
  44. nuget pack Google.Protobuf.Tools.nuspec
  45. # Copy the nupkg to the output artifacts
  46. cp Google.Protobuf.Tools.*.nupkg ../artifacts