@ -1,6 +1,9 @@
#!/usr/bin/env bash
set -e
# WARN: non hermetic build (people must run this script inside docker to
# produce deterministic binaries).
# Get the version from the environment, or try to figure it out.
if [ -z $VERSION ] ; then
VERSION = $( awk -F\" '/Version =/ { print $2; exit }' < version/version.go)
@ -11,22 +14,51 @@ if [ -z "$VERSION" ]; then
fi
echo " ==> Building version $VERSION ... "
# Get the parent directory of where this script is.
SOURCE = " ${ BASH_SOURCE [0] } "
while [ -h " $SOURCE " ] ; do SOURCE = " $( readlink " $SOURCE " ) " ; done
DIR = " $( cd -P " $( dirname " $SOURCE " ) /.. " && pwd ) "
# Change into that dir because we expect that.
cd " $DIR "
# Delete the old dir
echo "==> Removing old directory..."
rm -rf build/pkg
mkdir -p build/pkg
# Do a hermetic build inside a Docker container.
docker build -t tendermint/tendermint-builder scripts/tendermint-builder/
docker run --rm -e " BUILD_TAGS= $BUILD_TAGS " -v " $( pwd ) " :/go/src/github.com/tendermint/tendermint tendermint/tendermint-builder ./scripts/dist_build.sh
# Get the git commit
GIT_COMMIT = " $( git rev-parse --short= 8 HEAD) "
GIT_IMPORT = "github.com/tendermint/tendermint/version"
# Determine the arch/os combos we're building for
XC_ARCH = ${ XC_ARCH :- "386 amd64 arm" }
XC_OS = ${ XC_OS :- "solaris darwin freebsd linux windows" }
XC_EXCLUDE = ${ XC_EXCLUDE :- " darwin/arm solaris/amd64 solaris/386 solaris/arm freebsd/amd64 windows/arm " }
# Make sure build tools are available.
make get_tools
# Get VENDORED dependencies
make get_vendor_deps
# Build!
# ldflags: -s Omit the symbol table and debug information.
# -w Omit the DWARF symbol table.
echo "==> Building..."
IFS = ' ' read -ra arch_list <<< " $XC_ARCH "
IFS = ' ' read -ra os_list <<< " $XC_OS "
for arch in " ${ arch_list [@] } " ; do
for os in " ${ os_list [@] } " ; do
if [ [ " $XC_EXCLUDE " != *" $os / $arch " * ] ] ; then
echo " --> $os / $arch "
GOOS = ${ os } GOARCH = ${ arch } go build -ldflags " -s -w -X ${ GIT_IMPORT } .GitCommit= ${ GIT_COMMIT } " -tags= " ${ BUILD_TAGS } " -o " build/pkg/ ${ os } _ ${ arch } /tendermint " ./cmd/tendermint
fi
done
done
# Zip all the files.
echo "==> Packaging..."
for PLATFORM in $( find ./build/pkg -mindepth 1 -maxdepth 1 -type d) ; do
OSARCH = $( basename " ${ PLATFORM } " )
echo " --> ${ OSARCH } "
pushd " $PLATFORM " >/dev/null 2>& 1
zip " ../ ${ OSARCH } .zip " ./*
popd >/dev/null 2>& 1
done
# Add "tendermint" and $VERSION prefix to package name.
rm -rf ./build/dist