version: 1
script:
  - rm -rf AppDir appimage-builder-cache *.AppImage *.zsync |true
  - mkdir -p AppDir/usr/share/icons/hicolor/scalable/apps
  - mkdir -p AppDir/usr/share/applications
  - wget -O bearhub-${BEARHUB_VERSION}.tar.gz https://github.com/spalencsar/bearhub/archive/refs/tags/${BEARHUB_VERSION}.tar.gz || exit 1
  - tar -xf bearhub-${BEARHUB_VERSION}.tar.gz || exit 1
  - cd bearhub-${BEARHUB_VERSION} || exit 1
  - python3 -m build --wheel --no-isolation || exit 1
  - python3 -m installer --destdir=../AppDir --prefix=/usr dist/*.whl || exit 1
  - test -e ../AppDir/usr/bin/bearhub || exit 1
  - test -e ../AppDir/usr/bin/bearhub-tray || exit 1
  - cp bearhub/view/resources/img/logo.svg ../AppDir/usr/share/icons/hicolor/scalable/apps/bearhub.svg || exit 1
  - cp bearhub/desktop/bearhub.desktop ../AppDir/usr/share/applications || exit 1
  - cp bearhub/desktop/bearhub_tray.desktop ../AppDir/usr/share/applications || exit 1

AppDir:
  path: ./AppDir

  app_info:
    id: bearhub
    name: Bearhub
    icon: bearhub
    version: !ENV ${BEARHUB_VERSION}
    exec: /usr/bin/python3
    exec_args: "$APPDIR/usr/bin/bearhub $@"

  apt:
    arch: amd64
    sources:
      - sourceline: 'deb http://deb.debian.org/debian/ bullseye main contrib non-free'
        key_url: 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xa4285295fc7b1a81600062a9605c66f00d6c9793'

    include:
      - python3
      - python3-requests
      - python3-colorama
      - python3-dateutil
      - python3-yaml
      - python3-lxml
      - python3-bs4
      - sqlite3
      - xdg-utils
    exclude:
      - dpkg
      - apt
      - aptitude
      - python3-pip
      - python3-setuptools
      - python3-distutils

  after_bundle:
      - pip3 install pyqt5==5.15.10 --prefix=/usr --root=AppDir || exit 1
      - rm -rf AppDir/usr/share/doc || exit 1
      - cd AppDir/usr/lib/python3.9/site-packages/PyQt5/Qt5/plugins || exit 1
      - rm -rf audio gamepad gamepads geoservices printsupport sceneparsers sensorgestures sensors sqldrivers texttospeech webview mediaservice playlistformats || exit 1
      - cd ../lib/ || exit 1
      - rm libQt5Bluetooth.so.5 libQt5Designer.so.5 libQt5Multimedia.so.5 libQt5MultimediaGstTools.so.5 libQt5MultimediaWidgets.so.5 || exit 1
      - rm libQt5Quick3D.so.5 libQt5Quick3DAssetImport.so.5 libQt5Quick3DRender.so.5 libQt5Quick3DRuntimeRender.so.5 libQt5QuickTest.so.5 || exit 1
      - rm libQt5Quick3DUtils.so.5 libQt5PrintSupport.so.5 libQt5SerialPort.so.5 libQt5Sql.so.5 libQt5Sensors.so.5 libQt5Test.so.5 libQt5WebView.so.5 || exit 1
      - rm libQt5Quick.so.5 libQt5Location.so.5 libQt5QuickTemplates2.so.5 || exit 1
      - cd ../qml || exit 1
      - rm -rf QtBluetooth QtMultimedia QtQuick QtQuick.2 QtQuick3D QtRemoteObjects QtSensors QtTest
      - cd ../../ || exit 1
      - rm QtBluetooth.abi3.so QtMultimedia.abi3.so QtMultimediaWidgets.abi3.so QtPrintSupport.abi3.so QtQuick.abi3.so QtQuick3D.abi3.so QtQuickWidgets.abi3.so QtRemoteObjects.abi3.so QtSensors.abi3.so QtSerialPort.abi3.so QtSql.abi3.so QtTest.abi3.so QtTextToSpeech.abi3.so QtWebSockets.abi3.so|| exit 1
      - rm QtBluetooth.pyi QtMultimedia.pyi QtMultimediaWidgets.pyi QtPrintSupport.pyi QtQuick3D.pyi QtQuickWidgets.pyi QtSensors.pyi QtSerialPort.pyi QtSql.pyi
      - cd bindings || exit 1
      - rm -rf QtBluetooth QtMultimedia QtMultimediaWidgets QtPrintSupport QtSensors QtSerialPort QtTextToSpeech QtQuick QtQuick3D QtQuickWidgets QtSql QtTest || exit 1
  runtime:
    version: "v1.2.5"
    env:
      PYTHONHOME: '${APPDIR}/usr'
      PYTHONPATH: '${APPDIR}/usr/lib/python3.9/site-packages'

  test:
    fedora:
      image: appimagecrafters/tests-env:fedora-30
      command: ./AppRun --version
      use_host_x: true
    debian:
      image: appimagecrafters/tests-env:debian-stable
      command: ./AppRun --version
      use_host_x: true
    arch:
      image: appimagecrafters/tests-env:archlinux-latest
      command: ./AppRun --version
      use_host_x: true
    centos:
      image: appimagecrafters/tests-env:centos-7
      command: ./AppRun --version
      use_host_x: true
    ubuntu:
      image: appimagecrafters/tests-env:ubuntu-xenial
      command: ./AppRun --version
      use_host_x: true

AppImage:
  update-information: 'gh-releases-zsync|spalencsar|bearhub|latest|bearhub-*x86_64.AppImage.zsync'
  sign-key: None
  arch: x86_64