diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e0e53231..b846abfd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -153,7 +153,7 @@ jobs: env: MACOSX_DEPLOYMENT_TARGET: "11" run: | - VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )" + VERSION="$(tr -d '\r\n' < VERSION)" SKIP_CODESIGN="${{ env.IS_FORK }}" SKIP_CODESIGN=$(echo "$SKIP_CODESIGN" | tr '[:upper:]' '[:lower:]') ./compileOSX.sh $VERSION ${{ needs.initialization.outputs.build_number }} $SKIP_CODESIGN Qt6 universal @@ -510,7 +510,7 @@ jobs: - name: Get version id: version run: | - VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' ).${{ needs.initialization.outputs.build_number }}" + VERSION="$(tr -d '\r\n' < VERSION).${{ needs.initialization.outputs.build_number }}" echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Version: $VERSION" @@ -577,7 +577,7 @@ jobs: - name: Get version id: version run: | - VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' )" + VERSION="$(tr -d '\r\n' < VERSION)" echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Version: $VERSION" @@ -648,7 +648,7 @@ jobs: - name: Get version id: version run: | - VERSION="$(cat common/yacreader_global.h | grep '#define VERSION "' | tr -d '#define VERSION' | tr -d '"' ).${{ needs.initialization.outputs.build_number }}" + VERSION="$(tr -d '\r\n' < VERSION).${{ needs.initialization.outputs.build_number }}" echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Version: $VERSION" diff --git a/CMakeLists.txt b/CMakeLists.txt index aa4e6da7..84c86400 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,13 @@ cmake_minimum_required(VERSION 3.25...4.3.1) +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" YACREADER_VERSION) +string(STRIP "${YACREADER_VERSION}" YACREADER_VERSION) +if(NOT YACREADER_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$") + message(FATAL_ERROR "VERSION must contain a semantic version like x.y.z") +endif() + project(YACReader - VERSION 10.0.0 + VERSION ${YACREADER_VERSION} LANGUAGES C CXX ) diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..95c4e8d2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +10.0.0 \ No newline at end of file diff --git a/ci/win/create_installer.cmd b/ci/win/create_installer.cmd index 2a658073..2c710359 100644 --- a/ci/win/create_installer.cmd +++ b/ci/win/create_installer.cmd @@ -52,12 +52,8 @@ for /r %src_path%\build %%f in (*.qm) do ( copy %src_path%\vc_redist.%ARCH%.exe . -type %src_path%\common\yacreader_global.h | findstr /R /C:"#define VERSION " > tmp -set /p VERSION= < tmp -set VERSION=%VERSION:#define VERSION "=% -set VERSION=%VERSION:"=% +set /p VERSION=<%src_path%\VERSION echo %VERSION% -del tmp echo "iscc start" iscc /DVERSION=%VERSION% /DPLATFORM=%ARCH% /DCOMPRESSED_ARCHIVE_BACKEND=%COMPRESSION% /DBUILD_NUMBER=%BUILD_NUMBER% build_installer_qt6.iss || exit /b diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 47729aad..96125dd6 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -1,12 +1,23 @@ # Common libraries for YACReader # Fine-grained STATIC targets per concern +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/version.h + @ONLY +) + # --- yr_global (no GUI, used by all 3 apps) --- add_library(yr_global STATIC + ${CMAKE_CURRENT_BINARY_DIR}/version.h + version.h.in yacreader_global.h yacreader_global.cpp ) -target_include_directories(yr_global PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_include_directories(yr_global PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) target_link_libraries(yr_global PUBLIC Qt::Core) if(UNIX AND NOT APPLE) target_compile_definitions(yr_global PRIVATE @@ -171,6 +182,7 @@ target_link_libraries(rhi_flow_reader PUBLIC Qt::Gui Qt::GuiPrivate Qt::Widgets + yr_global ) qt_add_shaders(rhi_flow_reader "flow_shaders_reader" BASE rhi/shaders @@ -194,6 +206,7 @@ target_link_libraries(rhi_flow_library PUBLIC Qt::Gui Qt::GuiPrivate Qt::Widgets + yr_global ) qt_add_shaders(rhi_flow_library "flow_shaders_library" BASE rhi/shaders diff --git a/common/check_new_version.cpp b/common/check_new_version.cpp index 18646a5c..d8a8bf9e 100644 --- a/common/check_new_version.cpp +++ b/common/check_new_version.cpp @@ -6,16 +6,15 @@ #include #include #include -#include -#include #include #include +#include #include #define PREVIOUS_VERSION_TESTING "6.0.0" HttpVersionChecker::HttpVersionChecker() - : HttpWorker("https://raw.githubusercontent.com/YACReader/yacreader/master/common/yacreader_global.h", DEFAULT_USER_AGENT) + : HttpWorker("https://raw.githubusercontent.com/YACReader/yacreader/master/VERSION", DEFAULT_USER_AGENT) { connect(this, &HttpVersionChecker::dataReady, this, QOverload::of(&HttpVersionChecker::checkNewVersion)); } @@ -27,39 +26,17 @@ void HttpVersionChecker::checkNewVersion(const QByteArray &data) bool HttpVersionChecker::checkNewVersion(QString sourceContent) { - QRegExp rx("#define VERSION \"([0-9]+).([0-9]+).([0-9]+)\""); - - bool newVersion = false; - bool sameVersion = true; - // bool currentVersionIsNewer = false; #ifdef QT_DEBUG - QString version(PREVIOUS_VERSION_TESTING); + const auto currentVersion = QVersionNumber::fromString(PREVIOUS_VERSION_TESTING); #else - QString version(VERSION); + const auto currentVersion = QVersionNumber::fromString(QString::fromLatin1(VERSION)); #endif - QStringList sl = version.split("."); - if (rx.indexIn(sourceContent) != -1) { - int length = qMin(sl.size(), (rx.cap(4) != "") ? 4 : 3); - for (int i = 0; i < length; i++) { - if (rx.cap(i + 1).toInt() < sl.at(i).toInt()) { - return false; - } - if (rx.cap(i + 1).toInt() > sl.at(i).toInt()) { - newVersion = true; - break; - } else - sameVersion = sameVersion && rx.cap(i + 1).toInt() == sl.at(i).toInt(); - } - if (!newVersion && sameVersion) { - if ((sl.size() == 3) && (rx.cap(4) != "")) - newVersion = true; - } - } + const auto latestVersion = QVersionNumber::fromString(sourceContent.trimmed()); - if (newVersion == true) { + if (!currentVersion.isNull() && !latestVersion.isNull() && QVersionNumber::compare(latestVersion, currentVersion) > 0) { emit newVersionDetected(); return true; - } else { - return false; } + + return false; } diff --git a/common/version.h.in b/common/version.h.in new file mode 100644 index 00000000..07b9f88d --- /dev/null +++ b/common/version.h.in @@ -0,0 +1,6 @@ +#ifndef YACREADER_VERSION_H +#define YACREADER_VERSION_H + +#define VERSION "@PROJECT_VERSION@" + +#endif diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 750e6c9a..81087862 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -9,7 +9,10 @@ class QLibrary; -#define VERSION "10.0.0" +// Compatibility for already released apps that still parse this file for update checks. +// TODO: remove after old releases have migrated away from scraping this header. +// #define VERSION "10.0.0" +#include "version.h" // Used to check if the database needs to be updated, the version is stored in the database. // This value is only incremented when the database structure changes. diff --git a/compileOSX.sh b/compileOSX.sh index 460c9684..519624df 100755 --- a/compileOSX.sh +++ b/compileOSX.sh @@ -1,7 +1,7 @@ #! /bin/bash set -e -VERSION=${1:-"9.9.1"} +VERSION=${1:-$(tr -d '\r\n' < VERSION)} BUILD_NUMBER=${2:-"0"}