You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/04/05 21:36:17 UTC

[GitHub] houshengbo closed pull request #857: Fix the missing version for the binary

houshengbo closed pull request #857: Fix the missing version for the binary
URL: https://github.com/apache/incubator-openwhisk-wskdeploy/pull/857
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
index 31077917..4ac1237b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -56,12 +56,16 @@ after_script:
 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 @@ before_deploy:
       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 97c50f02..291fc2a2 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ SOURCEDIR=.
 SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
 BINARY=wskdeploy
 
-VERSION=1.0.0
+VERSION=latest
 
 BUILD=`git rev-parse HEAD`
 
@@ -27,14 +27,14 @@ deps:
 	@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 83bf9f32..799c547c 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 @@ do
             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 cfc82f54..b0c7d5f4 100755
--- a/tools/travis/script.sh
+++ b/tools/travis/script.sh
@@ -28,7 +28,12 @@ ROOTDIR="$SCRIPTDIR/../.."
 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")"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services