sudo: false

language: c

matrix:
  include:
    - compiler: gcc
      env: ARCH=x86_64
      addons:
        apt:
          packages:
            - libusb-1.0-0-dev
        coverity_scan:
          project:
            name: "cyrozap/libcyusbserial"
          notification_email: cyrozap@users.noreply.github.com
          build_command_prepend: "cmake ../"
          build_command: make
          branch_pattern: coverity_scan
    - compiler: gcc
      env: ARCH=i386 CFLAGS="-m32"
      addons:
        apt:
          packages:
            - gcc-multilib
            - libusb-1.0-0-dev:i386
            - pkg-config:i386
    - compiler: clang
      env: ARCH=x86_64
      addons:
        apt:
          packages:
            - libusb-1.0-0-dev
    - compiler: clang
      env: ARCH=i386 CFLAGS="-m32"
      addons:
        apt:
          packages:
            - gcc-multilib
            - libusb-1.0-0-dev:i386
            - pkg-config:i386

before_script:
  - mkdir build && cd build

script:
  - cmake ../ && make

before_deploy:
  - export RELEASE_NAME=libcyusbserial-$TRAVIS_TAG-$TRAVIS_OS_NAME-$ARCH
  - cd -
  - mkdir -p $RELEASE_NAME/{include,lib,tools}
  - cp ./COPYING.LESSER.txt ./README.md $RELEASE_NAME/
  - cp ./include/*.h $RELEASE_NAME/include/
  - cp ./build/lib/*.so{,.*} $RELEASE_NAME/lib/
  - cp ./build/tools/cyusbserialtest ./tools/README.txt $RELEASE_NAME/tools/
  - tar -czf $RELEASE_NAME.tar.gz $RELEASE_NAME

deploy:
  provider: releases
  api_key:
    secure: eYzcv257okDxTohG7njLqRMIjad9ytsxsE0ORqvYBaQRYlOUuG8LXlj7JCmABMXvdWXVmaNbJ4k5o0qN8hiINwIarf14TzkXzfaXnZ6oTkQh4+6QWJudbNo1vGUIHV9ax4gUw4cV/UTKnviceNq82LnCHKa4i9Ts4HrQeKjXdEw=
  file: $RELEASE_NAME.tar.gz
  on:
    repo: cyrozap/libcyusbserial
    tags: true
    all_branches: true
    condition: "$CC = gcc"

env:
  global:
   - secure: "kS2HsEf1Jwv2mT+QtX+vTNmXiGiR1Bq1iFw7ZTW6o9y/I0xYfQeeZKZSpGLO/WCFyQu4qZvCszTV8A+6JcKx7c0YWvzFoSPCmLxz326N/K+Ml0aTqeUdnWqiShByIdYbnvLfwNhB8GUJQc95dga8KmuWGjT2fl4onMkdONjwHyc="
