chrly/.travis.yml

42 lines
1.2 KiB
YAML
Raw Normal View History

2018-02-16 03:16:20 +05:30
language: go
go:
- "1.13"
2018-02-16 03:16:20 +05:30
stages:
- test
2018-02-16 23:28:29 +05:30
- name: deploy
if: env(TRAVIS_PULL_REQUEST) = false AND (branch = master OR tag IS present)
2018-02-16 03:16:20 +05:30
2018-02-16 23:28:29 +05:30
install:
2018-02-16 03:16:20 +05:30
- go get -u github.com/golang/dep/cmd/dep
2018-02-16 23:28:29 +05:30
- dep ensure
2018-02-16 03:16:20 +05:30
jobs:
include:
- stage: test
script:
- go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
- bash <(curl -s https://codecov.io/bash)
2018-02-16 23:28:29 +05:30
- stage: deploy
sudo: required
services:
- docker
2018-02-16 03:16:20 +05:30
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/version.version=$APP_VERSION -X github.com/elyby/chrly/version.commit=$TRAVIS_COMMIT'
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