From 43ac9c38db3a1a8e1a6c882a7fa7967f25e0ec60 Mon Sep 17 00:00:00 2001 From: pajlada Date: Sun, 8 Feb 2026 11:59:34 +0100 Subject: [PATCH] dev: specify nightly tag through cmake instead of modes file (#6798) --- .github/workflows/build.yml | 61 +++++++++++++++++++++- CHANGELOG.md | 1 + CMakeLists.txt | 1 + src/CMakeLists.txt | 1 + src/common/Modes.cpp | 7 +-- src/common/Modes.hpp | 1 - src/common/Version.cpp | 17 +++--- src/common/Version.hpp | 7 +++ src/main.cpp | 3 +- src/singletons/Updates.cpp | 2 +- src/widgets/dialogs/LastRunCrashDialog.cpp | 11 ++-- 11 files changed, 87 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3652679d..aafdc881 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,16 @@ on: - "release/*" pull_request: workflow_dispatch: + inputs: + buildType: + description: "Build type" + required: true + type: choice + default: "auto" + options: + - auto + - nightly + - stable merge_group: concurrency: @@ -18,6 +28,7 @@ concurrency: env: C2_ENABLE_LTO: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/bugfix-release/') || startsWith(github.ref, 'refs/heads/release/') }} CHATTERINO_REQUIRE_CLEAN_GIT: On + CHATTERINO_BUILD_TYPE: ${{ case(inputs.buildType != '', inputs.buildType, 'auto') }} CONAN_VERSION: 2.11.0 jobs: @@ -70,6 +81,29 @@ jobs: run: | git config --global --add safe.directory '*' + - name: Determine build type + id: build-type + shell: bash + run: | + if [ "${CHATTERINO_BUILD_TYPE}" = "auto" ]; then + if git describe --exact-match --match 'v*'; then + echo "Auto - found release tag format" + echo "NIGHTLY_BUILD=Off" >> "$GITHUB_OUTPUT" + else + echo "Auto - did not find release tag format" + echo "NIGHTLY_BUILD=On" >> "$GITHUB_OUTPUT" + fi + elif [ "${CHATTERINO_BUILD_TYPE}" = "nightly" ]; then + echo "Override to nightly" + echo "NIGHTLY_BUILD=On" >> "$GITHUB_OUTPUT" + elif [ "${CHATTERINO_BUILD_TYPE}" = "stable" ]; then + echo "Override to stable" + echo "NIGHTLY_BUILD=Off" >> "$GITHUB_OUTPUT" + else + echo "Error: no build type variable set" + exit 1 + fi + - name: Install Python and libclang (24.04) if: matrix.os == 'ubuntu-24.04' run: | @@ -93,6 +127,7 @@ jobs: -DCHATTERINO_LTO="$C2_ENABLE_LTO" \ -DCMAKE_PREFIX_PATH="$Qt6_DIR/lib/cmake" \ -DCHATTERINO_STATIC_QT_BUILD=On \ + -DCHATTERINO_NIGHTLY_BUILD=${{ steps.build-type.outputs.NIGHTLY_BUILD }} \ -DFORCE_JSON_GENERATION=${{matrix.os == 'ubuntu-24.04' && 'On' || 'Off'}} \ -DCHATTERINO_PLUGINS=${{ matrix.plugins && 'On' || 'Off' }} \ .. @@ -147,6 +182,29 @@ jobs: submodules: recursive fetch-depth: 0 # allows for tags access + - name: Determine build type + id: build-type + shell: bash + run: | + if [ "${CHATTERINO_BUILD_TYPE}" = "auto" ]; then + if git describe --exact-match --match 'v*'; then + echo "Auto - found release tag format" + echo "NIGHTLY_BUILD=Off" >> "$GITHUB_OUTPUT" + else + echo "Auto - did not find release tag format" + echo "NIGHTLY_BUILD=On" >> "$GITHUB_OUTPUT" + fi + elif [ "${CHATTERINO_BUILD_TYPE}" = "nightly" ]; then + echo "Override to nightly" + echo "NIGHTLY_BUILD=On" >> "$GITHUB_OUTPUT" + elif [ "${CHATTERINO_BUILD_TYPE}" = "stable" ]; then + echo "Override to stable" + echo "NIGHTLY_BUILD=Off" >> "$GITHUB_OUTPUT" + else + echo "Error: no build type variable set" + exit 1 + fi + - name: Install Qt6 if: startsWith(matrix.qt-version, '6.') uses: jurplel/install-qt-action@v4.3.0 @@ -219,6 +277,7 @@ jobs: -DUSE_PRECOMPILED_HEADERS=ON ` -DBUILD_WITH_CRASHPAD="$Env:C2_ENABLE_CRASHPAD" ` -DCHATTERINO_LTO="$Env:C2_ENABLE_LTO" ` + -DCHATTERINO_NIGHTLY_BUILD="${{ steps.build-type.outputs.NIGHTLY_BUILD }}" ` -DFORCE_JSON_GENERATION=On ` -DCHATTERINO_SPELLCHECK=On ` .. @@ -243,7 +302,6 @@ jobs: windeployqt bin/chatterino.exe --release --no-compiler-runtime --no-translations --no-opengl-sw --dir Chatterino2/ cp bin/chatterino.exe Chatterino2/ ..\.CI\deploy-crt.ps1 Chatterino2 - echo nightly > Chatterino2/modes - name: Package (windows) if: startsWith(matrix.os, 'windows') @@ -290,6 +348,7 @@ jobs: -DUSE_PRECOMPILED_HEADERS=OFF \ -DCHATTERINO_LTO="$C2_ENABLE_LTO" \ -DFORCE_JSON_GENERATION=Off \ + -DCHATTERINO_NIGHTLY_BUILD=${{ steps.build-type.outputs.NIGHTLY_BUILD }} \ -DCHATTERINO_SPELLCHECK=On \ .. make -j"$(sysctl -n hw.logicalcpu)" diff --git a/CHANGELOG.md b/CHANGELOG.md index cc82868d..6fd50e17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - Bugfix: Disable "Sort Tabs Alphabetically" action when notebook layout is locked. (#6710) - Bugfix: Fix highlight mentions not updating when username changes. (#6723, #6739) - Bugfix: Fixed Return and Enter being treated as different keys on Mac OS. (#6726) +- Dev: Nightly builds are now defined through a build flag rather than the Modes file. (#6798) - Dev: Update release documentation. (#6498) - Dev: Make code sanitizers opt in with the `CHATTERINO_SANITIZER_SUPPORT` CMake option. After that's enabled, use the `SANITIZE_*` flag to enable individual sanitizers. (#6493) - Dev: Remove unused QTextCodec includes. (#6487) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e58ef7d..5c98ce0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ option(CHATTERINO_PLUGINS "Enable ALPHA plugin support in Chatterino" ON) option(CHATTERINO_USE_GDI_FONTENGINE "Use the legacy GDI fontengine instead of the new DirectWrite one on Windows (Qt 6.8.0 and later)" ON) option(CHATTERINO_ALLOW_PRIVATE_QT_API "Allow uses of Qt's private API - when enabling this, Chatterino must use the EXACT Qt version it was compiled against" OFF) option(CHATTERINO_SPELLCHECK "Enable spellchecking in Chatterino (requires Hunspell)" OFF) +option(CHATTERINO_NIGHTLY_BUILD "Specifies whether this is a nightly build." OFF) option(CHATTERINO_SANITIZER_SUPPORT "Attempt to enable Sanitizer support on the test and app targets. Actual sanitizers can then be enabled with the SANITIZE_* options." OFF) mark_as_advanced(CHATTERINO_SANITIZER_SUPPORT) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4d9aa12..0d2e2448 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1133,6 +1133,7 @@ target_compile_definitions(${VERSION_PROJECT} PRIVATE CHATTERINO_GIT_RELEASE=\"${GIT_RELEASE}\" CHATTERINO_GIT_COMMIT=\"${GIT_COMMIT}\" CHATTERINO_GIT_MODIFIED=${GIT_MODIFIED} + CHATTERINO_NIGHTLY_BUILD=$ CHATTERINO_CMAKE_GEN_DATE=\"${cmake_gen_date}\" ) diff --git a/src/common/Modes.cpp b/src/common/Modes.cpp index 30bf1059..0b232961 100644 --- a/src/common/Modes.cpp +++ b/src/common/Modes.cpp @@ -22,12 +22,7 @@ Modes::Modes() { auto line = QString(file.readLine()).trimmed(); - // we need to know if it is a nightly build to disable updates on windows - if (line == "nightly") - { - this->isNightly = true; - } - else if (line == "portable") + if (line == "portable") { this->isPortable = true; } diff --git a/src/common/Modes.hpp b/src/common/Modes.hpp index 30069732..9d4594b6 100644 --- a/src/common/Modes.hpp +++ b/src/common/Modes.hpp @@ -13,7 +13,6 @@ public: static const Modes &instance(); - bool isNightly{}; bool isPortable{}; /// Marked by the line `externally-packaged` diff --git a/src/common/Version.cpp b/src/common/Version.cpp index 319b2664..ddda8ea9 100644 --- a/src/common/Version.cpp +++ b/src/common/Version.cpp @@ -4,24 +4,22 @@ #include "common/Version.hpp" -#include "common/Literals.hpp" -#include "common/Modes.hpp" - #include #include -namespace chatterino { +using namespace Qt::StringLiterals; -using namespace literals; +namespace chatterino { Version::Version() : version_(CHATTERINO_VERSION) , commitHash_(QStringLiteral(CHATTERINO_GIT_HASH)) , isModified_(CHATTERINO_GIT_MODIFIED == 1) , dateOfBuild_(QStringLiteral(CHATTERINO_CMAKE_GEN_DATE)) + , isNightly_(CHATTERINO_NIGHTLY_BUILD == 1) { this->fullVersion_ = "Chatterino "; - if (Modes::instance().isNightly) + if (this->isNightly()) { this->fullVersion_ += "Nightly "; } @@ -129,6 +127,11 @@ const QString &Version::extraString() const return this->extraString_; } +bool Version::isNightly() const +{ + return this->isNightly_; +} + void Version::generateBuildString() { // e.g. Chatterino 2.3.5 or Chatterino Nightly 2.3.5 @@ -151,7 +154,7 @@ void Version::generateBuildString() s += " built"; // If the build is a nightly build (decided with modes atm), include build date information - if (Modes::instance().isNightly) + if (this->isNightly()) { s += " on " + this->dateOfBuild(); } diff --git a/src/common/Version.hpp b/src/common/Version.hpp index 1b794813..a680ed37 100644 --- a/src/common/Version.hpp +++ b/src/common/Version.hpp @@ -63,6 +63,11 @@ public: // Returns an extra string about this specific build const QString &extraString() const; + /// Returns true if this build is classified as a "nightly" (i.e. dev or unstable) build. + /// + /// This is controlled by the CMake parameter CHATTERINO_NIGHTLY_BUILD, which defaults to off. + bool isNightly() const; + #ifdef Q_OS_WIN /// Chatterino's App ID on Windows /// @@ -92,6 +97,8 @@ private: // Generate an extra string (e.g. "Built for Fedora 42.
Report bugs here") void generateExtraString(); + bool isNightly_; + #ifdef Q_OS_WIN std::wstring appUserModelID_; #endif diff --git a/src/main.cpp b/src/main.cpp index 1df5bfdf..7eb10ec6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,8 +102,7 @@ int main(int argc, char **argv) QString("%1 (commit %2%3)") .arg(version.fullVersion()) .arg(version.commitHash()) - .arg(Modes::instance().isNightly ? ", " + version.dateOfBuild() - : ""); + .arg(version.isNightly() ? ", " + version.dateOfBuild() : ""); std::cout << versionMessage.toLocal8Bit().constData() << '\n'; std::cout.flush(); } diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index 4a58b4ed..1e1ed760 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -315,7 +315,7 @@ void Updates::checkForUpdates() } // Disable updates if on nightly - if (Modes::instance().isNightly) + if (version.isNightly()) { return; } diff --git a/src/widgets/dialogs/LastRunCrashDialog.cpp b/src/widgets/dialogs/LastRunCrashDialog.cpp index d91ce70b..50735b68 100644 --- a/src/widgets/dialogs/LastRunCrashDialog.cpp +++ b/src/widgets/dialogs/LastRunCrashDialog.cpp @@ -5,8 +5,7 @@ #include "widgets/dialogs/LastRunCrashDialog.hpp" #include "common/Args.hpp" -#include "common/Literals.hpp" -#include "common/Modes.hpp" +#include "common/Version.hpp" // IWYU pragma: keep #include "singletons/Paths.hpp" #include "util/LayoutCreator.hpp" @@ -21,9 +20,9 @@ #include #include -namespace { +using namespace Qt::StringLiterals; -using namespace chatterino::literals; +namespace { const std::initializer_list MESSAGES = { u"Oops..."_s, u"NotLikeThis"_s, @@ -45,8 +44,6 @@ QString randomMessage() namespace chatterino { -using namespace literals; - LastRunCrashDialog::LastRunCrashDialog(const Args &args, const Paths &paths) { this->setWindowFlag(Qt::WindowContextHelpButtonHint, false); @@ -85,7 +82,7 @@ LastRunCrashDialog::LastRunCrashDialog(const Args &args, const Paths &paths) "the crash " u"so it can be prevented in the future."_s; - if (Modes::instance().isNightly) + if (Version::instance().isNightly()) { text += u" Make sure you're using the latest nightly version!"_s; }