Last active
October 11, 2015 18:08
-
-
Save surma/3899142 to your computer and use it in GitHub Desktop.
Cross-Compiler-Script for Go projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PLATFORMS=${PLATFORMS:-"darwin/amd64 linux/amd64"} | |
APPNAME=${1:-$(basename `pwd`)} | |
README=${2:-README.md} | |
VERSION=$(cat $README | tail -n4 | grep -i Version | cut -d' ' -f2) | |
for platform in $PLATFORMS; do | |
export GOOS=$(echo $platform | cut -d/ -f1) | |
export GOARCH=$(echo $platform | cut -d/ -f2) | |
BINNAME="${APPNAME}_${VERSION}_${GOOS}_${GOARCH}" | |
echo "Building $BINNAME..." | |
CGO_ENABLED=0 go build -o $BINNAME *.go | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment