Merge pull request #596 from ChinX/syncer-script

[SCB-1540] [Syncer] Add syncer's packaging command to the script of release
diff --git a/scripts/build/local.sh b/scripts/build/local.sh
index 869627a..487a3e1 100644
--- a/scripts/build/local.sh
+++ b/scripts/build/local.sh
@@ -42,6 +42,8 @@
 
     build_scctl
 
+    build_syncer
+
     package
 }
 
diff --git a/scripts/build/tools.sh b/scripts/build/tools.sh
index c971d65..bed602e 100644
--- a/scripts/build/tools.sh
+++ b/scripts/build/tools.sh
@@ -99,6 +99,23 @@
     cd -
 }
 
+build_syncer() {
+    local app=../$PACKAGE_PREFIX-$PACKAGE-$GOOS-$GOARCH
+    ## Build the syncer releases
+    cd syncer
+    export GIT_COMMIT=$(git log  --pretty=format:'%h' -n 1)
+    export BUILD_NUMBER=$RELEASE
+    local ldflags="${GO_LDFLAGS} -X 'github.com/apache/servicecomb-service-center/syncer/version.BUILD_TAG=$(date +%Y%m%d%H%M%S).$BUILD_NUMBER.$GIT_COMMIT'"
+    ldflags="${ldflags} -X 'github.com/apache/servicecomb-service-center/syncer/version.VERSION=$BUILD_NUMBER'"
+
+    local BINARY_NAME=$app/syncer
+    if [ "$GOOS" == "windows" ]; then
+        BINARY_NAME=${BINARY_NAME}.exe
+    fi
+    go build --ldflags "${ldflags}" -o $BINARY_NAME
+    cd -
+}
+
 sc_deps() {
     install_glide
 
diff --git a/scripts/release/make_release.sh b/scripts/release/make_release.sh
index fe965f1..2f154bb 100755
--- a/scripts/release/make_release.sh
+++ b/scripts/release/make_release.sh
@@ -18,7 +18,7 @@
 set -e
 
 ## Get the Release Number
-if [ $2 == "" ]; then
+if [[ $2 == "" ]]; then
     echo "Invalid version number....exiting...."
     exit 1
 else
@@ -74,6 +74,8 @@
 
     build_scctl
 
+    build_syncer
+
     package
 }