language: swift
osx_image: xcode11.3
xcode_workspace: Example/PerspectiveTransform.xcworkspace
xcode_scheme: Example
xcode_sdk: iphonesimulator13.2
git:
  depth: 1 # use 1, as false cause travis lint server 500 exception
cache:
  bundler: true
  cocoapods: true
bundler_args: --no-deployment
podfile: Example/Podfile
stages:
  - test
  - deploy
matrix:
  include:
  - stage: test
    name: Check dependencies up-to-date, Lint
    env: CACHE_NAME=iOS
    script:
        - bundle exec pod update --project-directory=Example
        - git diff --exit-code # Outdated Cocoapods dependencies found, please run 'pod update' and checkin changes
        - bundle update
        - git diff --exit-code # Outdated Bundle dependencies found, please run 'bundle update' and checkin changes
        - bundle exec pod lib lint || bundle exec pod lib lint --verbose --no-clean
  - name: With coverage report
    env: XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 11 Pro' CACHE_NAME=iOS
    after_success:
      - bash <(curl -s 'https://codecov.io/bash') -Z -J '^PerspectiveTransform$' -X gcov -X fix
  - name: Mac OS
    xcode_scheme: OpenCV Tests
    env: XCODE_DESTINATION='platform=macos' CACHE_NAME=macOS
    before_script: ./Example/OpenCV-OSX-Tests/install-opencv.sh
    cache:
      bundler: true
      cocoapods: true
      directories: # Cache opencv with dependecies
        - /usr/local/Cellar/opencv
        - /usr/local/Cellar/tbb
        - /usr/local/Cellar/openblas
        - /usr/local/Cellar/gcc
        - /usr/local/Cellar/ffmpeg
        - /usr/local/Cellar/libpng
        - /usr/local/Cellar/libtiff
        - /usr/local/Cellar/ilmbase
        - /usr/local/Cellar/openexr
        - /usr/local/Cellar/jpeg
        - /usr/local/Cellar/opencore-amr
        - /usr/local/Cellar/snappy
        - /usr/local/Cellar/lame
        - /usr/local/Cellar/openjpeg
        - /usr/local/Cellar/opus
        - /usr/local/Cellar/speex
        - /usr/local/Cellar/theora
        - /usr/local/Cellar/libogg
        - /usr/local/Cellar/libvorbis
        - /usr/local/Cellar/x264
        - /usr/local/Cellar/x265
        - /usr/local/Cellar/libsoxr
        - /usr/local/Cellar/libbluray
        - /usr/local/Cellar/gnutls
        - /usr/local/Cellar/rtmpdump
        - /usr/local/Cellar/openssl
        - /usr/local/Cellar/fontconfig
        - /usr/local/Cellar/freetype
        - /usr/local/Cellar/p11-kit
        - /usr/local/Cellar/libunistring
        - /usr/local/Cellar/libtasn1
        - /usr/local/Cellar/nettle
        - /usr/local/Cellar/gmp
        - /usr/local/Cellar/libffi
  - stage: deploy
    name: Cartage build, archive, deploy on tag
    env:
    cache: false
    script:
      - brew update > /dev/null
      - brew outdated carthage || brew upgrade carthage
      - carthage build --no-skip-current --platform iOS
      - carthage archive PerspectiveTransform
    deploy:
      provider: releases
      prerelease: true
      name: "Release $TRAVIS_TAG"
      body: "Travis build: https://travis-ci.org/${TRAVIS_REPO_SLUG}/jobs/${TRAVIS_JOB_ID} started by ${TRAVIS_EVENT_TYPE}"
      skip_cleanup: true
      api_key:
        secure: FNzPtWJ1wxgE3LITPT4CSTKboxeJF5tO0SznHMC/pswZeJ7KESZFsRZE0BiPalHT58o7sjW5bjI5GjjTnwLNHC1GpHdH1VRtIPqZF0K6WSfjeZoK5uEURWE3nego4J+h0C9DoQLdvjKwkW9Zw4OvIL1ZLhrqzbix6dcL0M1EGcoavDgkx8c5dsrtOAgafI3owp/RO1JQhPIzKrMwtLNNVHVJthU2ZmOrEngnJhN58hOu+tlcvYmIQvcgqF3S/zUAfsTictc5SiVEezH+lXiDKO361vh5InEMv/+Y9qXM/hZGG1PGdLGGwnVQ9jw2U4SfXNGrudnSxDzbyXLUxE0jeTadX+J9QHOQTaHv2uRevZI4Ok1YFQi/8L+/QSOBSQ1hAeLtvpJ2mGCW5iETbW3KhgShgvexF6tCAEePXIZA0bU9YcTTA0N5R6R09AcZA/jkOoOmwveN00vBsEBfgaEuFOshSPXMCsDl/UMiniU0Xmk47U8ABjAUW3381bMBhiA42Mue8S6bSkZdAoZTuQ/FZSOa4CyeOY6b1dv+kk2Y3rcXK5MmuDypcd2HHDNIWMCAa8zxlyFOd9eZZ2+jNf5XGSudiztMVqoUkosa3WY22GX1cWnRQELuzzAXztv1C6Gckxog4rdU1/U47yhCzYTQqjmwm0b5YqM+Fmsi2uQaOew=
      file: PerspectiveTransform.framework.zip
      on:
        repo: paulz/PerspectiveTransform
        tags: true
before_install:
  - bundle -v || gem install bundler
  - ls -la Example/Pods/Manifest.lock && echo Skipping cocoapods repo update || pod install --project-directory=Example
script:
  - set -o pipefail && xcodebuild test -workspace "$TRAVIS_XCODE_WORKSPACE" -scheme "$TRAVIS_XCODE_SCHEME" -destination "$XCODE_DESTINATION" | bundle exec xcpretty -f `bundle exec xcpretty-travis-formatter`
env:
  - XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 11' CACHE_NAME=iOS
  - XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 11 Pro Max' CACHE_NAME=iOS
  - XCODE_DESTINATION='platform=iOS Simulator,name=iPhone 8 Plus' CACHE_NAME=iOS
branches:
  except:
  - circleci
