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& Deploy"

      compiler: "clang"
      os: linux
      env: LDIST=DO_NOT_DEPLOY
    - compiler: "gcc"
      os: linux
      dist: xenial
      env:
        - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss
    - os: linux
      env:
        - OS_TYPE=centos_docker
        - OS_VERSION=6
        - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss
    - os: linux
      env:
        - OS_TYPE=centos_docker
        - OS_VERSION=7
        - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss
    - os: linux
      env:
        - OS_TYPE=ubuntu_docker
        - OS_VERSION=bionic
        - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss
    - compiler: "gcc"
      os: osx
      osx_image: xcode10.1
      env:
        - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss
    - compiler: "gcc"
      os: osx
      osx_image: xcode11
      env:
        - EXTRA_SSH=-oHostKeyAlgorithms=+ssh-dss

    - stage: "Trigger Next In Pipeline"
      env:
        - TRIGGER_NEXT_BUILD=true

addons:
  artifacts: true
  ssh_known_hosts:
    secure: "HzU57pX/0iwRgPCnrP7QQ92XkrySsx/jjCLEqNAyWuQBYTMl2vVXnys7dclUp841CWRHv3TQXT0Jem9mZ9oZbzMR8Nxo2mjJyiH06BMcBYmTiaGxzSOh0XjiYTm3ZZvH+SQYdiXNBbPIY7B1ekC6Vw/ZQ8N4U1SiMh5W38+jXgqTYefB2h8GjmYB8f3DP0WE97ITaLG0/dUF+vLkuyJaLHND2j0e+cjjir8ah8eioK67+iX1dnDnN4U6su7tdVcqHGdgS3sSjvFl8+q9R9IFuT2RuQLd05Fu5gehV5ruJP0GzjJ8eU1fhkFSiWPenBGgkDRsv7ORmtL9ZmZKjtXIxhIlgVBdH8Rb9qtDCbKf6tSSrOU14TkN1FR8uPw68xhlnptS31AwB+OisWw1ULRJBEWRTABw+avUloDhgFMgUtFnSukjMlst16Qwq5bGKn5yQ6KBJU8BP/uX6ptGQemTokEe92TWJq6TS6kNpb8rA537gaMp8VQ2zk8Nhw6LovA5LbuKB73rcjuQsOto2/DF2GhJkBQ0peVzu1vsAFD5WmMTPzQziTLiTyI+gQktYJSoV8ERAvxqeDptqUYMrRMg7VtuV5fNEQ2Q5fVMrcqB9NGkeUjfIo7GHP0tBEzLCNjaRNYrMxEqKYW8OQSfINA3b3gLZuwLepHW71j2xqnFlpQ="

before_install:
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./CI/travis/before_install_darwin ; fi
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./CI/travis/before_install_linux "$OS_TYPE" "$OS_VERSION" ; fi

  - mkdir -p $TRAVIS_BUILD_DIR/build
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p $TRAVIS_BUILD_DIR/build_tar ; fi

script:
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_linux libad9361-iio "$OS_TYPE" "$OS_VERSION" ; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/make_darwin; fi
  - if [[ "$TRIGGER_NEXT_BUILD" == "true" ]]; then ${TRAVIS_BUILD_DIR}/CI/travis/after_deploy; fi

notifications:
  email:
    on_success: change
    on_failure: always

before_deploy:
  - . ${TRAVIS_BUILD_DIR}/CI/travis/before_deploy
  - openssl aes-256-cbc -K $encrypted_ca7c55addc40_key -iv $encrypted_ca7c55addc40_iv -in ${TRAVIS_BUILD_DIR}/CI/travis/deploy.rsa.enc -out /tmp/deploy.rsa -d
  - eval "$(ssh-agent -s)"
  - chmod 600 /tmp/deploy.rsa
  - ssh-add /tmp/deploy.rsa
