Browse Source

scripts for building

pull/1780/head
Ethan Buchman 8 years ago
parent
commit
b86da57571
5 changed files with 144 additions and 1 deletions
  1. +12
    -1
      Makefile
  2. +12
    -0
      scripts/abci-builder/Dockerfile
  3. +53
    -0
      scripts/dist.sh
  4. +60
    -0
      scripts/dist_build.sh
  5. +7
    -0
      scripts/publish.sh

+ 12
- 1
Makefile View File

@ -1,4 +1,6 @@
.PHONY: all build test fmt lint get_deps
GOTOOLS = \
github.com/mitchellh/gox \
github.com/Masterminds/glide
all: protoc install test
@ -17,6 +19,10 @@ install:
build:
@ go build -i github.com/tendermint/abci/cmd/...
dist:
@ sudo bash scripts/dist.sh
@ bash scripts/publish.sh
# test.sh requires that we run the installed cmds, must not be out of date
test: install
find . -path ./vendor -prune -o -name *.sock -exec rm {} \;
@ -37,6 +43,11 @@ test_integrations: get_vendor_deps install test
get_deps:
@ go get -d `${NOVENDOR}`
tools:
go get -u -v $(GOTOOLS)
get_vendor_deps:
@ go get github.com/Masterminds/glide
@ glide install
.PHONY: all build test fmt lint get_deps tools

+ 12
- 0
scripts/abci-builder/Dockerfile View File

@ -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/abci
WORKDIR $GOPATH/src/github.com/tendermint/abci

+ 53
- 0
scripts/dist.sh View File

@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -e
REPO_NAME="abci"
# 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)
fi
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/${REPO_NAME}-builder scripts/${REPO_NAME}-builder/
docker run --rm -e "BUILD_TAGS=$BUILD_TAGS" -v "$(pwd)":/go/src/github.com/tendermint/${REPO_NAME} tendermint/${REPO_NAME}-builder ./scripts/dist_build.sh
# Add $REPO_NAME and $VERSION prefix to package name.
rm -rf ./build/dist
mkdir -p ./build/dist
for FILENAME in $(find ./build/pkg -mindepth 1 -maxdepth 1 -type f); do
FILENAME=$(basename "$FILENAME")
cp "./build/pkg/${FILENAME}" "./build/dist/${REPO_NAME}_${VERSION}_${FILENAME}"
done
# Make the checksums.
pushd ./build/dist
shasum -a256 ./* > "./${REPO_NAME}_${VERSION}_SHA256SUMS"
popd
# Done
echo
echo "==> Results:"
ls -hl ./build/dist
exit 0

+ 60
- 0
scripts/dist_build.sh View File

@ -0,0 +1,60 @@
#!/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/abci/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/pkg
mkdir -p build/pkg
# Make sure build tools are available.
make tools
# Get VENDORED dependencies
make get_vendor_deps
BINARIES=( "abci-cli" "dummy" "counter" )
for binary in ${BINARIES[@]}; do
# 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/pkg/{{.OS}}_{{.Arch}}/$binary" \
-tags="${BUILD_TAGS}" \
github.com/tendermint/abci/cmd/$binary
# 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
done
exit 0

+ 7
- 0
scripts/publish.sh View File

@ -0,0 +1,7 @@
#! /bin/bash
# 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)
fi
aws s3 cp --recursive build/dist s3://tendermint/binaries/abci/v${VERSION} --acl public-read

Loading…
Cancel
Save