Skip to content

Instantly share code, notes, and snippets.

@surma
Last active October 11, 2015 18:08
Show Gist options
  • Save surma/3899142 to your computer and use it in GitHub Desktop.
Save surma/3899142 to your computer and use it in GitHub Desktop.
Cross-Compiler-Script for Go projects
#!/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