deploy:
  - provider: releases
    api_key:
      secure: "ocDkFUpRYim0o3kEzO5It8mTjg4FnVYT+KaXoUtZA6r9x6VZteSFvimELIV/WePGnNLOavlXPgRb+cXmJiYSkVkFqrrwRkHgYvTapjPn/LBh0xDQZi9SrvTj/ICW3tMu7Esxqa7P2snhLf7P4XkLMySxeooKe4BoV5Uy8WUy+IE0HCkCxaiokUFEg7UVVDLy5ahTyVcdV4su44E+URCBDTk+UvgKJ3VDjNVDZp8uea7RBRHVfSucb/12AeJr+PkaxrbsqtI+GHMohvmLVBmALkP+WtLLMklxPofEnBW/UV6iU+hvEd6dROqG9T52hDQpcBqdJlqx4C3mHkPpt7lxSFTcyyTKEqRKZA0sBexadMZ3fnS2gNXizstuDAxIuCowc+nOjk1WNAN8z4ADxk5t4ct8U1I7CTA0TgkTzkRizeelTTZCbt8kHwh4oTalBt/5rIg3Tk8+YgrwvuEIAmRwPIORob+xbYGK9GCKwmdfpSuVhcLsgb43eh96ZXQ2bBn30I3pebCMm9xa+1c8pStBlMYmJPJv0Y6m5uNUJAvOImWNoZlyA967Df8b3pbODqhFkUN3OgDyR3uYRxBCohZgmguOvHsqtkM66/QgIMy2vQxhcnzc78dMT/BfLJ13RuN6+9DiGUMuGCzsVgQ7MNQu8MAkUV+fiEdGz6yxskiwpAQ="
    file:
      - "${RELEASE_PKG_FILE_DEB}"
      - "${RELEASE_PKG_FILE_RPM}"
      - "${RELEASE_PKG_FILE_TGZ}"
    skip_cleanup: true
    on:
      repo: analogdevicesinc/libad9361-iio
      tags: true
      condition: "($CC = gcc) && ($TRAVIS_OS_NAME = linux)"
  - provider: releases
    api_key:
      secure: "ocDkFUpRYim0o3kEzO5It8mTjg4FnVYT+KaXoUtZA6r9x6VZteSFvimELIV/WePGnNLOavlXPgRb+cXmJiYSkVkFqrrwRkHgYvTapjPn/LBh0xDQZi9SrvTj/ICW3tMu7Esxqa7P2snhLf7P4XkLMySxeooKe4BoV5Uy8WUy+IE0HCkCxaiokUFEg7UVVDLy5ahTyVcdV4su44E+URCBDTk+UvgKJ3VDjNVDZp8uea7RBRHVfSucb/12AeJr+PkaxrbsqtI+GHMohvmLVBmALkP+WtLLMklxPofEnBW/UV6iU+hvEd6dROqG9T52hDQpcBqdJlqx4C3mHkPpt7lxSFTcyyTKEqRKZA0sBexadMZ3fnS2gNXizstuDAxIuCowc+nOjk1WNAN8z4ADxk5t4ct8U1I7CTA0TgkTzkRizeelTTZCbt8kHwh4oTalBt/5rIg3Tk8+YgrwvuEIAmRwPIORob+xbYGK9GCKwmdfpSuVhcLsgb43eh96ZXQ2bBn30I3pebCMm9xa+1c8pStBlMYmJPJv0Y6m5uNUJAvOImWNoZlyA967Df8b3pbODqhFkUN3OgDyR3uYRxBCohZgmguOvHsqtkM66/QgIMy2vQxhcnzc78dMT/BfLJ13RuN6+9DiGUMuGCzsVgQ7MNQu8MAkUV+fiEdGz6yxskiwpAQ="
    file:
      - "${RELEASE_PKG_FILE_PKG}"
      - "${RELEASE_PKG_FILE_TGZ}"
    skip_cleanup: true
    on:
      repo: analogdevicesinc/libad9361-iio
      tags: true
      condition: "$TRAVIS_OS_NAME = osx"
  - provider: script
    skip_cleanup: true
    script:
      - ${TRAVIS_BUILD_DIR}/CI/travis/deploy
    on:
      condition: "($CC = gcc) && ($TRAVIS_OS_NAME = linux)"
      all_branches: true
  - provider: script
    skip_cleanup: true
    script:
      - ${TRAVIS_BUILD_DIR}/CI/travis/deploy
    on:
      condition: "$TRAVIS_OS_NAME = osx"
      all_branches: true
