-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from safing/feature/travis/setup
Setup Travis CI tests and releases deployment
Showing
5 changed files
with
145 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
cpu.out | ||
vendor | ||
cmd/cmd | ||
cmd/jess | ||
cmd/cmd* | ||
cmd/jess* | ||
dist |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/bin/bash | ||
|
||
baseDir="$( cd "$(dirname "$0")" && pwd )" | ||
cd "$baseDir" | ||
|
||
COL_OFF="\033[00m" | ||
COL_BOLD="\033[01;01m" | ||
COL_RED="\033[31m" | ||
|
||
destDirPart1="dist" | ||
|
||
function check { | ||
# output | ||
output="cmd" | ||
# get version | ||
version=$(grep "info.Set" cmd/main.go | cut -d'"' -f4) | ||
# build versioned file name with platform | ||
filename="jess_${GOOS}_${GOARCH}_v${version//./-}" | ||
# platform | ||
platform="${GOOS}_${GOARCH}" | ||
if [[ $GOOS == "windows" ]]; then | ||
filename="${filename}.exe" | ||
output="${output}.exe" | ||
fi | ||
# build destination path | ||
destPath=${destDirPart1}/$filename | ||
|
||
# check if file exists | ||
if [[ -f $destPath ]]; then | ||
echo "$platform $version already built" | ||
else | ||
echo -e "${COL_BOLD}$platform $version${COL_OFF}" | ||
fi | ||
} | ||
|
||
function build { | ||
# output | ||
output="cmd/cmd" | ||
# get version | ||
version=$(grep "info.Set" cmd/main.go | cut -d'"' -f4) | ||
# build versioned file name with platform | ||
filename="jess_${GOOS}_${GOARCH}_v${version//./-}" | ||
# platform | ||
platform="${GOOS}_${GOARCH}" | ||
if [[ $GOOS == "windows" ]]; then | ||
filename="${filename}.exe" | ||
output="${output}.exe" | ||
fi | ||
# build destination path | ||
destPath=${destDirPart1}/$filename | ||
|
||
# check if file exists | ||
if [[ -f $destPath ]]; then | ||
echo "$platform already built in version $version, skipping..." | ||
return | ||
fi | ||
|
||
# build | ||
./cmd/build | ||
if [[ $? -ne 0 ]]; then | ||
echo -e "\n${COL_BOLD}$platform: ${COL_RED}BUILD FAILED.${COL_OFF}" | ||
exit 1 | ||
fi | ||
mkdir -p $(dirname $destPath) | ||
cp $output $destPath | ||
echo -e "\n${COL_BOLD}$platform: successfully built.${COL_OFF}" | ||
} | ||
|
||
function check_all { | ||
GOOS=linux GOARCH=amd64 check | ||
GOOS=windows GOARCH=amd64 check | ||
GOOS=darwin GOARCH=amd64 check | ||
} | ||
|
||
function build_all { | ||
GOOS=linux GOARCH=amd64 build | ||
GOOS=windows GOARCH=amd64 build | ||
GOOS=darwin GOARCH=amd64 build | ||
} | ||
|
||
function build_os { | ||
# build only for current OS | ||
# set for script | ||
GOOS=$(go env GOOS) | ||
# architectures | ||
GOARCH=amd64 build | ||
} | ||
|
||
case $1 in | ||
"check" ) | ||
check_all | ||
;; | ||
"build" ) | ||
build_all | ||
;; | ||
"build-os" ) | ||
build_os | ||
;; | ||
* ) | ||
echo "" | ||
echo "build list:" | ||
echo "" | ||
check_all | ||
echo "" | ||
read -p "press [Enter] to start building" x | ||
echo "" | ||
build_all | ||
echo "" | ||
echo "finished building." | ||
echo "" | ||
;; | ||
esac |