Skip to content

Commit 779fc78

Browse files
author
Pawan Rawal
committed
Update nightly upload script to also build and update binaries for darwin
1 parent 1014364 commit 779fc78

File tree

6 files changed

+60
-59
lines changed

6 files changed

+60
-59
lines changed

contrib/nightly/build-windows.sh contrib/nightly/build-cross-platform.sh

+27-13
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ set -e
1111
echo -e "\n\n Downloading xgo"
1212
go get github.com/karalabe/xgo
1313

14-
asset_suffix=$1
14+
platform=$1
15+
asset_suffix=$2
1516
cur_dir=$(pwd);
1617
tmp_dir=/tmp/dgraph-build;
1718
release_version=$(git describe --abbrev=0);
1819
if [[ -n $asset_suffix ]]; then
1920
release_version="$release_version${asset_suffix}"
2021
fi
21-
platform="windows"
2222

2323
# TODO - Add checksum file later when we support get.dgraph.io for Windows.
2424

@@ -33,28 +33,42 @@ source $GOPATH/src/github.com/dgraph-io/dgraph/contrib/nightly/constants.sh
3333

3434
pushd $GOPATH/src/github.com/dgraph-io/dgraph/dgraph > /dev/null
3535

36-
xgo_target="windows/amd64"
36+
if [[ $platform == "windows" ]]; then
37+
xgo_target="windows/amd64"
38+
else
39+
xgo_target="darwin-10.9/amd64"
40+
fi
41+
3742
echo -e "\n\n\033[1;33mBuilding binaries for $platform\033[0m"
3843
xgo --go 1.8.3 --targets $xgo_target -ldflags \
3944
"-X $release=$release_version -X $branch=$gitBranch -X $commitSHA1=$lastCommitSHA1 -X '$commitTime=$lastCommitTime' -X $uiDir=$ui" .;
4045

41-
cp dgraph-windows-4.0-amd64.exe dgraph.exe
42-
4346
echo -e "\n\033[1;33mCopying binaries to tmp folder\033[0m"
44-
pushd $tmp_dir > /dev/null
45-
cp $GOPATH/src/github.com/dgraph-io/dgraph/dgraph/dgraph.exe .
46-
echo -e "\n\033[1;34mSize of files: $(du -sh)\033[0m"
47-
popd &> /dev/null
47+
if [[ $platform == "windows" ]]; then
48+
cp dgraph-windows-4.0-amd64.exe $tmp_dir/dgraph.exe
49+
else
50+
cp dgraph-darwin-10.9-amd64 $tmp_dir/dgraph
51+
fi
52+
53+
echo -e "\n\033[1;34mSize of files: $(du -sh $tmp_dir)\033[0m"
4854

4955
echo -e "\n\033[1;33mCreating tar file\033[0m"
50-
tar_file=dgraph-"$platform"-amd64-$release_version
56+
tar_file=dgraph-"$platform"-amd64-$release_version.tar.gz
57+
5158
# Create a tar file with the contents of the dgraph folder (i.e the binaries)
5259
pushd $tmp_dir > /dev/null
53-
tar -zcvf $tar_file.tar.gz dgraph.exe;
54-
echo -e "\n\033[1;34mSize of tar file: $(du -sh $tar_file.tar.gz)\033[0m"
60+
if [[ $platform == "windows" ]]; then
61+
tar -zcvf $tar_file dgraph.exe
62+
else
63+
checksum=$(shasum -a 256 dgraph | awk '{print $1}')
64+
echo "$checksum /usr/local/bin/dgraph" >> $cur_dir/"dgraph-checksum-darwin-amd64-$release_version".sha256
65+
tar -zcvf $tar_file dgraph
66+
fi
67+
68+
echo -e "\n\033[1;34mSize of tar file: $(du -sh $tar_file)\033[0m"
5569

5670
echo -e "\n\033[1;33mMoving tarfile to original directory\033[0m"
57-
mv $tar_file.tar.gz $cur_dir
71+
mv $tar_file $cur_dir
5872
popd > /dev/null
5973
rm -rf $tmp_dir
6074

contrib/nightly/build.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fi
4949
# Create the checksum file for dgraph binary.
5050
checksum_file=$cur_dir/"dgraph-checksum-$platform-amd64-$release_version".sha256
5151
if [ -f "$checksum_file" ]; then
52-
rm $checksum_file
52+
rm $checksum_file
53+
rm -rf $cur_dir/"dgraph-checksum-darwin-amd64-$release_version".sha256
5354
fi
5455

