dist command to make binaries and package them for distribution
This commit is contained in:
parent
c6375e414d
commit
cc2457f7d5
|
@ -12,3 +12,4 @@ remote_dump
|
||||||
vendor
|
vendor
|
||||||
.vagrant
|
.vagrant
|
||||||
test/p2p/data/
|
test/p2p/data/
|
||||||
|
.glide
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -16,6 +16,10 @@ build:
|
||||||
build_race:
|
build_race:
|
||||||
go build -race -o build/tendermint ./cmd/tendermint
|
go build -race -o build/tendermint ./cmd/tendermint
|
||||||
|
|
||||||
|
# dist builds binaries for all platforms and packages them for distribution
|
||||||
|
dist:
|
||||||
|
@BUILD_TAGS='$(BUILD_TAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
@echo "--> Running go test"
|
@echo "--> Running go test"
|
||||||
@go test $(PACKAGES)
|
@go test $(PACKAGES)
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "Please specify a version."
|
||||||
|
exit 1
|
||||||
|
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"
|
||||||
|
|
||||||
|
# Generate the tag.
|
||||||
|
if [ -z "$NOTAG" ]; then
|
||||||
|
echo "==> Tagging..."
|
||||||
|
git commit --allow-empty -a -m "Release v$VERSION"
|
||||||
|
git tag -a -m "Version $VERSION" "v${VERSION}" master
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# Add "tendermint" and $VERSION prefix to package name.
|
||||||
|
for FILENAME in $(find ./build/dist -mindepth 1 -maxdepth 1 -type f); do
|
||||||
|
FILENAME=$(basename "$FILENAME")
|
||||||
|
mv "./build/dist/${FILENAME}" "./build/dist/tendermint_${VERSION}_${FILENAME}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Make the checksums.
|
||||||
|
pushd ./build/dist
|
||||||
|
shasum -a256 ./* > "./tendermint_${VERSION}_SHA256SUMS"
|
||||||
|
popd
|
||||||
|
|
||||||
|
# Done
|
||||||
|
echo
|
||||||
|
echo "==> Results:"
|
||||||
|
ls -hl ./build/dist
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# Get the git commit
|
||||||
|
GIT_COMMIT="$(git rev-parse --short HEAD)"
|
||||||
|
GIT_DESCRIBE="$(git describe --tags --always)"
|
||||||
|
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"}
|
||||||
|
|
||||||
|
# Delete the old dir
|
||||||
|
echo "==> Removing old directory..."
|
||||||
|
rm -rf build/dist/*
|
||||||
|
mkdir -p build/dist
|
||||||
|
|
||||||
|
# Make sure build tools are available.
|
||||||
|
make tools
|
||||||
|
|
||||||
|
# Get VENDORED dependencies
|
||||||
|
make get_vendor_deps
|
||||||
|
|
||||||
|
# Build!
|
||||||
|
echo "==> Building..."
|
||||||
|
"$(which gox)" \
|
||||||
|
-os="${XC_OS}" \
|
||||||
|
-arch="${XC_ARCH}" \
|
||||||
|
-osarch="!darwin/arm !solaris/amd64 !freebsd/amd64" \
|
||||||
|
-ldflags "-X ${GIT_IMPORT}.GitCommit='${GIT_COMMIT}' -X ${GIT_IMPORT}.GitDescribe='${GIT_DESCRIBE}'" \
|
||||||
|
-output "build/dist/{{.OS}}_{{.Arch}}/tendermint" \
|
||||||
|
-tags="${BUILD_TAGS}" \
|
||||||
|
github.com/tendermint/tendermint/cmd/tendermint
|
||||||
|
|
||||||
|
# Zip all the files.
|
||||||
|
echo "==> Packaging..."
|
||||||
|
for PLATFORM in $(find ./build/dist -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
|
||||||
|
|
||||||
|
# Remove build/dist/{{.OS}}_{{.Arch}} directories.
|
||||||
|
rm -rf build/dist/*/
|
||||||
|
|
||||||
|
exit 0
|
|
@ -0,0 +1,12 @@
|
||||||
|
FROM golang:1.7.4
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
zip \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# We want to ensure that release builds never have any cgo dependencies so we
|
||||||
|
# switch that off at the highest level.
|
||||||
|
ENV CGO_ENABLED 0
|
||||||
|
|
||||||
|
RUN mkdir -p $GOPATH/src/github.com/tendermint/tendermint
|
||||||
|
WORKDIR $GOPATH/src/github.com/tendermint/tendermint
|
Loading…
Reference in New Issue