From 90d4acd1a1c9abeb31548d152c155491e2cf98fa Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Mar 2022 13:20:14 +0100 Subject: [PATCH 1/6] refactor: combine portable and system builds Portable builds now have the same layout as system builds. If you want to build a portable bundle, you now need to additionally install the `portable` component. For example: $ cmake -Bbuild -DCMAKE_INSTALL_PREFIX=install ... $ cmake --build build $ cmake --install build $ cmake --install build --component portable --- CMakeLists.txt | 56 +++++++++++++++---------------------- launcher/Application.cpp | 53 ++++++++++++++++++----------------- launcher/Launcher.in | 2 +- program_info/CMakeLists.txt | 2 ++ program_info/portable.txt | 4 +++ 5 files changed, 58 insertions(+), 59 deletions(-) create mode 100644 program_info/portable.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1350a3ba..cf06fe0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,13 +165,12 @@ add_subdirectory(program_info) ####################################### Install layout ####################################### -# Install the build results according to platform -set(Launcher_PORTABLE 1 CACHE BOOL "The type of installation (Portable or System)") +# TODO: drop this? +# Target install directory, relative to CMAKE_INSTALL_PREFIx +set(BUNDLE_DEST_DIR ".") -if (Launcher_PORTABLE) - # launcher/Application.cpp will use this value - set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_PORTABLE") -endif() +# Install "portable.txt" if selected component is "portable" +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_Portable_File}" DESTINATION ${BUNDLE_DEST_DIR} COMPONENT portable EXCLUDE_FROM_ALL) if(UNIX AND APPLE) set(BINARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS") @@ -180,8 +179,6 @@ if(UNIX AND APPLE) set(RESOURCES_DEST_DIR "${Launcher_Name}.app/Contents/Resources") set(JARS_DEST_DIR "${Launcher_Name}.app/Contents/MacOS/jars") - set(BUNDLE_DEST_DIR ".") - # Apps to bundle set(APPS "\${CMAKE_INSTALL_PREFIX}/${Launcher_Name}.app") @@ -206,30 +203,12 @@ if(UNIX AND APPLE) elseif(UNIX) set(BINARY_DEST_DIR "bin") - if(Launcher_PORTABLE) - set(LIBRARY_DEST_DIR "bin") - set(BUNDLE_DEST_DIR ".") - set(JARS_DEST_DIR "bin/jars") - - # Install basic runner script - configure_file(launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY) - install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" DESTINATION ${BUNDLE_DEST_DIR} RENAME ${Launcher_Name}) - else() - set(LIBRARY_DEST_DIR "lib${LIB_SUFFIX}") - set(JARS_DEST_DIR "share/jars") - set(LAUNCHER_DESKTOP_DEST_DIR "share/applications" CACHE STRING "Path to the desktop file directory") - set(LAUNCHER_METAINFO_DEST_DIR "share/metainfo" CACHE STRING "Path to the metainfo directory") - set(LAUNCHER_ICON_DEST_DIR "share/icons/hicolor/scalable/apps" CACHE STRING "Path to the scalable icon directory") - set(LAUNCHER_MAN_DEST_DIR "share/man/man6" CACHE STRING "Path to the man page directory") - - # jars path is determined on runtime, relative to "Application root path", generally /usr for Launcher_PORTABLE=0 - set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_JARS_LOCATION=${JARS_DEST_DIR}") - - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_Desktop} DESTINATION ${LAUNCHER_DESKTOP_DEST_DIR}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${LAUNCHER_METAINFO_DEST_DIR}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION ${LAUNCHER_ICON_DEST_DIR}) - install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_ManPage} DESTINATION ${LAUNCHER_MAN_DEST_DIR} RENAME "${Launcher_APP_BINARY_NAME}.6") - endif() + set(LIBRARY_DEST_DIR "lib${LIB_SUFFIX}") + set(JARS_DEST_DIR "share/jars") + set(LAUNCHER_DESKTOP_DEST_DIR "share/applications" CACHE STRING "Path to the desktop file directory") + set(LAUNCHER_METAINFO_DEST_DIR "share/metainfo" CACHE STRING "Path to the metainfo directory") + set(LAUNCHER_ICON_DEST_DIR "share/icons/hicolor/scalable/apps" CACHE STRING "Path to the scalable icon directory") + set(LAUNCHER_MAN_DEST_DIR "share/man/man6" CACHE STRING "Path to the man page directory") # install as bundle with no dependencies included set(INSTALL_BUNDLE "nodeps") @@ -237,11 +216,22 @@ elseif(UNIX) # Set RPATH SET(Launcher_BINARY_RPATH "$ORIGIN/") + # jars path is determined on runtime, relative to "Application root path", generally /usr or the root of the portable bundle + set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_JARS_LOCATION=${JARS_DEST_DIR}") + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_Desktop} DESTINATION ${LAUNCHER_DESKTOP_DEST_DIR}) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${LAUNCHER_METAINFO_DEST_DIR}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION ${LAUNCHER_ICON_DEST_DIR}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_ManPage} DESTINATION ${LAUNCHER_MAN_DEST_DIR} RENAME "${Launcher_APP_BINARY_NAME}.6") + + # Install basic runner script if component "portable" is selected + configure_file(launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY) + install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" DESTINATION ${BUNDLE_DEST_DIR} RENAME ${Launcher_Name} COMPONENT portable EXCLUDE_FROM_ALL) + elseif(WIN32) set(BINARY_DEST_DIR ".") set(LIBRARY_DEST_DIR ".") set(PLUGIN_DEST_DIR ".") - set(BUNDLE_DEST_DIR ".") set(RESOURCES_DEST_DIR ".") set(JARS_DEST_DIR "jars") diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 9cca534c..a9f7a0f0 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -316,6 +316,26 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) QString origcwdPath = QDir::currentPath(); QString binPath = applicationDirPath(); + + { + // Root path is used for updates and portable data +#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) + QDir foo(FS::PathCombine(binPath, "..")); // typically portable-root or /usr + m_rootPath = foo.absolutePath(); +#elif defined(Q_OS_WIN32) + m_rootPath = binPath; +#elif defined(Q_OS_MAC) + QDir foo(FS::PathCombine(binPath, "../..")); + m_rootPath = foo.absolutePath(); + // on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues) + FS::updateTimestamp(m_rootPath); +#endif + +#ifdef LAUNCHER_JARS_LOCATION + m_jarsPath = TOSTRING(LAUNCHER_JARS_LOCATION); +#endif + } + QString adjustedBy; QString dataPath; // change folder @@ -324,15 +344,14 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) { // the dir param. it makes multimc data path point to whatever the user specified // on command line - adjustedBy += "Command line " + dirParam; + adjustedBy = "Command line"; dataPath = dirParam; } else { -#if !defined(LAUNCHER_PORTABLE) || defined(Q_OS_MAC) QDir foo(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "..")); dataPath = foo.absolutePath(); - adjustedBy += dataPath; + adjustedBy = "Persistent data path"; #ifdef Q_OS_LINUX // TODO: this should be removed in a future version @@ -340,13 +359,14 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) QDir bar(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), "polymc")); if (bar.exists()) { dataPath = bar.absolutePath(); - adjustedBy += "Legacy data path " + dataPath; + adjustedBy = "Legacy data path"; } #endif -#else - dataPath = applicationDirPath(); - adjustedBy += "Fallback to binary path " + dataPath; -#endif + + if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) { + dataPath = m_rootPath; + adjustedBy = "Portable data path"; + } } if (!FS::ensureFolderPathExists(dataPath)) @@ -535,24 +555,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) qDebug() << "<> Log initialized."; } - // Set up paths { - // Root path is used for updates. -#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) - QDir foo(FS::PathCombine(binPath, "..")); - m_rootPath = foo.absolutePath(); -#elif defined(Q_OS_WIN32) - m_rootPath = binPath; -#elif defined(Q_OS_MAC) - QDir foo(FS::PathCombine(binPath, "../..")); - m_rootPath = foo.absolutePath(); - // on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues) - FS::updateTimestamp(m_rootPath); -#endif - -#ifdef LAUNCHER_JARS_LOCATION - m_jarsPath = TOSTRING(LAUNCHER_JARS_LOCATION); -#endif qDebug() << BuildConfig.LAUNCHER_DISPLAYNAME << ", (c) 2013-2021 " << BuildConfig.LAUNCHER_COPYRIGHT; qDebug() << "Version : " << BuildConfig.printableVersionString(); diff --git a/launcher/Launcher.in b/launcher/Launcher.in index 5e5e2c2b..528e360e 100755 --- a/launcher/Launcher.in +++ b/launcher/Launcher.in @@ -21,7 +21,7 @@ echo "Launcher Dir: ${LAUNCHER_DIR}" # Set up env - filter out input LD_ variables but pass them in under different names export GAME_LIBRARY_PATH=${GAME_LIBRARY_PATH-${LD_LIBRARY_PATH}} export GAME_PRELOAD=${GAME_PRELOAD-${LD_PRELOAD}} -export LD_LIBRARY_PATH="${LAUNCHER_DIR}/bin":$LAUNCHER_LIBRARY_PATH +export LD_LIBRARY_PATH="${LAUNCHER_DIR}/lib@LIB_SUFFIX@":$LAUNCHER_LIBRARY_PATH export LD_PRELOAD=$LAUNCHER_PRELOAD export QT_PLUGIN_PATH="${LAUNCHER_DIR}/plugins" export QT_FONTPATH="${LAUNCHER_DIR}/fonts" diff --git a/program_info/CMakeLists.txt b/program_info/CMakeLists.txt index 9c243826..60549d8d 100644 --- a/program_info/CMakeLists.txt +++ b/program_info/CMakeLists.txt @@ -17,5 +17,7 @@ set(Launcher_Branding_ICNS "program_info/polymc.icns" PARENT_SCOPE) set(Launcher_Branding_WindowsRC "program_info/polymc.rc" PARENT_SCOPE) set(Launcher_Branding_LogoQRC "program_info/polymc.qrc" PARENT_SCOPE) +set(Launcher_Portable_File "program_info/portable.txt" PARENT_SCOPE) + configure_file(org.polymc.PolyMC.desktop.in org.polymc.PolyMC.desktop) configure_file(org.polymc.PolyMC.metainfo.xml.in org.polymc.PolyMC.metainfo.xml) diff --git a/program_info/portable.txt b/program_info/portable.txt new file mode 100644 index 00000000..b7e256a2 --- /dev/null +++ b/program_info/portable.txt @@ -0,0 +1,4 @@ +This file enables the portable mode for the launcher. + +If this file is present in the root directory of the launcher, it will store all data here. Otherwise it will store your data in your appdata directory. +You can safely delete this file, if you don't want the launcher to store your data here. From 6ed130fc1610da8d66ed17be9446e8f53bf96db5 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Mar 2022 14:38:58 +0100 Subject: [PATCH 2/6] fix: don't allow portable builds on macOS --- CMakeLists.txt | 6 ++++-- launcher/Application.cpp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf06fe0d..5061de3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,8 +169,10 @@ add_subdirectory(program_info) # Target install directory, relative to CMAKE_INSTALL_PREFIx set(BUNDLE_DEST_DIR ".") -# Install "portable.txt" if selected component is "portable" -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_Portable_File}" DESTINATION ${BUNDLE_DEST_DIR} COMPONENT portable EXCLUDE_FROM_ALL) +if(NOT (UNIX AND APPLE)) + # Install "portable.txt" if selected component is "portable" + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_Portable_File}" DESTINATION ${BUNDLE_DEST_DIR} COMPONENT portable EXCLUDE_FROM_ALL) +endif() if(UNIX AND APPLE) set(BINARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS") diff --git a/launcher/Application.cpp b/launcher/Application.cpp index a9f7a0f0..6e934fa4 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -363,10 +363,12 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) } #endif +#ifndef Q_OS_MACOS if (QFile::exists(FS::PathCombine(m_rootPath, "portable.txt"))) { dataPath = m_rootPath; adjustedBy = "Portable data path"; } +#endif } if (!FS::ensureFolderPathExists(dataPath)) From b10d4d3b8f68a27434d04ac6c595cea0bc1337af Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Mar 2022 14:42:56 +0100 Subject: [PATCH 3/6] fix: drop BUNDLE_DEST_DIR --- CMakeLists.txt | 8 ++------ launcher/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5061de3b..1f4f4295 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,13 +165,9 @@ add_subdirectory(program_info) ####################################### Install layout ####################################### -# TODO: drop this? -# Target install directory, relative to CMAKE_INSTALL_PREFIx -set(BUNDLE_DEST_DIR ".") - if(NOT (UNIX AND APPLE)) # Install "portable.txt" if selected component is "portable" - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_Portable_File}" DESTINATION ${BUNDLE_DEST_DIR} COMPONENT portable EXCLUDE_FROM_ALL) + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_Portable_File}" DESTINATION "." COMPONENT portable EXCLUDE_FROM_ALL) endif() if(UNIX AND APPLE) @@ -228,7 +224,7 @@ elseif(UNIX) # Install basic runner script if component "portable" is selected configure_file(launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY) - install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" DESTINATION ${BUNDLE_DEST_DIR} RENAME ${Launcher_Name} COMPONENT portable EXCLUDE_FROM_ALL) + install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" DESTINATION "." RENAME ${Launcher_Name} COMPONENT portable EXCLUDE_FROM_ALL) elseif(WIN32) set(BINARY_DEST_DIR ".") diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 0ab398e8..6ed86726 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -991,7 +991,7 @@ if(DEFINED Launcher_APP_BINARY_DEFS) endif() install(TARGETS ${Launcher_Name} - BUNDLE DESTINATION ${BUNDLE_DEST_DIR} COMPONENT Runtime + BUNDLE DESTINATION "." COMPONENT Runtime LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime RUNTIME DESTINATION ${BINARY_DEST_DIR} COMPONENT Runtime ) From 4a971226e4292bb7de9646c199582ab70ef002c5 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Mar 2022 13:52:37 +0100 Subject: [PATCH 4/6] refactor(actions): combine steps for unified builds --- .github/workflows/build.yml | 243 +++++++++++++++++------------------- 1 file changed, 113 insertions(+), 130 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0123c99a..ab80af7e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,14 +17,6 @@ jobs: - os: ubuntu-20.04 - - os: ubuntu-20.04 - portable: true - - - os: ubuntu-20.04 - qt_version: 5.15.2 - qt_host: linux - app_image: true - - os: windows-2022 name: "Windows-i686" msystem: mingw32 @@ -33,16 +25,6 @@ jobs: name: "Windows-x86_64" msystem: mingw64 - - os: windows-2022 - name: "Windows-i686-portable" - msystem: mingw32 - portable: true - - - os: windows-2022 - name: "Windows-x86_64-portable" - msystem: mingw64 - portable: true - - os: macos-11 qt_version: 5.12.12 qt_host: mac @@ -53,9 +35,14 @@ jobs: env: MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }} INSTALL_DIR: "install" + INSTALL_PORTABLE_DIR: "install-portable" + INSTALL_APPIMAGE_DIR: "install-appdir" BUILD_DIR: "build" steps: + ## + # PREPARE + ## - name: Checkout uses: actions/checkout@v3 with: @@ -87,16 +74,16 @@ jobs: distribution: 'temurin' java-version: '17' - - name: Cache Qt - if: runner.os != 'Windows' + - name: Cache Qt (macOS) + if: runner.os == 'macOS' id: cache-qt uses: actions/cache@v3 with: path: "${{ github.workspace }}/Qt/" key: ${{ runner.os }}-${{ matrix.qt_version }}-${{ matrix.qt_arch }}-qt_cache - - name: Install Qt - if: runner.os != 'Linux' && runner.os != 'Windows' || matrix.app_image == true + - name: Install Qt (macOS) + if: runner.os == 'macOS' uses: jurplel/install-qt-action@v2 with: version: ${{ matrix.qt_version }} @@ -105,8 +92,8 @@ jobs: cached: ${{ steps.cache-qt.outputs.cache-hit }} dir: "${{ github.workspace }}/Qt/" - - name: Install System Qt on Linux - if: runner.os == 'Linux' && matrix.app_image != true + - name: Install Qt (Linux) + if: runner.os == 'Linux' run: | sudo apt-get -y update sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 @@ -115,174 +102,170 @@ jobs: if: runner.os != 'Windows' uses: urkle/action-get-ninja@v1 - - name: Download linuxdeploy family for AppImage on Linux - if: matrix.app_image == true + - name: Prepare AppImage (Linux) + if: runner.os == 'Linux' run: | wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage" wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" - - name: Download JREs for AppImage on Linux - if: matrix.app_image == true - shell: bash - run: | ${{ github.workspace }}/.github/scripts/prepare_JREs.sh - - name: Configure CMake - if: runner.os != 'Linux' && runner.os != 'Windows' + ## + # CONFIGURE + ## + + - name: Configure CMake (macOS) + if: runner.os == 'macOS' run: | cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja - - name: Configure CMake on Windows - if: runner.os == 'Windows' && matrix.portable != true + - name: Configure CMake (Windows) + if: runner.os == 'Windows' shell: msys2 {0} run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_PORTABLE=OFF -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja - - name: Configure CMake on Windows portable - if: runner.os == 'Windows' && matrix.portable == true - shell: msys2 {0} + - name: Configure CMake (Linux) + if: runner.os == 'Linux' run: | cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja - - name: Configure CMake on Linux - if: runner.os == 'Linux' && matrix.portable != true - run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DLauncher_PORTABLE=OFF -DENABLE_LTO=ON -G Ninja - - - name: Configure CMake on Linux Portable - if: runner.os == 'Linux' && matrix.portable == true - run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -G Ninja + ## + # BUILD + ## - name: Build if: runner.os != 'Windows' run: | cmake --build ${{ env.BUILD_DIR }} - - name: Build on Windows + - name: Build (Windows) if: runner.os == 'Windows' shell: msys2 {0} run: | cmake --build ${{ env.BUILD_DIR }} - - name: Install - if: runner.os != 'Linux' && runner.os != 'Windows' + ## + # PACKAGE BUILDS + ## + + - name: Package (macOS) + if: runner.os == 'macOS' run: | cmake --install ${{ env.BUILD_DIR }} - - name: Install on Windows + cd ${{ env.INSTALL_DIR }} + macdeployqt "PolyMC.app" -executable="PolyMC.app/Contents/MacOS/polymc" -always-overwrite + chmod +x "PolyMC.app/Contents/MacOS/polymc" + tar -czf ../PolyMC.tar.gz * + + - name: Package (Windows) if: runner.os == 'Windows' shell: msys2 {0} run: | cmake --install ${{ env.BUILD_DIR }} - - name: Install on Linux - if: runner.os == 'Linux' && matrix.portable != true - run: | - DESTDIR=${{ env.INSTALL_DIR }} cmake --install ${{ env.BUILD_DIR }} + cd ${{ env.INSTALL_DIR }} + if [ "${{ matrix.msystem }}" == "mingw32" ]; then + cp /mingw32/bin/libcrypto-1_1.dll /mingw32/bin/libssl-1_1.dll ./ + elif [ "${{ matrix.msystem }}" == "mingw64" ]; then + cp /mingw64/bin/libcrypto-1_1-x64.dll /mingw64/bin/libssl-1_1-x64.dll ./ + fi - - name: Install on Linux portable - if: runner.os == 'Linux' && matrix.portable == true + - name: Package (Windows, portable) + if: runner.os == 'Windows' + shell: msys2 {0} run: | - cmake --install ${{ env.BUILD_DIR }} + cp -r ${{ env.INSTALL_DIR }} ${{ env.INSTALL_PORTABLE_DIR }} # cmake install on Windows is slow, let's just copy instead + cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable - - name: Bundle AppImage - if: matrix.app_image == true + - name: Package (Linux) + if: runner.os == 'Linux' + run: | + cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }} + + cd ${{ env.INSTALL_DIR }} + tar -czf ../PolyMC.tar.gz * + + - name: Package (Linux, portable) + if: runner.os == 'Linux' + run: | + cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} + cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable + + cd ${{ env.INSTALL_PORTABLE_DIR }} + tar -czf ../PolyMC-portable.tar.gz * + + - name: Package AppImage (Linux) + if: runner.os == 'Linux' shell: bash run: | + cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr + export OUTPUT="PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage" chmod +x linuxdeploy-*.AppImage - mkdir -p ${{ env.INSTALL_DIR }}/usr/lib/jvm/java-{8,17}-openjdk + mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-{8,17}-openjdk - cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_DIR }}/usr/lib/jvm/java-8-openjdk + cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk - cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_DIR }}/usr/lib/jvm/java-17-openjdk + cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_DIR }}/usr/lib" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_DIR }}/usr/lib/jvm/java-17-openjdk/lib/server" - LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_DIR }}/usr/lib/jvm/java-17-openjdk/lib" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib/server" + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib" + export LD_LIBRARY_PATH - ./linuxdeploy-x86_64.AppImage --appdir ${{ env.INSTALL_DIR }} --output appimage --plugin qt -i ${{ env.INSTALL_DIR }}/usr/share/icons/hicolor/scalable/apps/org.polymc.PolyMC.svg + ./linuxdeploy-x86_64.AppImage --appdir ${{ env.INSTALL_APPIMAGE_DIR }} --output appimage --plugin qt -i ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/icons/hicolor/scalable/apps/org.polymc.PolyMC.svg - - name: Run macdeployqt + ## + # UPLOAD BUILDS + ## + + - name: Upload binary tarball (macOS) if: runner.os == 'macOS' - run: | - cd ${{ env.INSTALL_DIR }} - macdeployqt "PolyMC.app" -executable="PolyMC.app/Contents/MacOS/polymc" -always-overwrite - - - name: chmod binary on macOS - if: runner.os == 'macOS' - run: | - chmod +x "${{ github.workspace }}/${{ env.INSTALL_DIR }}/PolyMC.app/Contents/MacOS/polymc" - - - name: tar bundle on macOS - if: runner.os == 'macOS' - run: | - cd ${{ env.INSTALL_DIR }} - tar -czf ../PolyMC.tar.gz * - - - name: tar on Linux - if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable != true - run: | - cd ${{ env.INSTALL_DIR }} - tar -czf ../PolyMC.tar.gz * - - - name: tar on Linux portable - if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable == true - run: | - cd ${{ env.INSTALL_DIR }} - tar -czf ../PolyMC-portable.tar.gz * - - - name: Upload Linux tar.gz - if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable != true uses: actions/upload-artifact@v3 with: name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }} path: PolyMC.tar.gz - - name: Upload Linux Portable tar.gz - if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable == true - uses: actions/upload-artifact@v3 - with: - name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }} - path: PolyMC-portable.tar.gz - - - name: Upload AppImage for Linux - if: matrix.app_image == true - uses: actions/upload-artifact@v3 - with: - name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage - path: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage - - - name: Copy OpenSSL libs on Windows x86 - if: runner.os == 'Windows' && matrix.msystem == 'mingw32' - shell: msys2 {0} - run: | - cp /mingw32/bin/libcrypto-1_1.dll ${{ env.INSTALL_DIR }}/ - cp /mingw32/bin/libssl-1_1.dll ${{ env.INSTALL_DIR }}/ - - - name: Copy OpenSSL libs on Windows x86_64 - if: runner.os == 'Windows' && matrix.msystem == 'mingw64' - shell: msys2 {0} - run: | - cp /mingw64/bin/libcrypto-1_1-x64.dll ${{ env.INSTALL_DIR }}/ - cp /mingw64/bin/libssl-1_1-x64.dll ${{ env.INSTALL_DIR }}/ - - - name: Upload package for Windows + - name: Upload binary zip (Windows) if: runner.os == 'Windows' uses: actions/upload-artifact@v3 with: name: PolyMC-${{ matrix.name }}-${{ env.VERSION }}-${{ inputs.build_type }} path: ${{ env.INSTALL_DIR }}/** - - name: Upload package for macOS - if: runner.os == 'macOS' + - name: Upload binary zip (Windows, portable) + if: runner.os == 'Windows' + uses: actions/upload-artifact@v3 + with: + name: PolyMC-${{ matrix.name }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }} + path: ${{ env.INSTALL_PORTABLE_DIR }}/** + + - name: Upload binary tarball (Linux) + if: runner.os == 'Linux' uses: actions/upload-artifact@v3 with: name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }} path: PolyMC.tar.gz + + - name: Upload binary tarball (Linux, portable) + if: runner.os == 'Linux' + uses: actions/upload-artifact@v3 + with: + name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }} + path: PolyMC-portable.tar.gz + + - name: Upload AppImage (Linux) + if: runner.os == 'Linux' + uses: actions/upload-artifact@v3 + with: + name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage + path: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage + + From b0b6dd8f87e5d414045b6c7fe56fbfb128619fca Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 13 Apr 2022 19:27:41 +0200 Subject: [PATCH 5/6] fix(actions): remove macdeployqt --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab80af7e..f6790045 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -156,7 +156,6 @@ jobs: cmake --install ${{ env.BUILD_DIR }} cd ${{ env.INSTALL_DIR }} - macdeployqt "PolyMC.app" -executable="PolyMC.app/Contents/MacOS/polymc" -always-overwrite chmod +x "PolyMC.app/Contents/MacOS/polymc" tar -czf ../PolyMC.tar.gz * From abdb846c3fd9537b7eda47852ad942bc8498663f Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 16 Apr 2022 18:10:47 +0200 Subject: [PATCH 6/6] fix: set install prefix for Linux to /usr --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6790045..4b1195ee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -129,7 +129,7 @@ jobs: - name: Configure CMake (Linux) if: runner.os == 'Linux' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja ## # BUILD