build-release 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh -e
  2. VER=$1
  3. PROJ="etcd"
  4. if [ -z "$1" ]; then
  5. echo "Usage: ${0} VERSION" >> /dev/stderr
  6. exit 255
  7. fi
  8. set -u
  9. function setup_env {
  10. local proj=${1}
  11. local ver=${2}
  12. if [ ! -d ${proj} ]; then
  13. git clone https://github.com/coreos/${proj}
  14. fi
  15. pushd ${proj} >/dev/null
  16. git checkout master
  17. git fetch --all
  18. git reset --hard origin/master
  19. git checkout $ver
  20. popd >/dev/null
  21. }
  22. function package {
  23. local target=${1}
  24. local srcdir="${2}/bin"
  25. local ccdir="${srcdir}/${GOOS}_${GOARCH}"
  26. if [ -d ${ccdir} ]; then
  27. srcdir=${ccdir}
  28. fi
  29. local ext=""
  30. if [ ${GOOS} == "windows" ]; then
  31. ext=".exe"
  32. fi
  33. for bin in etcd etcdctl; do
  34. cp ${srcdir}/${bin} ${target}/${bin}${ext}
  35. done
  36. cp etcd/README.md ${target}/README.md
  37. cp etcd/etcdctl/README.md ${target}/README-etcdctl.md
  38. cp -R etcd/Documentation ${target}/Documentation
  39. }
  40. function main {
  41. mkdir release
  42. cd release
  43. setup_env ${PROJ} ${VER}
  44. for os in darwin windows linux; do
  45. export GOOS=${os}
  46. export GOARCH="amd64"
  47. pushd etcd >/dev/null
  48. ./build
  49. popd >/dev/null
  50. TARGET="etcd-${VER}-${GOOS}-${GOARCH}"
  51. mkdir ${TARGET}
  52. package ${TARGET} ${PROJ}
  53. if [ ${GOOS} == "linux" ]; then
  54. tar cfz ${TARGET}.tar.gz ${TARGET}
  55. echo "Wrote release/${TARGET}.tar.gz"
  56. else
  57. zip -qr ${TARGET}.zip ${TARGET}
  58. echo "Wrote release/${TARGET}.zip"
  59. fi
  60. done
  61. }
  62. main