From 3b504d5109f08212b69e98992ef65bab2713b2ec Mon Sep 17 00:00:00 2001 From: quest Date: Mon, 8 Feb 2016 16:17:53 -0800 Subject: [PATCH 1/3] Added travis cross compilation support for linux/solaris/windows --- .gitignore | 4 ++++ .travis.yml | 2 ++ scripts/cross_compile.sh | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100755 scripts/cross_compile.sh diff --git a/.gitignore b/.gitignore index eeb3cbb3..1c0f697c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ gnatsd # coverage coverage.out + +# Cross compiled binaries +pkg + diff --git a/.travis.yml b/.travis.yml index b18ca58e..860aab53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,3 +15,5 @@ script: - go test -i -race ./... - go test -v -race ./... - ./scripts/cov.sh TRAVIS +after_script: +- if [ "$TRAVIS_GO_VERSION" = "1.5" ] && [ "$BUILD_GOOS" = "linux" ] && [ "$TRAVIS_TAG" != "" ]; then ./scripts/cross_compile.sh; ghr --username derekcollison --token $GITHUB_TOKEN --replace $TRAVIS_TAG pkg/; fi diff --git a/scripts/cross_compile.sh b/scripts/cross_compile.sh new file mode 100755 index 00000000..359a519c --- /dev/null +++ b/scripts/cross_compile.sh @@ -0,0 +1,18 @@ +#!/bin/bash +go get github.com/inconshreveable/mousetrap +go get github.com/mitchellh/gox +go get github.com/tcnksm/ghr + +export APPNAME="gnatsd" +export OSARCH="linux/386 linux/amd64 linux/arm solaris/amd64 windows/386 windows/amd64" +export DIRS="linux_386 linux_amd64 linux_arm solaris_amd64 windows_386 windows_amd64" +export OUTDIR="pkg" + +gox -osarch="$OSARCH" -output "$OUTDIR/$APPNAME-{{.OS}}_{{.Arch}}/$APPNAME" +for dir in $DIRS; do \ + (cp README.md $OUTDIR/$APPNAME-$dir/README.md) ;\ + (cp LICENSE $OUTDIR/$APPNAME-$dir/LICENSE) ;\ + (cd $OUTDIR && zip -q $APPNAME-$dir.zip -r $APPNAME-$dir) ;\ + echo "make $OUTDIR/$APPNAME-$dir.zip" ;\ +done + From 6e754af487cde31b7fb7956c8b5dd6eec78d328f Mon Sep 17 00:00:00 2001 From: quest Date: Mon, 8 Feb 2016 18:40:05 -0800 Subject: [PATCH 2/3] Remove mousetrap --- scripts/cross_compile.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/cross_compile.sh b/scripts/cross_compile.sh index 359a519c..0e069b7d 100755 --- a/scripts/cross_compile.sh +++ b/scripts/cross_compile.sh @@ -1,5 +1,4 @@ #!/bin/bash -go get github.com/inconshreveable/mousetrap go get github.com/mitchellh/gox go get github.com/tcnksm/ghr From 9d493686c2e820452a7b6bc1ad96082f126ab27a Mon Sep 17 00:00:00 2001 From: quest Date: Mon, 15 Feb 2016 23:58:55 -0800 Subject: [PATCH 3/3] Change user to nats-io for cross compiled binaries --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 860aab53..be84c4d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,4 @@ script: - go test -v -race ./... - ./scripts/cov.sh TRAVIS after_script: -- if [ "$TRAVIS_GO_VERSION" = "1.5" ] && [ "$BUILD_GOOS" = "linux" ] && [ "$TRAVIS_TAG" != "" ]; then ./scripts/cross_compile.sh; ghr --username derekcollison --token $GITHUB_TOKEN --replace $TRAVIS_TAG pkg/; fi +- if [ "$TRAVIS_GO_VERSION" = "1.5" ] && [ "$BUILD_GOOS" = "linux" ] && [ "$TRAVIS_TAG" != "" ]; then ./scripts/cross_compile.sh; ghr --username nats-io --token $GITHUB_TOKEN --replace $TRAVIS_TAG pkg/; fi