Created
April 28, 2021 13:40
-
-
Save porfirion/cd30b8e690baed29940c08c66c6b466d to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
if [ $# -eq 0 ] | |
then | |
echo "Usage: $0 DIRECTORY" | |
echo " DIRECTORY is a go project directory to build" | |
exit 1 | |
fi | |
cd $1 > /dev/null | |
readonly ROOT=`pwd` | |
readonly EXE_NAME=$(basename "$ROOT") | |
echo "Building in dir $ROOT" | |
GOOSES=(linux windows darwin darwin) | |
GOARCHS=(amd64 amd64 amd64 arm64) | |
for i in ${!GOOSES[@]}; | |
do | |
OS=${GOOSES[i]} | |
ARCH=${GOARCHS[i]} | |
FULL_EXE_NAME="$EXE_NAME-$OS-$ARCH" | |
echo "Will build $FULL_EXE_NAME" | |
GOOS=$OS GOARCH=$ARCH go build -o "$FULL_EXE_NAME" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment