dist.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # 1. commit to bump the version and update the changelog/readme
  3. # 2. tag that commit
  4. # 3. use dist.sh to produce tar.gz for all platforms
  5. # 4. aws s3 cp dist s3://bitly-downloads/nsq/ --recursive --include "nsq-1.2.1*" --profile bitly --acl public-read
  6. # 5. docker manifest push nsqio/nsq:latest
  7. # 6. push to nsqio/master
  8. # 7. update the release metadata on github / upload the binaries
  9. # 8. update nsqio/nsqio.github.io/_posts/2014-03-01-installing.md
  10. # 9. send release announcement emails
  11. # 10. update IRC channel topic
  12. # 11. tweet
  13. set -e
  14. DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  15. rm -rf $DIR/dist/docker
  16. mkdir -p $DIR/dist/docker
  17. GOFLAGS='-ldflags="-s -w"'
  18. version=$(awk '/const Binary/ {print $NF}' < $DIR/internal/version/binary.go | sed 's/"//g')
  19. goversion=$(go version | awk '{print $3}')
  20. echo "... running tests"
  21. ./test.sh
  22. export GO111MODULE=on
  23. for target in "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64" "freebsd/amd64" "windows/amd64"; do
  24. os=${target%/*}
  25. arch=${target##*/}
  26. echo "... building v$version for $os/$arch"
  27. BUILD=$(mktemp -d ${TMPDIR:-/tmp}/nsq-XXXXX)
  28. TARGET="nsq-$version.$os-$arch.$goversion"
  29. GOOS=$os GOARCH=$arch CGO_ENABLED=0 \
  30. make DESTDIR=$BUILD PREFIX=/$TARGET BLDFLAGS="$GOFLAGS" install
  31. pushd $BUILD
  32. sudo chown -R 0:0 $TARGET
  33. tar czvf $TARGET.tar.gz $TARGET
  34. mv $TARGET.tar.gz $DIR/dist
  35. popd
  36. make clean
  37. sudo rm -r $BUILD
  38. done
  39. rnd=$(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c10)
  40. docker buildx create --use --name nsq-$rnd
  41. docker buildx build --tag nsqio/nsq:v$version --platform linux/amd64,linux/arm64 .
  42. if [[ ! $version == *"-"* ]]; then
  43. echo "Tagging nsqio/nsq:v$version as the latest release"
  44. shas=$(docker manifest inspect nsqio/nsq:$version |\
  45. grep digest | awk '{print $2}' | sed 's/[",]//g' | sed 's/^/nsqio\/nsq@/')
  46. docker manifest create nsqio/nsq:latest $shas
  47. fi