Refactor travis files

This commit is contained in:
Caleb Bassi 2019-02-07 19:04:51 -08:00
parent 77dfcba386
commit 9e7f58b769
2 changed files with 29 additions and 26 deletions

View File

@ -10,10 +10,6 @@ env:
global: global:
- NAME=gotop - NAME=gotop
install: true
script:
- ./ci/script.sh
matrix: matrix:
include: include:
# Linux # Linux
@ -34,6 +30,9 @@ matrix:
- env: _GOOS=darwin _GOARCH=amd64 - env: _GOOS=darwin _GOARCH=amd64
os: osx os: osx
install: true
script: ./ci/script.sh
deploy: deploy:
provider: releases provider: releases
api_key: $GITHUB_TOKEN api_key: $GITHUB_TOKEN

View File

@ -1,32 +1,36 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Check if any command failed function main {
ERROR=false # Check if any command failed
ERROR=false
GOARCH=${_GOARCH} GOARCH=${_GOARCH}
GOOS=${_GOOS} GOOS=${_GOOS}
if [[ ! ${GOARCH} ]]; then if [[ ! ${GOARCH} ]]; then
exit exit
fi fi
env GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${NAME} || ERROR=true env GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${NAME} || ERROR=true
mkdir -p dist mkdir -p dist
if [[ ${GOARCH} == "arm64" ]]; then if [[ ${GOARCH} == "arm64" ]]; then
FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_arm8 FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_arm8
else else
FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM} FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM}
fi fi
tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true
if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then
make all || ERROR=true make all || ERROR=true
rm dist/gotop rm dist/gotop
fi fi
if [ ${ERROR} == "true" ]; then if [ ${ERROR} == "true" ]; then
exit 1 exit 1
fi fi
}
main