Fix the missing version for the binary
diff --git a/.travis.yml b/.travis.yml
index 3107791..4ac1237 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -56,12 +56,16 @@
before_deploy:
- export build_file_name=wskdeploy
- go get github.com/inconshreveable/mousetrap
-- "./tools/travis/build_tag_releases.sh $build_file_name"
-- ./gradlew --console=plain releaseBinaries
-- export RELEASE_PKG_FILE="$(cd "$TRAVIS_BUILD_DIR/release" && ls ${zip_file_name}-*.tgz ${zip_file_name}-*.zip)"
-- echo "Deploying $RELEASE_PKG_FILE to GitHub releases."
- export GIT_TAG="latest"
- export TAG=false
+- if [ ! -z "$TRAVIS_TAG" ] ; then
+ export GIT_TAG=$TRAVIS_TAG;
+ export TAG=true;
+ fi
+- "./tools/travis/build_tag_releases.sh $build_file_name $GIT_TAG"
+- ./gradlew --console=plain releaseBinaries -PpackageVersion=$GIT_TAG
+- export RELEASE_PKG_FILE="$(cd "$TRAVIS_BUILD_DIR/release" && ls ${zip_file_name}-*.tgz ${zip_file_name}-*.zip)"
+- echo "Deploying $RELEASE_PKG_FILE to GitHub releases."
- if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ "$TRAVIS_OS_NAME" == "linux" ] ; then
git config --global user.email "builds@travis-ci.com";
git config --global user.name "Travis CI";
@@ -70,10 +74,7 @@
GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" git tag $GIT_TAG -a -m "Generated tag from Travis CI build $TRAVIS_BUILD_NUMBER";
git push -f -q https://$API_KEY@github.com/apache/incubator-openwhisk-wskdeploy $GIT_TAG;
fi
-- if [ ! -z "$TRAVIS_TAG" ] ; then
- export GIT_TAG=$TRAVIS_TAG;
- export TAG=true;
- fi
+- echo "The event type is $TRAVIS_EVENT_TYPE."
- echo "The GIT_TAG of this Travis build is $GIT_TAG."
deploy:
diff --git a/Makefile b/Makefile
index 97c50f0..291fc2a 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
BINARY=wskdeploy
-VERSION=1.0.0
+VERSION=latest
BUILD=`git rev-parse HEAD`
@@ -27,14 +27,14 @@
@echo "Installing dependencies"
godep restore -v
-LDFLAGS=-ldflags "-X main.Version=`date -u '+%Y-%m-%dT%H:%M:%S'` -X main.Build=`git rev-parse HEAD` "
+LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=`git rev-parse HEAD` "
test: deps
@echo "Testing"
go test ./... -tags=unit
# Build the project
-build: test
+build:
go build ${LDFLAGS} -o ${BINARY}
# Run the integration test against OpenWhisk
diff --git a/tools/travis/build_tag_releases.sh b/tools/travis/build_tag_releases.sh
index 83bf9f3..799c547 100755
--- a/tools/travis/build_tag_releases.sh
+++ b/tools/travis/build_tag_releases.sh
@@ -23,6 +23,7 @@
declare -a os_list=("linux" "darwin" "windows")
declare -a arc_list=("amd64" "386")
build_file_name=${1:-"wskdeploy"}
+build_version=${2:-"$TRAVIS_TAG"}
for os in "${os_list[@]}"
do
@@ -37,7 +38,7 @@
os_name="mac"
fi
cd $TRAVIS_BUILD_DIR
- GOOS=$os GOARCH=$arc go build -o build/$os/$wskdeploy
+ GOOS=$os GOARCH=$arc go build -ldflags "-X main.Version=$build_version" -o build/$os/$wskdeploy
cd build/$os
if [[ "$os" == "linux" ]]; then
tar -czvf "$TRAVIS_BUILD_DIR/$build_file_name-$TRAVIS_TAG-$os_name-$arc.tgz" $wskdeploy
diff --git a/tools/travis/script.sh b/tools/travis/script.sh
index cfc82f5..b0c7d5f 100755
--- a/tools/travis/script.sh
+++ b/tools/travis/script.sh
@@ -28,7 +28,12 @@
cd $TRAVIS_BUILD_DIR
./tools/travis/scancode.sh
make lint
-make build
+make test
+BUILD_VERSION="latest"
+if [ ! -z "$TRAVIS_TAG" ] ; then
+ BUILD_VERSION=$TRAVIS_TAG
+fi
+make build VERSION=$BUILD_VERSION
export PATH=$PATH:$TRAVIS_BUILD_DIR
HOMEDIR="$(dirname "$TRAVIS_BUILD_DIR")"