build-release 873 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/sh -e
  2. VER=$1
  3. function build {
  4. proj=${1}
  5. ver=${2}
  6. if [ ! -d ${proj} ]; then
  7. git clone https://github.com/coreos/${proj}
  8. fi
  9. cd ${proj}
  10. git checkout master
  11. git fetch --all
  12. git reset --hard origin/master
  13. git checkout $ver
  14. ./build
  15. cd -
  16. }
  17. function package {
  18. proj=${1}
  19. target=${2}
  20. ccdir="${proj}/bin/${GOOS}_${GOARCH}"
  21. if [ -d ${ccdir} ]; then
  22. cp ${ccdir}/${proj}* ${target}
  23. else
  24. cp ${proj}/bin/${proj} ${target}
  25. fi
  26. cp ${proj}/README.md ${target}/README-${proj}.md
  27. }
  28. mkdir release
  29. cd release
  30. for i in darwin windows linux; do
  31. export GOOS=${i}
  32. export GOARCH="amd64"
  33. build etcd ${VER}
  34. build etcdctl ${VER}
  35. TARGET="etcd-${VER}-${GOOS}-${GOARCH}"
  36. mkdir ${TARGET}
  37. package etcd ${TARGET}
  38. package etcdctl ${TARGET}
  39. if [ ${GOOS} == "linux" ]; then
  40. tar cvvfz ${TARGET}.tar.gz ${TARGET}
  41. else
  42. zip -r ${TARGET}.zip ${TARGET}
  43. fi
  44. done