sudo: false
language: d
d:
  - dmd-nightly
  - dmd-beta
  - dmd
  - ldc-beta
  - ldc

os:
  - linux
#  - osx # disabled until travis has more mac resources

env:
  - BUILD=
  - BUILD=dub

script: ./.travis.sh

jobs:
    include:
        - stage: Build & Upload Package
          if: tag IS present
          # Which package to deploy
          env:
              - DMD=2.076.*
              - DIST=xenial
              - PATH="$(git config -f .gitmodules submodule.beaver.path)/bin:$PATH"
          language: generic
          sudo: required
          services:
              - docker
          git:
              submodules: false
          before_install: git submodule update --init
          install: beaver dlang install
          script:
              - beaver dlang make pkg
          deploy:
              provider: script
              script: beaver bintray upload -d dlang-community/apt/dfmt build/last/pkg/*.deb
              skip_cleanup: true
              on:
                  tags: true # must be a git tag
                  repo: dlang-community/dfmt # must be a tag on dlang-community
        - stage: GitHub Release
          #if: tag IS present
          d: ldc-1.8.0
          os: linux
          script: echo "Deploying to GitHub releases ..." && ./release.sh
          deploy:
            provider: releases
            api_key: $GH_REPO_TOKEN
            file_glob: true
            file: bin/dfmt-*.tar.gz
            skip_cleanup: true
            on:
              repo: dlang-community/dfmt
              tags: true
        - stage: GitHub Release
          #if: tag IS present
          d: ldc-1.8.0
          os: osx
          script: echo "Deploying to GitHub releases ..." && ./release.sh
          deploy:
            provider: releases
            api_key: $GH_REPO_TOKEN
            file_glob: true
            file: bin/dfmt-*.tar.gz
            skip_cleanup: true
            on:
              repo: dlang-community/dfmt
              tags: true
        - stage: GitHub Release
          #if: tag IS present
          d: dmd
          os: linux
          language: generic
          sudo: yes
          script: echo "Deploying to GitHub releases ..." && ./release-windows.sh
          addons:
            apt:
              packages:
                - p7zip-full
                - wine
            deploy:
              provider: releases
              api_key: $GH_REPO_TOKEN
              file_glob: true
              file: bin/dfmt-.*.zip
              skip_cleanup: true
              on:
                repo: dlang-community/dfmt
                tags: true
stages:
  - name: test
    if: type = pull_request or (type = push and branch = master)