diff --git a/.gitignore b/.gitignore index 4ba3b85..aeeb6a4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ test/*.html *.vr goiban-service +build/ \ No newline at end of file diff --git a/Makefile b/Makefile index 008f60a..d354759 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,8 @@ -.PHONY: dev +.PHONY: dev build dev: go build - ./goiban-service 8080 root:root@/goiban?charset=utf8 \ No newline at end of file + ./goiban-service 8080 root:root@/goiban?charset=utf8 + +build: + ./build.sh \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..2033710 --- /dev/null +++ b/build.sh @@ -0,0 +1,33 @@ +#/usr/bin/env bash +CONFIGURATIONS=( + darwin,386 \ + windows,386 \ + windows,amd64 \ + linux,386 \ + linux,amd64 \ + linux,arm \ + linux,arm64 \ + solaris,amd64 +) + +for config in ${CONFIGURATIONS[@]}; do +IFS="," +set $config + +os="$1" +arch="$2" +path="build/$os/$arch" +mkdir -p "build/$os/$arch" +bin_name="goiban-service" + +if [ $os = "windows" ]; then + bin_name="$bin_name.exe" +fi + +GOOS="$os" GOARCH="$arch" go build -o "$path/$bin_name" +cp -r $GOPATH/src/github.com/fourcube/goiban-data-loader/data "$path/" +cp -r ./static "$path/" +tar -czf "build/goiban-service-$os-$arch.tar.gz" "$path" + +unset IFS; +done \ No newline at end of file