language: rust
sudo: true
rust:
  - stable
  - beta
  - nightly

# Cache `cargo install`ed tools, but don't cache the project's `target`
# directory (which ends up over-caching and filling all disk space!)
cache: cargo
#  directories:
#    - /home/travis/.cargo

script:
  - cargo build --verbose --all
  - cargo test --verbose --all


DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB
  before_deploy:
    - git config --local user.name "Jan Schreiber"
    - git config --local user.email "jan@mecinus.com"
    - name="ncgopher-$TRAVIS_TAG-$TARGET"
    - mkdir $name
    - cp target/$TARGET/release/ncgopher $name/
    - cp README.org LICENSE $name/
    - tar czvf $name.tar.gz $name
  deploy:
    provider: releases
    api_key: $GH_TOKEN
    file: ncgopher-$TRAVIS_TAG-$TARGET.tar.gz
    skip_cleanup: true
    on:
      branch: master
      tags: true

matrix:
  include:
# Can't crosscompile due to error in ncurses-rs
#  - name: Linux Binary
#    env: TARGET=x86_64-unknown-linux-musl
#    rust: stable
#    before_script:
#      - rustup target add $TARGET
#      - sudo apt-get -y install libncurses5 libncursesw5 libncurses5-dev libncursesw5-dev git
#    script: cargo build --verbose --release --target $TARGET --locked
#    addons:
#      apt:
#        packages:
#          - musl-tools
#    <<: *DEPLOY_TO_GITHUB

  - name: macOS Binary
    env: MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=x86_64-apple-darwin
    os: osx
    rust: stable
    script: cargo build --release --target $TARGET --locked
    install: true
    <<: *DEPLOY_TO_GITHUB

  # Testing other channels
# Can't get compilation on windows to run here:
#  - name: Windows
#    env: TARGET=x86_64-pc-windows-msvc
#    # TODO: install mingw-w64-pdcurses
#    os: windows
#    rust: stable