Skip to content

Commit

Permalink
Added travis cross compilation support for linux/solaris/windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zquestz committed Feb 9, 2016
1 parent d22b52b commit 3b504d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ gnatsd

# coverage
coverage.out

# Cross compiled binaries
pkg

2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions scripts/cross_compile.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b504d5

Please sign in to comment.