Skip to content

Commit

Permalink
[#1/feature] Create a build script to windows, linux and mac
Browse files Browse the repository at this point in the history
> current branch: master, issue link: #1
go.build.sh
  • Loading branch information
wilcorrea committed May 25, 2019
1 parent 3104af8 commit 328bf6e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions go.build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

BUILD_OPTIONS="windows,linux,mac"
BUILD_PLATFORM=${1}

function __build
{
if [[ ! ",${BUILD_OPTIONS}," =~ ",${BUILD_PLATFORM}," ]]; then
echo "You need to enter one of these options: ${BUILD_OPTIONS}"
echo "Ex.: ./go.build.sh windows"
return
fi

BUILD_OUTPUT="dist/${BUILD_PLATFORM}"
if [[ BUILD_PLATFORM = "windows" ]]; then
BUILD_OUTPUT="${BUILD_OUTPUT}.exe"
fi

if [[ -f ${BUILD_OUTPUT} ]]; then
rm -f ${BUILD_OUTPUT}
fi

docker run --rm\
-v $(pwd):/var/www/app\
-w /var/www/app\
tevun-client-go\
env GOOS=${BUILD_PLATFORM} GOARCH=amd64\
go build -o ${BUILD_OUTPUT} src/main.go

if [[ -f ${BUILD_OUTPUT} ]]; then
chown 1000:1000 ${BUILD_OUTPUT}
chmod +x ${BUILD_OUTPUT}
fi
}

__build

0 comments on commit 328bf6e

Please sign in to comment.