5556
checksum=$($digest_cmd dgraph | awk '{print $1}')
@@ -77,6 +78,7 @@ mv $tmp_dir ./
7778
GZIP=-n tar -zcf assets.tar.gz -C $GOPATH/src/github.com/dgraph-io/dgraph/dashboard/build .
7879
checksum=$($digest_cmd assets.tar.gz | awk '{print $1}')
7980
echo "$checksum /usr/local/share/dgraph/assets.tar.gz" >> $checksum_file
81+
echo "$checksum /usr/local/share/dgraph/assets.tar.gz" >> $cur_dir/"dgraph-checksum-darwin-amd64-$release_version".sha256
8082

8183
# Only run this locally.
8284
if [[ $TRAVIS != true ]]; then

contrib/nightly/upload.sh

+28-34
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ else
9292
echo "Running nightly script"
9393
fi
9494

95-
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
96-
OS="darwin"
97-
else
98-
OS="linux"
99-
fi
95+
OS="linux"
10096

10197
DGRAPH=$GOPATH/src/github.com/dgraph-io/dgraph
10298
BUILD_DIR=$DGRAPH/contrib/nightly
@@ -109,8 +105,10 @@ LATEST_TAG=$(curl -s https://api.github.com/repos/dgraph-io/dgraph/releases/late
109105
DGRAPH_COMMIT=$(git rev-parse HEAD)
110106
TAR_FILE="dgraph-${OS}-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.tar.gz"
111107
NIGHTLY_FILE="${GOPATH}/src/github.com/dgraph-io/dgraph/${TAR_FILE}"
108+
OSX_NIGHTLY_FILE="${GOPATH}/src/github.com/dgraph-io/dgraph/dgraph-darwin-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.tar.gz"
112109
SHA_FILE_NAME="dgraph-checksum-${OS}-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.sha256"
113110
SHA_FILE="${GOPATH}/src/github.com/dgraph-io/dgraph/${SHA_FILE_NAME}"
111+
OSX_SHA_FILE="${GOPATH}/src/github.com/dgraph-io/dgraph/dgraph-checksum-darwin-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.sha256"
114112
ASSETS_FILE="${GOPATH}/src/github.com/dgraph-io/dgraph/assets.tar.gz"
115113
CURRENT_BRANCH=$TRAVIS_BRANCH
116114
CURRENT_DIR=$(pwd)
@@ -176,28 +174,32 @@ upload_assets() {
176174
local name="dgraph-${OS}-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.tar.gz"
177175
update_or_create_asset $release_id $name ${NIGHTLY_FILE}
178176

177+
local name="dgraph-darwin-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.tar.gz"
178+
update_or_create_asset $release_id $name ${OSX_NIGHTLY_FILE}
179+
179180
local sha_name="dgraph-checksum-${OS}-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.sha256"
180181
update_or_create_asset $release_id $sha_name ${SHA_FILE}
181182

182-
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
183-
# As asset would be the same on both platforms, we only upload it from linux.
184-
update_or_create_asset $release_id "assets.tar.gz" ${ASSETS_FILE}
185-
update_or_create_asset $release_id $WINDOWS_TAR_NAME ${NIGHTLY_WINDOWS_FILE}
183+
local sha_name="dgraph-checksum-darwin-amd64-${DGRAPH_VERSION}${ASSET_SUFFIX}.sha256"
184+
update_or_create_asset $release_id $sha_name ${OSX_SHA_FILE}
186185

187-
# We dont want to update description programatically for version releases and commit apart from
188-
# nightly.
189-
if [[ $BUILD_TAG == "nightly" ]]; then
190-
echo 'Updating release description.'
191-
# TODO(pawan) - This fails, investigate and fix.
192-
# send_gh_api_data_request repos/${DGRAPH_REPO}/releases/${release_id} PATCH \
193-
# "{ \"force\": true, \"body\": $(get_nightly_release_body) | jq -s -c -R '.') }" \
194-
# > /dev/null
195-
#
196-
echo "Updating ${BUILD_TAG} tag to point to ${DGRAPH_COMMIT}."
197-
send_gh_api_data_request repos/${DGRAPH_REPO}/git/refs/tags/${BUILD_TAG} PATCH \
198-
"{ \"force\": true, \"sha\": \"${DGRAPH_COMMIT}\" }" \
199-
> /dev/null
200-
fi
186+
# As asset would be the same on both platforms, we only upload it from linux.
187+
update_or_create_asset $release_id "assets.tar.gz" ${ASSETS_FILE}
188+
update_or_create_asset $release_id $WINDOWS_TAR_NAME ${NIGHTLY_WINDOWS_FILE}
189+
190+
# We dont want to update description programatically for version releases and commit apart from
191+
# nightly.
192+
if [[ $BUILD_TAG == "nightly" ]]; then
193+
echo 'Updating release description.'
194+
# TODO(pawan) - This fails, investigate and fix.
195+
# send_gh_api_data_request repos/${DGRAPH_REPO}/releases/${release_id} PATCH \
196+
# "{ \"force\": true, \"body\": $(get_nightly_release_body) | jq -s -c -R '.') }" \
197+
# > /dev/null
198+
#
199+
echo "Updating ${BUILD_TAG} tag to point to ${DGRAPH_COMMIT}."
200+
send_gh_api_data_request repos/${DGRAPH_REPO}/git/refs/tags/${BUILD_TAG} PATCH \
201+
"{ \"force\": true, \"sha\": \"${DGRAPH_COMMIT}\" }" \
202+
> /dev/null
201203
fi
202204
}
203205

@@ -213,10 +215,6 @@ docker_tag() {
213215
docker_tag
214216

215217
build_docker_image() {
216-
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
217-
return 0
218-
fi
219-
220218
pushd $DGRAPH/contrib/nightly > /dev/null
221219
# Extract dgraph binary from the tar into dgraph-build folder.
222220
if [ ! -d dgraph-build ]; then
@@ -235,10 +233,6 @@ build_docker_image() {
235233
}
236234

237235
upload_docker_image() {
238-
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
239-
return 0
240-
fi
241-
242236
echo "Logging into Docker."
243237
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
244238
echo "Pushing the image"
@@ -252,10 +246,10 @@ upload_docker_image() {
252246
}
253247

254248
pushd $DGRAPH > /dev/null
249+
250+
$BUILD_DIR/build-cross-platform.sh "windows" $ASSET_SUFFIX
251+
$BUILD_DIR/build-cross-platform.sh "darwin" $ASSET_SUFFIX
255252
$BUILD_DIR/build.sh $ASSET_SUFFIX
256-
if [[ $TRAVIS_OS_NAME == "linux" ]]; then
257-
$BUILD_DIR/build-windows.sh $ASSET_SUFFIX
258-
fi
259253

260254
if [[ $DOCKER_TAG == "" ]]; then
261255
echo -e "No docker tag found. Exiting the script"

contrib/scripts/cover.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set -e
2121
# create coverage output
2222
echo 'mode: atomic' > $OUT
2323
for PKG in $(go list ./...|grep -v -E 'vendor|contrib|wiki|customtok'); do
24-
#if [[ "$TRAVIS_BRANCH" =~ master|release\/ && $TRAVIS_OS_NAME == "linux" ]]; then
24+
#if [[ "$TRAVIS_BRANCH" =~ master|release\/ ]]; then
2525
#echo "Running tests with race flag."
2626
#go test -v -race -timeout=30m -covermode=atomic -coverprofile=$TMP $PKG
2727
#else

contrib/scripts/install.sh

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
set -e
66

7-
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
8-
brew update
9-
brew install jq
10-
fi
11-
127
# Lets install the dependencies that are not vendored in anymore.
138
go get -d golang.org/x/net/context
149
go get -d google.golang.org/grpc/...

contrib/scripts/loader.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ pushd dgraph &> /dev/null
7878
dataCount="1120879"
7979
# Concat exported files to get total count.
8080
cat $(ls -t export/dgraph-1-* | head -1) $(ls -t export/dgraph-2-* | head -1) > export/dgraph-export.rdf.gz
81-
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
82-
exportCount=$(zcat < export/dgraph-export.rdf.gz | wc -l)
83-
else
84-
exportCount=$(zcat export/dgraph-export.rdf.gz | wc -l)
85-
fi
81+
exportCount=$(zcat export/dgraph-export.rdf.gz | wc -l)
8682
popd &> /dev/null
8783

8884
if [[ ! "$exportCount" -eq "$dataCount" ]]; then

0 commit comments

Comments
 (0)