|
| 1 | +name: test-appimage-qtcli |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + defaults: |
| 10 | + run: |
| 11 | + shell: bash -el {0} |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Setup apt-get |
| 15 | + run: | |
| 16 | + sudo apt-get update |
| 17 | + sudo apt-get install wget |
| 18 | + sudo apt-get install cmake ninja-build |
| 19 | + sudo apt-get install libgl1-mesa-dev libglvnd-dev libxcb-xkb-dev libxkbcommon-x11-dev libvulkan-dev |
| 20 | +
|
| 21 | + - name: Setup appimagetool linuxdeploy |
| 22 | + run: | |
| 23 | + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage |
| 24 | + wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage |
| 25 | + wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage |
| 26 | + chmod +x linuxdeploy-x86_64.AppImage |
| 27 | + chmod +x linuxdeploy-plugin-qt-x86_64.AppImage |
| 28 | + chmod +x appimagetool-x86_64.AppImage |
| 29 | + mv linuxdeploy-x86_64.AppImage /usr/local/bin/linuxdeploy |
| 30 | + mv linuxdeploy-plugin-qt-x86_64.AppImage /usr/local/bin/linuxdeploy-plugin-qt |
| 31 | + mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool |
| 32 | +
|
| 33 | + - name: Setup miniconda |
| 34 | + uses: conda-incubator/setup-miniconda@v3 |
| 35 | + with: |
| 36 | + miniforge-version: latest |
| 37 | + auto-update-conda: true |
| 38 | + channels: conda-forge,defaults |
| 39 | + |
| 40 | + - name: Install conda-forge packages |
| 41 | + run: | |
| 42 | + conda install conda-forge::qt6-main |
| 43 | +
|
| 44 | + - name: Create files |
| 45 | + working-directory: ${{github.workspace}} |
| 46 | + run: | |
| 47 | + mkdir testqtcli |
| 48 | + cd testqtcli |
| 49 | + # CMakeLists.txt |
| 50 | + printf "cmake_minimum_required(VERSION 3.22)\n\nproject(testqtcli LANGUAGES CXX)\n\n" > CMakeLists.txt |
| 51 | + printf "find_package(Qt6 REQUIRED COMPONENTS Core)\n\n" >> CMakeLists.txt |
| 52 | + printf "set(CMAKE_CXX_STANDARD 17)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\nset(CMAKE_AUTOMOC ON)\nset(CMAKE_AUTORCC ON)\n\n" >> CMakeLists.txt |
| 53 | + printf "qt_add_executable(testqtcli main.cpp)\n" >> CMakeLists.txt |
| 54 | + printf "target_link_libraries(testqtcli PRIVATE Qt6::Core)\n\n" >> CMakeLists.txt |
| 55 | + printf "include(GNUInstallDirs)\n" >> CMakeLists.txt |
| 56 | + printf "install(TARGETS testqtcli RUNTIME DESTINATION bin)\n" >> CMakeLists.txt |
| 57 | + # main.cpp |
| 58 | + printf '#include <QCoreApplication>\n#include <QDebug>\n\n' > main.cpp |
| 59 | + printf 'int main(int argc, char* argv[])\n{\n' >> main.cpp |
| 60 | + printf '\tQCoreApplication* mroot = new QCoreApplication(argc, argv);\n\n' >> main.cpp |
| 61 | + printf '\tqDebug() << "argv[0]: " << argv[0];\n' >> main.cpp |
| 62 | + printf '\tqDebug() << "arguments: " << mroot->arguments();\n' >> main.cpp |
| 63 | + printf '\tqDebug() << "applicationFilePath: " << mroot->applicationFilePath();\n' >> main.cpp |
| 64 | + printf '\tqDebug() << "applicationDirPath: " << mroot->applicationDirPath();\n' >> main.cpp |
| 65 | + printf '\tqDebug() << "libraryPaths: " << mroot->libraryPaths();\n\n' >> main.cpp |
| 66 | + printf '\treturn mroot->exec();\n}\n' >> main.cpp |
| 67 | +
|
| 68 | + - name: Configure CMake |
| 69 | + working-directory: ${{github.workspace}}/testqtcli |
| 70 | + run: | |
| 71 | + cmake \ |
| 72 | + -G Ninja \ |
| 73 | + -B build \ |
| 74 | + -DCMAKE_INSTALL_PREFIX=/usr \ |
| 75 | + -DCMAKE_BUILD_TYPE=Release |
| 76 | +
|
| 77 | + - name: Build |
| 78 | + working-directory: ${{github.workspace}}/testqtcli |
| 79 | + run: cmake --build build --config Release |
| 80 | + |
| 81 | + - name: Deploy |
| 82 | + working-directory: ${{github.workspace}}/testqtcli |
| 83 | + continue-on-error: true |
| 84 | + run: | |
| 85 | + # run ninja install |
| 86 | + DESTDIR=../AppDir ninja -C build install |
| 87 | + # provide a manifest file xdg |
| 88 | + mkdir -p AppDir/usr/share/metainfo |
| 89 | + 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" |
| 90 | + # provide a desktop file xdg |
| 91 | + mkdir -p AppDir/usr/share/applications |
| 92 | + printf "[Desktop Entry]\nType=Application\nName=testqtcli\nExec=testqtcli\nIcon=testqtcli\nTerminal=true\nCategories=Utility;\n" > "AppDir/usr/share/applications/com.example.testqtcli.desktop" |
| 93 | + # provide an icon |
| 94 | + mkdir -p AppDir/usr/share/icons/hicolor/32x32/apps |
| 95 | + 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 |
| 96 | + # run linuxdeploy |
| 97 | + export LD_LIBRARY_PATH=/home/runner/miniconda3/envs/test/lib:/home/runner/miniconda3/lib:/usr/local/lib:/usr/lib |
| 98 | + export QMAKE=qmake6 |
| 99 | + export DISABLE_COPYRIGHT_FILES_DEPLOYMENT=1 |
| 100 | + export LDAI_NO_APPSTREAM=1 |
| 101 | + linuxdeploy --appdir AppDir --plugin qt --output appimage |
| 102 | + export LD_LIBRARY_PATH= |
| 103 | + # move package |
| 104 | + mv testqtcli-x86_64.AppImage artifact |
| 105 | +
|
| 106 | + - name: Upload artifacts |
| 107 | + uses: actions/upload-artifact@v6 |
| 108 | + with: |
| 109 | + path: ${{github.workspace}}/testqtcli/artifact |
0 commit comments