linux:appimage:
    image: ubuntu:16.04
    stage: build
    before_script:
        - apt-get update -qq
        - apt-get install -y libpython3-dev python3-pip software-properties-common desktop-file-utils wget zlib1g-dev libpotrace-dev zip libarchive-dev x264 libvpx3
        - add-apt-repository ppa:beineri/opt-qt-5.15.2-xenial -y
        - add-apt-repository ppa:ubuntu-toolchain-r/test -y
        - apt update -qq
        - apt-get install -y qt515base qt515tools qt515translations libgl1-mesa-dev g++-9 qt515svg
        - pip3 install cmake==3.22.6
        - echo libav from source
        - apt-get install -y git build-essential nasm pkg-config
        - git clone https://github.com/FFmpeg/FFmpeg.git --branch release/4.4
        - cd FFmpeg/
        - ./configure --disable-static --enable-shared
        - make
        - make install
        - cd ..
    script:
        - mkdir build
        - cd external/QtAppSetup/external/pybind11/
        - git remote -v
        - git fetch -v --tags origin v2.9.2
        - git tag
        - git checkout v2.9.2
        - cd ../../../..
        - cd build
        - cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_COMPILER=/usr/bin/g++-9 -DCMAKE_PREFIX_PATH=/opt/qt515/lib/cmake/Qt5LinguistTools/ -DVERSION_SUFFIX="appimage-$CI_COMMIT_SHORT_SHA"
        - make
        - make translations
        - make install DESTDIR=AppDir >/dev/null
        - mkdir AppDir/usr/lib
        - cp -r /usr/lib/python3.* AppDir/usr/lib
        - cp ../deploy/app_run.sh AppDir/AppRun
        - chmod a+x AppDir/AppRun
        - cp AppDir/usr/share/glaxnimate/glaxnimate/glaxnimate.desktop AppDir
        - cp AppDir/usr/share/glaxnimate/glaxnimate/images/glaxnimate.png AppDir
        - wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
        - chmod a+x linuxdeployqt-continuous-x86_64.AppImage
        - ./linuxdeployqt-continuous-x86_64.AppImage --appimage-extract
        - ls -l /usr/local/lib/
        - ldd AppDir/usr/bin/glaxnimate
        - LD_LIBRARY_PATH="/usr/local/lib/:$LD_LIBRARY_PATH" ldd AppDir/usr/bin/glaxnimate
        - PATH="/opt/qt515/bin/:$PATH" LD_LIBRARY_PATH="/usr/local/lib/:$LD_LIBRARY_PATH" VERSION=dev ./squashfs-root/AppRun AppDir/glaxnimate.desktop -extra-plugins=iconengines,platformthemes,imageformats -bundle-non-qt-libs -appimage
        - mv glaxnimate-dev-x86_64.AppImage glaxnimate-x86_64.AppImage
        - sha1sum glaxnimate-x86_64.AppImage >checksum.txt
    artifacts:
        paths:
            - build/glaxnimate-x86_64.AppImage
            - build/checksum.txt
    when: always
