sudo: required language: go go: - 1.12 services: - docker stages: - test - name: deploy if: branch = master OR tag IS present install: - go get -u github.com/golang/dep/cmd/dep - dep ensure jobs: include: - stage: test script: - go test -v -race ./... - stage: deploy script: - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - export DOCKER_TAG="${TRAVIS_TAG:-dev}" - export APP_VERSION="${TRAVIS_TAG:-dev-${TRAVIS_COMMIT:0:7}}" - > env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o release/chrly -ldflags '-extldflags "-static" -X github.com/elyby/chrly/bootstrap.version=$APP_VERSION' main.go - docker build -t elyby/chrly:$DOCKER_TAG . - docker push elyby/chrly:$DOCKER_TAG - | if [ ! -z ${TRAVIS_TAG+x} ] && [[ "$TRAVIS_TAG" != *"-"* ]]; then docker tag elyby/chrly:$DOCKER_TAG elyby/chrly:latest docker push elyby/chrly:latest fi