forked from couchbase/sync_gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·24 lines (20 loc) · 1.15 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh -e
# This script builds the sync gateway. You can't just run "go install"
# directly, because we need to tell the Go compiler how to find the
# dependent packages (in vendor) and the gateway source code (in src)
# by setting $GOPATH.
# Set the git commit info before the build
BUILD_INFO="./src/github.com/couchbaselabs/sync_gateway/rest/git_info.go"
#tell git to ignore any local changes to git_info.go, we don't want to commit them to the repo
git update-index --assume-unchanged ${BUILD_INFO}
# Escape forward slash's so sed command does not get confused
# We use thses in feature branches e.g. feature/issue_nnn
GIT_BRANCH=`git status -b -s | sed q | sed 's/## //' | sed 's/\.\.\..*$//' | sed 's/\\//\\\\\//g'`
GIT_COMMIT=`git rev-parse HEAD`
GIT_DIRTY=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)
sed -i.bak -e 's/GitCommit.*=.*/GitCommit = "'$GIT_COMMIT'"/' $BUILD_INFO
sed -i.bak -e 's/GitBranch.*=.*/GitBranch = "'$GIT_BRANCH'"/' $BUILD_INFO
sed -i.bak -e 's/GitDirty.*=.*/GitDirty = "'$GIT_DIRTY'"/' $BUILD_INFO
export GOBIN="`pwd`/bin"
./go.sh install -v github.com/couchbaselabs/sync_gateway
echo "Success! Output is bin/sync_gateway"