Created
November 15, 2020 09:21
-
-
Save asiermarques/4583b8d72c9460a480a32f513ab33c58 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 | |
package=$1 | |
if [[ -z "$package" ]]; then | |
echo "usage: $0 <package-name>" | |
exit 1 | |
fi | |
IFS="/" read -ra package_split <<< "$package" | |
package_name=${package_split[2]} | |
platforms=("linux/arm64" "darwin/amd64") | |
for platform in "${platforms[@]}" | |
do | |
platform_split=(${platform//\// }) | |
GOOS=${platform_split[0]} | |
GOARCH=${platform_split[1]} | |
output_name=$package_name'-'$GOOS'-'$GOARCH | |
if [ $GOOS = "windows" ]; then | |
output_name+='.exe' | |
fi | |
env GOOS=$GOOS GOARCH=$GOARCH go build -o bin/$output_name $package | |
if [ $? -ne 0 ]; then | |
echo 'An error has occurred! Aborting the script execution...' | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment