sudo: required

language: go

go_import_path: github.com/frodenas/stackdriver_exporter

services:
  - docker

env:
  - DOCKER_IMAGE_NAME=frodenas/stackdriver-exporter

jobs:
  include:
    - stage: tests
      script: make test
    - stage: docker image
      script:
        - make crossbuild
        - ln -s .build/linux-amd64/stackdriver_exporter stackdriver_exporter
        - |
          if [ -n "$TRAVIS_TAG" ]; then
            make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$TRAVIS_TAG
          else
            make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME
          fi
        - |
          if [[ "$TRAVIS_TAG" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
            docker tag "$DOCKER_IMAGE_NAME:$TRAVIS_TAG" "$DOCKER_IMAGE_NAME:latest"
          fi
        - docker images

sudo: required

language: go

go_import_path: github.com/frodenas/stackdriver_exporter

services:
  - docker

env:
  - DOCKER_IMAGE_NAME=frodenas/stackdriver-exporter

jobs:
  include:
    - stage: tests
      script: make test
    - stage: docker image
      script:
        - make crossbuild
        - ln -s .build/linux-amd64/stackdriver_exporter stackdriver_exporter
        - |
          if [ -n "$TRAVIS_TAG" ]; then
            make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$TRAVIS_TAG
          else
            make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
          fi
        - |
          if [[ "$TRAVIS_TAG" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
            docker tag "$DOCKER_IMAGE_NAME:$TRAVIS_TAG" "$DOCKER_IMAGE_NAME:latest"
          fi
        - docker images

Use branch as docker image tag
Use branch as docker image tag
