test-appimage-qtcli #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test-appimage-qtcli | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash -el {0} | |
| steps: | |
| - name: Setup apt-get | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install wget | |
| sudo apt-get install cmake ninja-build | |
| sudo apt-get install libgl1-mesa-dev libglvnd-dev libxcb-xkb-dev libxkbcommon-x11-dev libvulkan-dev | |
| - name: Setup appimagetool linuxdeploy | |
| run: | | |
| wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage | |
| wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage | |
| wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage | |
| chmod +x linuxdeploy-x86_64.AppImage | |
| chmod +x linuxdeploy-plugin-qt-x86_64.AppImage | |
| chmod +x appimagetool-x86_64.AppImage | |
| mv linuxdeploy-x86_64.AppImage /usr/local/bin/linuxdeploy | |
| mv linuxdeploy-plugin-qt-x86_64.AppImage /usr/local/bin/linuxdeploy-plugin-qt | |
| mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool | |
| - name: Setup miniconda | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| miniforge-version: latest | |
| auto-update-conda: true | |
| channels: conda-forge,defaults | |
| - name: Install conda-forge packages | |
| run: | | |
| conda install conda-forge::qt6-main | |
| - name: Create files | |
| working-directory: ${{github.workspace}} | |
| run: | | |
| mkdir testqtcli | |
| cd testqtcli | |
| # CMakeLists.txt | |
| printf "cmake_minimum_required(VERSION 3.22)\n\nproject(testqtcli LANGUAGES CXX)\n\n" > CMakeLists.txt | |
| printf "find_package(Qt6 REQUIRED COMPONENTS Core)\n\n" >> CMakeLists.txt | |
| printf "set(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_AUTOMOC ON)\nset(CMAKE_AUTORCC ON)\n\n" >> CMakeLists.txt | |
| printf "qt_add_executable(testqtcli main.cpp)\n" >> CMakeLists.txt | |
| printf "target_link_libraries(testqtcli PRIVATE Qt6::Core)\n\n" >> CMakeLists.txt | |
| printf "include(GNUInstallDirs)\n" >> CMakeLists.txt | |
| printf "install(TARGETS testqtcli RUNTIME DESTINATION bin)\n" >> CMakeLists.txt | |
| # main.cpp | |
| printf '#include <QCoreApplication>\n#include <QDebug>\n\n' > main.cpp | |
| printf 'int main(int argc, char* argv[])\n{\n' >> main.cpp | |
| printf '\tQCoreApplication* mroot = new QCoreApplication(argc, argv);\n\n' >> main.cpp | |
| printf '\tqDebug() << "argv[0]: " << argv[0];\n' >> main.cpp | |
| printf '\tqDebug() << "arguments: " << mroot->arguments();\n' >> main.cpp | |
| printf '\tqDebug() << "applicationFilePath: " << mroot->applicationFilePath();\n' >> main.cpp | |
| printf '\tqDebug() << "applicationDirPath: " << mroot->applicationDirPath();\n' >> main.cpp | |
| printf '\tqDebug() << "libraryPaths: " << mroot->libraryPaths();\n\n' >> main.cpp | |
| printf '\treturn mroot->exec();\n}\n' >> main.cpp | |
| - name: Configure CMake | |
| working-directory: ${{github.workspace}}/testqtcli | |
| run: | | |
| cmake \ | |
| -G Ninja \ | |
| -B build \ | |
| -DCMAKE_INSTALL_PREFIX=/usr \ | |
| -DCMAKE_BUILD_TYPE=Release | |
| - name: Build | |
| working-directory: ${{github.workspace}}/testqtcli | |
| run: cmake --build build --config Release | |
| - name: Deploy | |
| working-directory: ${{github.workspace}}/testqtcli | |
| continue-on-error: true | |
| run: | | |
| # run ninja install | |
| DESTDIR=../AppDir ninja -C build install | |
| # provide a manifest file xdg | |
| mkdir -p AppDir/usr/share/metainfo | |
| printf "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<component type=\"desktop-application\">\n<id>com.example.testqtcli</id>\n<name>testqtcli</name>\n<launchable type=\"desktop-id\">com.example.testqtcli.desktop</launchable>\n</component>\n" > "AppDir/usr/share/metainfo/com.example.testqtcli.metainfo.xml" | |
| # provide a desktop file xdg | |
| mkdir -p AppDir/usr/share/applications | |
| printf "[Desktop Entry]\nType=Application\nName=testqtcli\nExec=testqtcli\nIcon=testqtcli\nTerminal=true\nCategories=Utility;\n" > "AppDir/usr/share/applications/com.example.testqtcli.desktop" | |
| # provide an icon | |
| mkdir -p AppDir/usr/share/icons/hicolor/32x32/apps | |
| cp /home/runner/miniconda3/envs/test/share/doc/qt6/global/tools-doc-front-page/images/build-32x32.png AppDir/usr/share/icons/hicolor/32x32/apps/testqtcli.png | |
| # run linuxdeploy | |
| export LD_LIBRARY_PATH=/home/runner/miniconda3/envs/test/lib:/home/runner/miniconda3/lib:/usr/local/lib:/usr/lib | |
| export QMAKE=qmake6 | |
| export DISABLE_COPYRIGHT_FILES_DEPLOYMENT=1 | |
| export LDAI_NO_APPSTREAM=1 | |
| linuxdeploy --appdir AppDir --plugin qt --output appimage | |
| export LD_LIBRARY_PATH= | |
| # move package | |
| mv testqtcli-x86_64.AppImage artifact | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| path: ${{github.workspace}}/testqtcli/artifact |