From 3b504d5109f08212b69e98992ef65bab2713b2ec Mon Sep 17 00:00:00 2001 From: quest Date: Mon, 8 Feb 2016 16:17:53 -0800 Subject: [PATCH] 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 eeb3cbb302f..1c0f697c80f 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 b18ca58e687..860aab53491 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 00000000000..359a519c66a --- /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 +