travis: fail build when script.sh errors

This commit is contained in:
Caleb Bassi 2019-02-07 00:35:53 -08:00
parent bfeb9f8f5a
commit d97af5296d

View File

@ -1,5 +1,8 @@
#!/usr/bin/env bash
# Check if any command failed
ERROR=false
GOARCH=${_GOARCH}
GOOS=${_GOOS}
@ -7,7 +10,7 @@ if [[ ! ${GOARCH} ]]; then
exit
fi
env GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${NAME}
env GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${NAME} || ERROR=true
mkdir -p dist
@ -17,7 +20,7 @@ else
FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM}
fi
tar -czf dist/${FILE}.tgz ${NAME}
tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true
if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then
VERSION=$(go run main.go -v) # used by nfpm
@ -26,11 +29,15 @@ if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then
-e VERSION=${VERSION} \
goreleaser/nfpm pkg \
--config /tmp/pkg/ci/nfpm.yml \
--target /tmp/pkg/dist/${FILE}.deb
--target /tmp/pkg/dist/${FILE}.deb || ERROR=true
docker run --rm \
-v $PWD:/tmp/pkg \
-e VERSION=${VERSION} \
goreleaser/nfpm pkg \
--config /tmp/pkg/ci/nfpm.yml \
--target /tmp/pkg/dist/${FILE}.rpm
--target /tmp/pkg/dist/${FILE}.rpm || ERROR=true
fi
if [ ${ERROR} == "true" ]; then
exit 1
fi