github.com/DFWallet/tendermint-cosmos@v0.0.2/scripts/dist.sh (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  
     4  # WARN: non hermetic build (people must run this script inside docker to
     5  # produce deterministic binaries).
     6  
     7  # Get the version from the environment, or try to figure it out.
     8  if [ -z $VERSION ]; then
     9  	VERSION=$(awk -F\" 'TMCoreSemVer =/ { print $2; exit }' < version/version.go)
    10  fi
    11  if [ -z "$VERSION" ]; then
    12      echo "Please specify a version."
    13      exit 1
    14  fi
    15  echo "==> Building version $VERSION..."
    16  
    17  # Delete the old dir
    18  echo "==> Removing old directory..."
    19  rm -rf build/pkg
    20  mkdir -p build/pkg
    21  
    22  # Get the git commit
    23  VERSION := "$(shell git describe --always)"
    24  GIT_IMPORT="github.com/DFWallet/tendermint-cosmos/version"
    25  
    26  # Determine the arch/os combos we're building for
    27  XC_ARCH=${XC_ARCH:-"386 amd64 arm"}
    28  XC_OS=${XC_OS:-"solaris darwin freebsd linux windows"}
    29  XC_EXCLUDE=${XC_EXCLUDE:-" darwin/arm solaris/amd64 solaris/386 solaris/arm freebsd/amd64 windows/arm "}
    30  
    31  # Make sure build tools are available.
    32  make tools
    33  
    34  # Build!
    35  # ldflags: -s Omit the symbol table and debug information.
    36  #	         -w Omit the DWARF symbol table.
    37  echo "==> Building..."
    38  IFS=' ' read -ra arch_list <<< "$XC_ARCH"
    39  IFS=' ' read -ra os_list <<< "$XC_OS"
    40  for arch in "${arch_list[@]}"; do
    41  	for os in "${os_list[@]}"; do
    42  		if [[ "$XC_EXCLUDE" !=  *" $os/$arch "* ]]; then
    43  			echo "--> $os/$arch"
    44  			GOOS=${os} GOARCH=${arch} go build -ldflags "-s -w -X ${GIT_IMPORT}.TMCoreSemVer=${VERSION}" -tags="${BUILD_TAGS}" -o "build/pkg/${os}_${arch}/tendermint" ./cmd/tendermint
    45  		fi
    46  	done
    47  done
    48  
    49  # Zip all the files.
    50  echo "==> Packaging..."
    51  for PLATFORM in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type d); do
    52  	OSARCH=$(basename "${PLATFORM}")
    53  	echo "--> ${OSARCH}"
    54  
    55  	pushd "$PLATFORM" >/dev/null 2>&1
    56  	zip "../${OSARCH}.zip" ./*
    57  	popd >/dev/null 2>&1
    58  done
    59  
    60  # Add "tendermint" and $VERSION prefix to package name.
    61  rm -rf ./build/dist
    62  mkdir -p ./build/dist
    63  for FILENAME in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type f); do
    64    FILENAME=$(basename "$FILENAME")
    65  	cp "./build/pkg/${FILENAME}" "./build/dist/tendermint_${VERSION}_${FILENAME}"
    66  done
    67  
    68  # Make the checksums.
    69  pushd ./build/dist
    70  shasum -a256 ./* > "./tendermint_${VERSION}_SHA256SUMS"
    71  popd
    72  
    73  # Done
    74  echo
    75  echo "==> Results:"
    76  ls -hl ./build/dist
    77  
    78  exit 0