github.com/nsqio/nsq@v1.3.0/dist.sh (about)

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