add installation and build
This commit is contained in:
33
go-executable-build.bash
Normal file
33
go-executable-build.bash
Normal file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
package=$1
|
||||
package_name=$2
|
||||
if [[ -z "$package" ]]; then
|
||||
echo "usage: $0 <package-name> <tool-name>"
|
||||
exit 1
|
||||
fi
|
||||
package_split=(${package//\// })
|
||||
#package_name=${package_split[-1]}
|
||||
if [[ -z "$package_name" ]]; then
|
||||
package_name=${package_split[-1]}
|
||||
fi
|
||||
|
||||
platforms=("windows/amd64" "windows/arm64" "darwin/amd64" "darwin/arm64" "linux/amd64" "linux/arm64")
|
||||
|
||||
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
|
||||
output_name='build/'$output_name
|
||||
|
||||
env GOOS=$GOOS GOARCH=$GOARCH go build -o $output_name $package
|
||||
if [ $? -ne 0 ]; then
|
||||
echo 'An error has occurred! Aborting the script execution...'
|
||||
exit 1
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user