github.com/btcsuite/btcd@v0.24.0/release/release.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright (c) 2016 Company 0, LLC.
     4  # Copyright (c) 2016-2020 The btcsuite developers
     5  # Use of this source code is governed by an ISC
     6  # license that can be found in the LICENSE file.
     7  
     8  # Simple bash script to build basic btcd tools for all the platforms we support
     9  # with the golang cross-compiler.
    10  
    11  set -e
    12  
    13  # If no tag specified, use date + version otherwise use tag.
    14  if [[ $1x = x ]]; then
    15      DATE=`date +%Y%m%d`
    16      VERSION="01"
    17      TAG=$DATE-$VERSION
    18  else
    19      TAG=$1
    20  fi
    21  
    22  go mod vendor
    23  tar -cvzf vendor.tar.gz vendor
    24  
    25  PACKAGE=btcd
    26  MAINDIR=$PACKAGE-$TAG
    27  mkdir -p $MAINDIR
    28  
    29  cp vendor.tar.gz $MAINDIR/
    30  rm vendor.tar.gz
    31  rm -r vendor
    32  
    33  PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar"
    34  git archive -o $PACKAGESRC HEAD
    35  gzip -f $PACKAGESRC > "$PACKAGESRC.gz"
    36  
    37  cd $MAINDIR
    38  
    39  # If BTCDBUILDSYS is set the default list is ignored. Useful to release
    40  # for a subset of systems/architectures.
    41  SYS=${BTCDBUILDSYS:-"
    42          darwin-amd64
    43          dragonfly-amd64
    44          freebsd-386
    45          freebsd-amd64
    46          freebsd-arm
    47          illumos-amd64
    48          linux-386
    49          linux-amd64
    50          linux-armv6
    51          linux-armv7
    52          linux-arm64
    53          linux-ppc64
    54          linux-ppc64le
    55          linux-mips
    56          linux-mipsle
    57          linux-mips64
    58          linux-mips64le
    59          linux-s390x
    60          netbsd-386
    61          netbsd-amd64
    62          netbsd-arm
    63          netbsd-arm64
    64          openbsd-386
    65          openbsd-amd64
    66          openbsd-arm
    67          openbsd-arm64
    68          solaris-amd64
    69          windows-386
    70          windows-amd64
    71  "}
    72  
    73  # Use the first element of $GOPATH in the case where GOPATH is a list
    74  # (something that is totally allowed).
    75  PKG="github.com/btcsuite/btcd"
    76  COMMIT=$(git describe --abbrev=40 --dirty)
    77  
    78  for i in $SYS; do
    79      OS=$(echo $i | cut -f1 -d-)
    80      ARCH=$(echo $i | cut -f2 -d-)
    81      ARM=
    82  
    83      if [[ $ARCH = "armv6" ]]; then
    84        ARCH=arm
    85        ARM=6
    86      elif [[ $ARCH = "armv7" ]]; then
    87        ARCH=arm
    88        ARM=7
    89      fi
    90  
    91      mkdir $PACKAGE-$i-$TAG
    92      cd $PACKAGE-$i-$TAG
    93  
    94      echo "Building:" $OS $ARCH $ARM
    95      env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/btcsuite/btcd
    96      env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/btcsuite/btcd/cmd/btcctl
    97      cd ..
    98  
    99      if [[ $OS = "windows" ]]; then
   100  	zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG
   101      else
   102  	tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG
   103      fi
   104  
   105      rm -r $PACKAGE-$i-$TAG
   106  done
   107  
   108  shasum -a 256 * > manifest-$TAG.txt