From ba7dfb360c53b717b76ba7197ae40d2f9f59a659 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 23 Jul 2022 17:51:58 +0200 Subject: [PATCH 1/2] fix: actually substitute variables in pre/post launch Signed-off-by: Sefa Eyeoglu --- launcher/launch/LaunchTask.cpp | 33 +++++++-------------- launcher/launch/LaunchTask.h | 4 +-- launcher/launch/steps/PostLaunchCommand.cpp | 7 +++-- launcher/launch/steps/PreLaunchCommand.cpp | 7 +++-- 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/launcher/launch/LaunchTask.cpp b/launcher/launch/LaunchTask.cpp index 3aa950520..28fcc4f42 100644 --- a/launcher/launch/LaunchTask.cpp +++ b/launcher/launch/LaunchTask.cpp @@ -282,35 +282,22 @@ void LaunchTask::emitFailed(QString reason) Task::emitFailed(reason); } -void LaunchTask::substituteVariables(const QStringList &args) const +void LaunchTask::substituteVariables(QStringList &args) const { - auto variables = m_instance->getVariables(); - auto envVariables = QProcessEnvironment::systemEnvironment(); + auto env = m_instance->createEnvironment(); - for (auto arg : args) { - for (auto key : variables) - { - arg.replace("$" + key, variables.value(key)); - } - for (auto env : envVariables.keys()) - { - arg.replace("$" + env, envVariables.value(env)); - } + for (auto key : env.keys()) + { + args.replaceInStrings("$" + key, env.value(key)); } } -QString LaunchTask::substituteVariables(const QString &cmd) const +void LaunchTask::substituteVariables(QString &cmd) const { - QString out = cmd; - auto variables = m_instance->getVariables(); - for (auto it = variables.begin(); it != variables.end(); ++it) - { - out.replace("$" + it.key(), it.value()); - } - auto env = QProcessEnvironment::systemEnvironment(); - for (auto var : env.keys()) + auto env = m_instance->createEnvironment(); + + for (auto key : env.keys()) { - out.replace("$" + var, env.value(var)); + cmd.replace("$" + key, env.value(key)); } - return out; } diff --git a/launcher/launch/LaunchTask.h b/launcher/launch/LaunchTask.h index 2efe1fa22..9c72b23f0 100644 --- a/launcher/launch/LaunchTask.h +++ b/launcher/launch/LaunchTask.h @@ -105,8 +105,8 @@ class LaunchTask: public Task shared_qobject_ptr getLogModel(); public: - void substituteVariables(const QStringList &args) const; - QString substituteVariables(const QString &cmd) const; + void substituteVariables(QStringList &args) const; + void substituteVariables(QString &cmd) const; QString censorPrivateInfo(QString in); protected: /* methods */ diff --git a/launcher/launch/steps/PostLaunchCommand.cpp b/launcher/launch/steps/PostLaunchCommand.cpp index cf765bc0a..ccf07f220 100644 --- a/launcher/launch/steps/PostLaunchCommand.cpp +++ b/launcher/launch/steps/PostLaunchCommand.cpp @@ -56,9 +56,10 @@ void PostLaunchCommand::executeTask() const QString program = args.takeFirst(); m_process.start(program, args); #else - QString postlaunch_cmd = m_parent->substituteVariables(m_command); - emit logLine(tr("Running Post-Launch command: %1").arg(postlaunch_cmd), MessageLevel::Launcher); - m_process.start(postlaunch_cmd); + m_parent->substituteVariables(m_command); + + emit logLine(tr("Running Post-Launch command: %1").arg(m_command), MessageLevel::Launcher); + m_process.start(m_command); #endif } diff --git a/launcher/launch/steps/PreLaunchCommand.cpp b/launcher/launch/steps/PreLaunchCommand.cpp index bf7d27eb5..0b0392cbb 100644 --- a/launcher/launch/steps/PreLaunchCommand.cpp +++ b/launcher/launch/steps/PreLaunchCommand.cpp @@ -56,9 +56,10 @@ void PreLaunchCommand::executeTask() const QString program = args.takeFirst(); m_process.start(program, args); #else - QString prelaunch_cmd = m_parent->substituteVariables(m_command); - emit logLine(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd), MessageLevel::Launcher); - m_process.start(prelaunch_cmd); + m_parent->substituteVariables(m_command); + + emit logLine(tr("Running Pre-Launch command: %1").arg(m_command), MessageLevel::Launcher); + m_process.start(m_command); #endif } From 9f535f4d1373734a8cb91262dddb437fd6bb270a Mon Sep 17 00:00:00 2001 From: Fintan Martin Date: Sat, 23 Jul 2022 18:36:48 +0100 Subject: [PATCH 2/2] Fix releases --- .github/workflows/trigger_release.yml | 52 +++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml index 45ef72812..af5c21379 100644 --- a/.github/workflows/trigger_release.yml +++ b/.github/workflows/trigger_release.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v3 with: submodules: 'true' - path: 'PolyMC-source' + path: 'PollyMC-source' - name: Download artifacts uses: actions/download-artifact@v3 - name: Grab and store version @@ -34,25 +34,25 @@ jobs: echo "VERSION=$tag_name" >> $GITHUB_ENV - name: Package artifacts properly run: | - mv ${{ github.workspace }}/PolyMC-source PolyMC-${{ env.VERSION }} - mv PolyMC-Linux-Qt6-Portable*/PolyMC-portable.tar.gz PolyMC-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz - mv PolyMC-Linux-Qt6*/PolyMC.tar.gz PolyMC-Linux-Qt6-${{ env.VERSION }}.tar.gz - mv PolyMC-Linux-Portable*/PolyMC-portable.tar.gz PolyMC-Linux-Portable-${{ env.VERSION }}.tar.gz - mv PolyMC-Linux*/PolyMC.tar.gz PolyMC-Linux-${{ env.VERSION }}.tar.gz - mv PolyMC-*.AppImage/PolyMC-*.AppImage PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage - mv PolyMC-macOS*/PolyMC.tar.gz PolyMC-macOS-${{ env.VERSION }}.tar.gz + mv ${{ github.workspace }}/PollyMC-source PollyMC-${{ env.VERSION }} + mv PollyMC-Linux-Qt6-Portable*/PollyMC-portable.tar.gz PollyMC-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz + mv PollyMC-Linux-Qt6*/PollyMC.tar.gz PollyMC-Linux-Qt6-${{ env.VERSION }}.tar.gz + mv PollyMC-Linux-Portable*/PollyMC-portable.tar.gz PollyMC-Linux-Portable-${{ env.VERSION }}.tar.gz + mv PollyMC-Linux*/PollyMC.tar.gz PollyMC-Linux-${{ env.VERSION }}.tar.gz + mv PollyMC-*.AppImage/PollyMC-*.AppImage PollyMC-Linux-${{ env.VERSION }}-x86_64.AppImage + mv PollyMC-macOS*/PollyMC.tar.gz PollyMC-macOS-${{ env.VERSION }}.tar.gz - tar -czf PolyMC-${{ env.VERSION }}.tar.gz PolyMC-${{ env.VERSION }} + tar -czf PollyMC-${{ env.VERSION }}.tar.gz PollyMC-${{ env.VERSION }} - for d in PolyMC-Windows-*; do + for d in PollyMC-Windows-*; do cd "${d}" || continue LEGACY="$(echo -n ${d} | grep -o Legacy || true)" INST="$(echo -n ${d} | grep -o Setup || true)" PORT="$(echo -n ${d} | grep -o Portable || true)" - NAME="PolyMC-Windows" + NAME="PollyMC-Windows" test -z "${LEGACY}" || NAME="${NAME}-Legacy" test -z "${PORT}" || NAME="${NAME}-Portable" - test -z "${INST}" || mv PolyMC-*.exe ../${NAME}-Setup-${{ env.VERSION }}.exe + test -z "${INST}" || mv PollyMC-*.exe ../${NAME}-Setup-${{ env.VERSION }}.exe test -n "${INST}" || zip -r -9 "../${NAME}-${{ env.VERSION }}.zip" * cd .. done @@ -64,20 +64,20 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ github.ref }} - name: PolyMC ${{ env.VERSION }} + name: PollyMC ${{ env.VERSION }} draft: true prerelease: false files: | - PolyMC-Linux-${{ env.VERSION }}.tar.gz - PolyMC-Linux-Portable-${{ env.VERSION }}.tar.gz - PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage - PolyMC-Windows-Legacy-${{ env.VERSION }}.zip - PolyMC-Linux-Qt6-${{ env.VERSION }}.tar.gz - PolyMC-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz - PolyMC-Windows-Legacy-Portable-${{ env.VERSION }}.zip - PolyMC-Windows-Legacy-Setup-${{ env.VERSION }}.exe - PolyMC-Windows-${{ env.VERSION }}.zip - PolyMC-Windows-Portable-${{ env.VERSION }}.zip - PolyMC-Windows-Setup-${{ env.VERSION }}.exe - PolyMC-macOS-${{ env.VERSION }}.tar.gz - PolyMC-${{ env.VERSION }}.tar.gz + PollyMC-Linux-${{ env.VERSION }}.tar.gz + PollyMC-Linux-Portable-${{ env.VERSION }}.tar.gz + PollyMC-Linux-${{ env.VERSION }}-x86_64.AppImage + PollyMC-Windows-Legacy-${{ env.VERSION }}.zip + PollyMC-Linux-Qt6-${{ env.VERSION }}.tar.gz + PollyMC-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz + PollyMC-Windows-Legacy-Portable-${{ env.VERSION }}.zip + PollyMC-Windows-Legacy-Setup-${{ env.VERSION }}.exe + PollyMC-Windows-${{ env.VERSION }}.zip + PollyMC-Windows-Portable-${{ env.VERSION }}.zip + PollyMC-Windows-Setup-${{ env.VERSION }}.exe + PollyMC-macOS-${{ env.VERSION }}.tar.gz + PollyMC-${{ env.VERSION }}.tar.gz