language: cpp
os: linux
stages:
    - name: deploy
      if: branch = master
    - name: before_script
      if: branch = master
jobs:
    include:
    - name: "macOS Build"
      os: osx
      compiler: clang
      osx_image: xcode11.3
      script:
        - bash scripts/build.macos.release.sh
      before_deploy:
        - tar czf subconverter_darwin64.tar.gz subconverter
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_darwin64.tar.gz"
        skip_cleanup: true
        draft: true
        on:
          tags: true
    - name: "Linux x86 Build"
      services: docker
      script:
        - docker run --rm -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:x86-latest-stable /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
      before_deploy:
        - tar czf subconverter_linux32.tar.gz subconverter/
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_linux32.tar.gz"
        skip_cleanup: true
        draft: true
        on:
          tags: true
    - name: "Linux x86_64 Build"
      services: docker
      script:
        - docker run -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:amd64-latest-stable /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
      before_deploy:
        - tar czf subconverter_linux64.tar.gz subconverter/
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_linux64.tar.gz"
        skip_cleanup: true
        draft: true
        on:
          tags: true
    - name: "Linux ARMHF Build"
      services: docker
      arch: arm64
      script:
        - docker run --rm -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:armhf-latest-stable /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
      before_deploy:
        - tar czf subconverter_armhf.tar.gz subconverter/
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_armhf.tar.gz"
        skip_cleanup: true
        draft: true
        on:
          tags: true
    - name: "Linux ARM64 Build"
      services: docker
      arch: arm64
      script:
        - docker run -v $TRAVIS_BUILD_DIR:/root/workdir multiarch/alpine:aarch64-latest-stable /bin/sh -c "apk add bash git && cd /root/workdir && chmod +x scripts/build.alpine.release.sh && bash scripts/build.alpine.release.sh"
      before_deploy:
        - tar czf subconverter_aarch64.tar.gz subconverter/
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_aarch64.tar.gz"
        skip_cleanup: true
        draft: true
        on:
          tags: true
    - name: "Windows x86_64 Build"
      os: windows
      before_install:
      - |-
         [[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
         choco uninstall -y mingw
         choco upgrade --no-progress -y msys2 nodejs
         export msys2='cmd //C RefreshEnv.cmd '
         export msys2+='& set MSYS=winsymlinks:nativestrict '
         export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
         export mingw64="$msys2 -mingw64 -full-path -here -c "\"\$@"\" --"
         export msys2+=" -msys2 -c "\"\$@"\" --"
         $msys2 pacman --sync --noconfirm --needed base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-libevent mingw-w64-x86_64-pcre2 patch
         taskkill //IM gpg-agent.exe //F
         export PATH=/C/tools/msys64/mingw64/bin:$PATH
         export MAKE=make
      before_cache:
      - |-
        $msys2 pacman --sync --clean --noconfirm
      cache:
        directories:
        - $HOME/AppData/Local/Temp/chocolatey
      script:
        - $mingw64 bash scripts/build.windows.release.sh
      before_deploy:
        - 7z a subconverter_win64.7z subconverter/
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_win64.7z"
        skip_cleanup: true
        draft: true
        on:
          tags: true
    - name: "Windows x86 Build"
      os: windows
      before_install:
      - |-
         [[ ! -f C:/tools/msys64/msys2_shell.cmd ]] && rm -rf C:/tools/msys64
         choco uninstall -y mingw
         choco upgrade --no-progress -y msys2 nodejs
         export msys2='cmd //C RefreshEnv.cmd '
         export msys2+='& set MSYS=winsymlinks:nativestrict '
         export msys2+='& C:\\tools\\msys64\\msys2_shell.cmd -defterm -no-start'
         export mingw32="$msys2 -mingw32 -full-path -here -c "\"\$@"\" --"
         export msys2+=" -msys2 -c "\"\$@"\" --"
         $msys2 pacman --sync --noconfirm --needed base-devel git mingw-w64-i686-gcc mingw-w64-i686-cmake mingw-w64-i686-libevent mingw-w64-i686-pcre2 patch
         taskkill //IM gpg-agent.exe //F
         export PATH=/C/tools/msys64/mingw64/bin:$PATH
         export MAKE=make
      before_cache:
      - |-
        $msys2 pacman --sync --clean --noconfirm
      cache:
        directories:
        - $HOME/AppData/Local/Temp/chocolatey
      script:
        - $mingw32 bash scripts/build.windows.release.sh
      before_deploy:
        - 7z a subconverter_win32.7z subconverter/
      deploy:
        provider: releases
        token: "$GITHUB_OAUTH_TOKEN"
        file: "subconverter_win32.7z"
        skip_cleanup: true
        draft: true
        on:
          tags: true
