version: 1.0.0+{build}

image:
  - Previous Ubuntu

services:
  - docker

configuration: Release

platform: x64

environment:
  global:
    docker_login: infactum
    docker_password:
      secure: wWPsUiEtw8rfnjX2/Y3/AA==
    docker_image: infactum/tg2sip-builder

  matrix:
    - target_name: Ubuntu Bionic
      docker_tag: bionic

    - target_name: CentOS 7
      docker_tag: centos7

init:
  - sh: |
      docker login -u "$docker_login" -p "$docker_password"
      docker pull "$docker_image":"$docker_tag" 

install:
  - sh: docker build buildenv/ -f buildenv/Dockerfile."$docker_tag" --cache-from "$docker_image":"$docker_tag" -t "$docker_image":"$docker_tag"

build_script: 
  - sh: >- 
      mkdir build;
      docker run --rm -v "$(pwd)":/src "$docker_image" /bin/bash -c "
        mkdir build && cd build;
        export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src
        cmake --build .;
        chmod +x tg2sip;
        chmod +x gen_db;
        cp tg2sip /src/build;
        cp gen_db /src/build;"      
      7z a tg2sip.zip ./build/tg2sip ./build/gen_db ./settings.ini;

after_build:
  - sh: docker push "$docker_image":"$docker_tag"
  - sh: appveyor PushArtifact tg2sip.zip -FileName tg2sip_"$docker_tag".zip -DeploymentName "TG2SIP $target_name"