Skip to content
Snippets Groups Projects
Unverified Commit a667aa8e authored by Manish R Jain's avatar Manish R Jain Committed by GitHub
Browse files

Simplify the release process (#2458)

Create a simple script to do the release. This script should only be doing the release, and nothing else (testing, uploading, etc.).
parent e0de7b5d
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
# This script is used to compile and tar gzip the release binaries so that they
# can be uploaded to Github. It would typically only be used by Dgraph developers
# while doing a new release. If you are looking to build Dgraph, you should run a
# go build from inside $GOPATH/src/github.com/dgraph-io/dgraph/cmd/dgraph
# Exit script in case an error is encountered.
set -e
echo -e "\n\n Downloading xgo"
go get github.com/karalabe/xgo
platform=$1
asset_suffix=$2
cur_dir=$(pwd);
tmp_dir=/tmp/dgraph-build;
release_version=$(git describe --abbrev=0);
if [[ -n $asset_suffix ]]; then
release_version="$release_version${asset_suffix}"
fi
# TODO - Add checksum file later when we support get.dgraph.io for Windows.
# If temporary directory already exists delete it.
if [ -d "$tmp_dir" ]; then
rm -rf $tmp_dir
fi
mkdir $tmp_dir;
source $GOPATH/src/github.com/dgraph-io/dgraph/contrib/nightly/constants.sh
pushd $GOPATH/src/github.com/dgraph-io/dgraph/dgraph > /dev/null
if [[ $platform == "windows" ]]; then
xgo_target="windows/amd64"
else
xgo_target="darwin-10.9/amd64"
fi
echo -e "\n\n\033[1;33mBuilding binaries for $platform\033[0m"
xgo --go 1.10.x --targets $xgo_target -ldflags \
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime'" .;
echo -e "\n\033[1;33mCopying binaries to tmp folder\033[0m"
if [[ $platform == "windows" ]]; then
mv dgraph-windows-4.0-amd64.exe $tmp_dir/dgraph.exe
else
mv dgraph-darwin-10.9-amd64 $tmp_dir/dgraph
fi
pushd $ratel
echo -e "\033[1;33mBuilding ratel binary for $platform\033[0m"
if [[ $platform == "windows" ]]; then
GOOS=windows GOARCH=amd64 go build -ldflags \
"-X $ratel_release=$release_version" -o dgraph-ratel.exe .
mv dgraph-ratel.exe $tmp_dir
else
GOOS=darwin GOARCH=amd64 go build -ldflags \
"-X $ratel_release=$release_version" -o dgraph-ratel .
mv dgraph-ratel $tmp_dir
fi
popd
echo -e "\n\033[1;34mSize of files: $(du -sh $tmp_dir)\033[0m"
echo -e "\n\033[1;33mCreating tar file\033[0m"
tar_file=dgraph-"$platform"-amd64.tar.gz
# Create a tar file with the contents of the dgraph folder (i.e the binaries)
if [[ $platform == "windows" ]]; then
tar -zcvf $tar_file -C $tmp_dir .
else
checksum=$(shasum -a 256 $tmp_dir/dgraph | awk '{print $1}')
echo "$checksum /usr/local/bin/dgraph" >> $cur_dir/"dgraph-checksum-darwin-amd64.sha256"
checksum=$(shasum -a 256 $tmp_dir/dgraph-ratel | awk '{print $1}')
echo "$checksum /usr/local/bin/dgraph-ratel" >> $cur_dir/"dgraph-checksum-darwin-amd64.sha256"
tar -zcvf $tar_file -C $tmp_dir .
fi
echo -e "\n\033[1;34mSize of tar file: $(du -sh $tar_file)\033[0m"
echo -e "\n\033[1;33mMoving tarfile to original directory\033[0m"
mv $tar_file $cur_dir
rm -rf $tmp_dir
#!/bin/bash
set -e
lastCommitSHA1=$(git rev-parse --short HEAD);
gitBranch=$(git rev-parse --abbrev-ref HEAD)
lastCommitTime=$(git log -1 --format=%ci)
dgraph_cmd=$GOPATH/src/github.com/dgraph-io/dgraph/dgraph;
ratel_release="github.com/dgraph-io/ratel/server.ratelVersion"
release="github.com/dgraph-io/dgraph/x.dgraphVersion"
branch="github.com/dgraph-io/dgraph/x.gitBranch"
commitSHA1="github.com/dgraph-io/dgraph/x.lastCommitSHA"
commitTime="github.com/dgraph-io/dgraph/x.lastCommitTime"
ratel=$GOPATH/src/github.com/dgraph-io/ratel;
#!/bin/bash
# Script to do Dgraph release. This script would output the built binaries in
# $TMP. This script should NOT be responsible for doing any testing, or
# uploading to any server. The sole task of this script is to build the
# binaries and prepare them such that any human or script can then pick these up
# and use them as they deem fit.
# Don't use standard GOPATH. Create a new one.
GOPATH="/tmp/go"
rm -Rf $GOPATH
mkdir $GOPATH
TAG=$1
TMP="/tmp/build"
rm -Rf $TMP
mkdir $TMP
if [ -z "$TAG" ]; then
echo "Must specify which tag to build for."
exit 1
fi
echo "Building Dgraph for tag: $TAG"
# Stop on first failure.
set -e
set -o xtrace
# Check for existence of strip tool.
type strip
type shasum
ratel_release="github.com/dgraph-io/ratel/server.ratelVersion"
release="github.com/dgraph-io/dgraph/x.dgraphVersion"
branch="github.com/dgraph-io/dgraph/x.gitBranch"
commitSHA1="github.com/dgraph-io/dgraph/x.lastCommitSHA"
commitTime="github.com/dgraph-io/dgraph/x.lastCommitTime"
echo "Using Go version"
go version
go get -u github.com/jteeuwen/go-bindata/...
go get -d -u golang.org/x/net/context
go get -d google.golang.org/grpc
go get -u github.com/prometheus/client_golang/prometheus
go get -u github.com/dgraph-io/dgo
# go get github.com/stretchr/testify/require
go get -u github.com/karalabe/xgo
pushd $GOPATH/src/google.golang.org/grpc
git checkout v1.13.0
popd
basedir=$GOPATH/src/github.com/dgraph-io
# Clone Dgraph repo.
pushd $basedir
git clone git@github.com:dgraph-io/dgraph.git
popd
pushd $basedir/dgraph
git pull
git checkout $TAG
# HEAD here points to whatever is checked out.
lastCommitSHA1=$(git rev-parse --short HEAD);
gitBranch=$(git rev-parse --abbrev-ref HEAD)
lastCommitTime=$(git log -1 --format=%ci)
release_version=$(git describe --abbrev=0);
popd
# Clone ratel repo.
pushd $basedir
git clone git@github.com:dgraph-io/ratel.git
popd
pushd $basedir/ratel
git pull
source ~/.nvm/nvm.sh
nvm install --lts
./scripts/build.prod.sh
popd
# Build Windows.
pushd $basedir/dgraph/dgraph
xgo --targets=windows/amd64 -ldflags \
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime'" .
mkdir $TMP/windows
mv dgraph-windows-4.0-amd64.exe $TMP/windows/dgraph.exe
popd
pushd $basedir/ratel
xgo --targets=windows/amd64 -ldflags "-X $ratel_release=$release_version" .
mv ratel-windows-4.0-amd64.exe $TMP/windows/dgraph-ratel.exe
popd
# Build Darwin.
pushd $basedir/dgraph/dgraph
xgo --targets=darwin-10.9/amd64 -ldflags \
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime'" .
mkdir $TMP/darwin
mv dgraph-darwin-10.9-amd64 $TMP/darwin/dgraph
popd
pushd $basedir/ratel
xgo --targets=darwin-10.9/amd64 -ldflags "-X $ratel_release=$release_version" .
mv ratel-darwin-10.9-amd64 $TMP/darwin/dgraph-ratel
popd
# Build Linux.
pushd $basedir/dgraph/dgraph
xgo --targets=linux/amd64 -ldflags \
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime'" .
strip -x dgraph-linux-amd64
mkdir $TMP/linux
mv dgraph-linux-amd64 $TMP/linux/dgraph
popd
pushd $basedir/ratel
xgo --targets=linux/amd64 -ldflags "-X $ratel_release=$release_version" .
strip -x ratel-linux-amd64
mv ratel-linux-amd64 $TMP/linux/dgraph-ratel
popd
createSum () {
os=$1
echo "Creating checksum for $os"
pushd $TMP/$os
csum=$(shasum -a 256 dgraph | awk '{print $1}')
echo $csum /usr/local/bin/dgraph >> ../dgraph-checksum-$os-amd64.sha256
csum=$(shasum -a 256 dgraph-ratel | awk '{print $1}')
echo $csum /usr/local/bin/dgraph-ratel >> ../dgraph-checksum-$os-amd64.sha256
popd
}
createSum darwin
createSum linux
createTar () {
os=$1
echo "Creating tar for $os"
pushd $TMP/$os
tar -zcvf ../dgraph-$os-amd64.tar.gz *
popd
rm -Rf $TMP/$os
}
createTar windows
createTar darwin
createTar linux
echo "Release $TAG is ready."
ls -alh $TMP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment