From d97af5296de06cc4907e3c56dec687326fcda9ea Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 7 Feb 2019 00:35:53 -0800 Subject: [PATCH] travis: fail build when script.sh errors --- ci/script.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ci/script.sh b/ci/script.sh index 596ee29..3872b25 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -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