Skip to content

Commit

Permalink
build for multiple arch
Browse files Browse the repository at this point in the history
  • Loading branch information
kepler471 committed Sep 9, 2020
1 parent 478fd41 commit 32f63a1
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/bash

package=$1
major=$2
minor=$3
patch=$4

if [[ -z "$package" || -z "$major" || -z "$minor" || -z "$patch" ]]; then
echo "usage: $0 <package-name> <major-ver-num> <patch-ver-num> <patch-ver-num>"
exit 1
fi

platforms=("windows/amd64" "linux/amd64" "darwin/amd64")
zip=""

for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}

path=releases/v"$major"/"$minor"/"$patch"/"$GOOS"/"$package"

if [ $GOOS = "windows" ]; then
path+='.exe'
fi

env GOOS="$GOOS" GOARCH="$GOARCH" go build -o "$path" "$package"

if [ $? -ne 0 ]; then
echo 'An error has occurred! Aborting the script execution...'
exit 1
fi

zip+="$GOOS"" "
done

tar -czf releases/v"$major"/"$minor"/"$patch"/dvembed.tar.gz -C releases/v"$major"/"$minor"/"$patch" $zip
#echo tar -czf releases/v"$major"/"$minor"/"$patch"/dvembed.tar.gz "$zip"

0 comments on commit 32f63a1

Please sign in to comment.