Adjust Travis setup

This commit is contained in:
ErickSkrauch 2018-02-16 20:58:29 +03:00
parent befa163f0e
commit d7bc77e5a7
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E

View File

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