dist: xenial
sudo: false
language: d
d:
- dmd
- ldc-beta
- ldc
os:
- linux
- osx
env:
- BUILD=
- BUILD=dub LIBDPARSE_VERSION=min
- BUILD=dub LIBDPARSE_VERSION=max
- BUILD=dub DSYMBOL_VERSION=min
- BUILD=dub DSYMBOL_VERSION=max
branches:
  only:
  - master
  - /^v\d+\.\d+\.\d+([+-]\S*)*$/
script: "./.travis.sh"
jobs:
  include:
    - stage: GitHub Release
      #if: tag IS present
      d: ldc-1.13.0
      os: linux
      script: echo "Deploying to GitHub releases ..." && ./release.sh
      deploy:
        provider: releases
        api_key: $GH_REPO_TOKEN
        file_glob: true
        file: bin/dscanner-*.tar.gz
        skip_cleanup: true
        on:
          repo: dlang-community/D-Scanner
          tags: true
    - stage: GitHub Release
      #if: tag IS present
      d: ldc-1.13.0
      os: osx
      script: echo "Deploying to GitHub releases ..." && ./release.sh
      deploy:
        provider: releases
        api_key: $GH_REPO_TOKEN
        file_glob: true
        file: bin/dscanner-*.tar.gz
        skip_cleanup: true
        on:
          repo: dlang-community/D-Scanner
          tags: true
    - stage: GitHub Release
      #if: tag IS present
      d: dmd
      os: linux
      language: generic
      script: echo "Deploying to GitHub releases ..." && ./release-windows.sh
      addons:
        apt:
          packages:
            - p7zip-full
        deploy:
          provider: releases
          api_key: $GH_REPO_TOKEN
          file_glob: true
          file: bin/dscanner-*.zip
          skip_cleanup: true
          on:
            repo: dlang-community/D-Scanner
            tags: true
    - stage: GitHub Release
      #if: tag IS present
      d: dmd
      os: linux
      language: generic
      script: echo "Deploying to GitHub releases ..." && ARCH=64 ./release-windows.sh
      addons:
        apt:
          packages:
            - p7zip-full
        deploy:
          provider: releases
          api_key: $GH_REPO_TOKEN
          file_glob: true
          file: bin/dscanner-*.zip
          skip_cleanup: true
          on:
            repo: dlang-community/D-Scanner
            tags: true
    - stage: dockerhub-stable
      if: tag IS present
      d: ldc
      os: linux
      script:
        - echo "Deploying to DockerHub..." && ./release.sh
        - LATEST_TAG="$(git describe --abbrev=0 --tags)"
        - docker build -t "dlangcommunity/dscanner:${LATEST_TAG} ."
        - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" ; fi
        - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then docker push "dlangcommunity/dscanner:${LATEST_TAG}" ; fi
    - stage: dockerhub-latest
      d: ldc
      os: linux
      script:
        - echo "Deploying to DockerHub..." && ./release.sh
        - docker build -t dlangcommunity/dscanner:latest .
        - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" ; fi
        - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; then docker push dlangcommunity/dscanner:latest ; fi
stages:
  - name: test
    if: type = pull_request or (type = push and branch = master)