summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2019-02-07 19:04:51 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2019-02-07 19:36:56 -0800
commit9e7f58b769ba1db3e116825152b89441025628ba (patch)
tree2f5332c977214d00ad135f9129916790c228cfb5
parent77dfcba386620f9060199eaa212ee322e52cf922 (diff)
Refactor travis files
-rw-r--r--.travis.yml7
-rwxr-xr-xci/script.sh48
2 files changed, 29 insertions, 26 deletions
diff --git a/.travis.yml b/.travis.yml
index cdacefc..cf131a6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,10 +10,6 @@ env:
global:
- NAME=gotop
-install: true
-script:
- - ./ci/script.sh
-
matrix:
include:
# Linux
@@ -34,6 +30,9 @@ matrix:
- env: _GOOS=darwin _GOARCH=amd64
os: osx
+install: true
+script: ./ci/script.sh
+
deploy:
provider: releases
api_key: $GITHUB_TOKEN
diff --git a/ci/script.sh b/ci/script.sh
index 142d0cf..27e6cdf 100755
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -1,32 +1,36 @@
#!/usr/bin/env bash
-# Check if any command failed
-ERROR=false
+function main {
+ # Check if any command failed
+ ERROR=false
-GOARCH=${_GOARCH}
-GOOS=${_GOOS}
+ GOARCH=${_GOARCH}
+ GOOS=${_GOOS}
-if [[ ! ${GOARCH} ]]; then
- exit
-fi
+ if [[ ! ${GOARCH} ]]; then
+ exit
+ 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
- FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_arm8
-else
- FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM}
-fi
+ if [[ ${GOARCH} == "arm64" ]]; then
+ FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_arm8
+ else
+ FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM}
+ fi
-tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true
+ tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true
-if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then
- make all || ERROR=true
- rm dist/gotop
-fi
+ if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then
+ make all || ERROR=true
+ rm dist/gotop
+ fi
-if [ ${ERROR} == "true" ]; then
- exit 1
-fi
+ if [ ${ERROR} == "true" ]; then
+ exit 1
+ fi
+}
+
+main