diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index d38d39b23..8f959eea8 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -11,6 +11,11 @@ on: required: true type: string description: 'Build name passed as VC_BUILD_NAME define' + version_patch: + required: false + type: string + default: '' + description: 'Engine version patch number passed as VC_VERSION_PATCH define' jobs: build-appimage: @@ -36,7 +41,7 @@ jobs: sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua5.1.a sudo ln -s /usr/include/luajit-2.1 /usr/include/lua - name: Configure - run: cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1 -DVOXELENGINE_BUILD_TESTS=ON -DVC_BUILD_NAME="${{ inputs.build_name }}" + run: cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1 -DVOXELENGINE_BUILD_TESTS=ON -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}" - name: Build run: cmake --build build -t install - name: Run tests diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 081ba662a..60bf1c628 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -11,6 +11,11 @@ on: required: true type: string description: 'Build name passed as VC_BUILD_NAME define' + version_patch: + required: false + type: string + default: '' + description: 'Engine version patch number passed as VC_VERSION_PATCH define' jobs: build-dmg: @@ -29,7 +34,7 @@ jobs: run: | cmake -DOPENAL_INCLUDE_DIR=$(brew --prefix openal-soft)/include \ -DOPENAL_LIBRARY=$(brew --prefix openal-soft)/lib/libopenal.dylib \ - -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1 -DVC_BUILD_NAME="${{ inputs.build_name }}" + -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVOXELENGINE_BUILD_TESTS=ON -DVOXELENGINE_BUILD_APPDIR=1 -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}" - name: Build run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6b539ba1..78250be9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,24 +13,32 @@ jobs: prepare: runs-on: ubuntu-latest steps: - - run: echo "exists just for outputs" + - id: version + run: | + if [[ "$RELEASE_VERSION" =~ ^[0-9]+\.[0-9]+\.([0-9]+) ]]; then + echo "patch=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" + fi outputs: build_name: '${{ env.RELEASE_VERSION }}' + version_patch: '${{ steps.version.outputs.patch }}' build_linux: needs: [prepare] uses: ./.github/workflows/appimage.yml with: build_name: '${{ needs.prepare.outputs.build_name }}' + version_patch: '${{ needs.prepare.outputs.version_patch }}' build_macos: needs: [prepare] uses: ./.github/workflows/macos.yml with: build_name: '${{ needs.prepare.outputs.build_name }}' + version_patch: '${{ needs.prepare.outputs.version_patch }}' build_windows: needs: [prepare] uses: ./.github/workflows/windows-clang.yml with: build_name: '${{ needs.prepare.outputs.build_name }}' + version_patch: '${{ needs.prepare.outputs.version_patch }}' publish_release: runs-on: ubuntu-latest needs: [build_linux, build_macos, build_windows] diff --git a/.github/workflows/windows-clang.yml b/.github/workflows/windows-clang.yml index 1fe591ac8..d8fd69677 100644 --- a/.github/workflows/windows-clang.yml +++ b/.github/workflows/windows-clang.yml @@ -11,6 +11,11 @@ on: required: true type: string description: 'Build name passed as VC_BUILD_NAME define' + version_patch: + required: false + type: string + default: '' + description: 'Engine version patch number passed as VC_VERSION_PATCH define' jobs: build-windows: @@ -53,7 +58,7 @@ jobs: export VCPKG_ROOT=$(pwd)/vcpkg mkdir build cd build - cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVC_BUILD_NAME="${{ inputs.build_name }}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake .. + cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVC_BUILD_NAME="${{ inputs.build_name }}" -DVC_VERSION_PATCH="${{ inputs.version_patch }}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake .. cmake --build . --config Release - name: Package for Windows run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d93b56a4..4e44e8532 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,14 @@ option(VOXELENGINE_BUILD_TESTS "Build tests" OFF) add_compile_definitions(VC_BUILD_NAME="${VC_BUILD_NAME}") +set(VC_VERSION_PATCH "" CACHE STRING "Engine version patch number") +if(NOT VC_VERSION_PATCH STREQUAL "") + if(NOT VC_VERSION_PATCH MATCHES "^[0-9]+$") + message(FATAL_ERROR "invalid VC_VERSION_PATCH: '${VC_VERSION_PATCH}'") + endif() + add_compile_definitions(VC_VERSION_PATCH=${VC_VERSION_PATCH}) +endif() + # Need for static compilation on Windows with MSVC clang TODO: Make single build # on Windows to avoid dependence on combinations of platforms and compilers and # make it independent diff --git a/doc/en/scripting/builtins/libapp.md b/doc/en/scripting/builtins/libapp.md index 018350b2e..a3eec7986 100644 --- a/doc/en/scripting/builtins/libapp.md +++ b/doc/en/scripting/builtins/libapp.md @@ -119,7 +119,8 @@ app.close_world( ```lua -- Returns the major and minor versions of the engine. -app.get_version() -> int, int +-- If a patch number is available, it also returns it. +app.get_version() -> int, int, int | nil -- Returns the value of a setting. -- Throws an exception if the setting does not exist. diff --git a/doc/ru/scripting/builtins/libapp.md b/doc/ru/scripting/builtins/libapp.md index 2cfd7f2fa..bb6490835 100644 --- a/doc/ru/scripting/builtins/libapp.md +++ b/doc/ru/scripting/builtins/libapp.md @@ -116,7 +116,8 @@ app.close_world( ```lua -- Возвращает мажорную и минорную версии движка. -app.get_version() -> int, int +-- При наличии номера патча возвращает и его. +app.get_version() -> int, int, int | nil -- Возвращает значение настройки. -- Бросает исключение, если настройки не существует. diff --git a/src/constants.hpp b/src/constants.hpp index 4cc29bbdf..259e5f8e7 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -7,6 +7,11 @@ inline constexpr int ENGINE_VERSION_MAJOR = 0; inline constexpr int ENGINE_VERSION_MINOR = 33; +#ifdef VC_VERSION_PATCH +inline constexpr int ENGINE_VERSION_PATCH = VC_VERSION_PATCH; +#else +inline constexpr int ENGINE_VERSION_PATCH = 0; +#endif #ifdef NDEBUG inline constexpr bool ENGINE_DEBUG_BUILD = false; @@ -14,7 +19,13 @@ inline constexpr bool ENGINE_DEBUG_BUILD = false; inline constexpr bool ENGINE_DEBUG_BUILD = true; #endif // NDEBUG -inline const std::string ENGINE_VERSION_STRING = "0.33"; +inline const std::string ENGINE_VERSION_STRING = + std::to_string(ENGINE_VERSION_MAJOR) + "." + + std::to_string(ENGINE_VERSION_MINOR) +#ifdef VC_VERSION_PATCH + + "." + std::to_string(ENGINE_VERSION_PATCH) +#endif + ; inline constexpr uint MAX_SUBPROCESSES = 1; inline constexpr uint MAX_SUBPROCESS_DEPTH = 2; diff --git a/src/engine/WindowControl.cpp b/src/engine/WindowControl.cpp index 5a14c02ba..c3d7be4a9 100644 --- a/src/engine/WindowControl.cpp +++ b/src/engine/WindowControl.cpp @@ -42,8 +42,7 @@ WindowControl::Result WindowControl::initialize() { #endif title += "VoxelCore v"; if (buildName.empty()) { - title += std::to_string(ENGINE_VERSION_MAJOR) + "." + - std::to_string(ENGINE_VERSION_MINOR); + title += ENGINE_VERSION_STRING; } else { title += buildName; } diff --git a/src/logic/scripting/lua/libs/libapp.cpp b/src/logic/scripting/lua/libs/libapp.cpp index 243c9a154..d8a63c720 100644 --- a/src/logic/scripting/lua/libs/libapp.cpp +++ b/src/logic/scripting/lua/libs/libapp.cpp @@ -328,10 +328,15 @@ static int l_delete_world(lua::State* L) { } /// @brief Get engine version -/// @return major, minor +/// @return major, minor, [patch] static int l_get_version(lua::State* L) { return lua::pushvec_stack( - L, glm::vec2(ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR) + L, +#ifdef VC_VERSION_PATCH + glm::vec3(ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR, ENGINE_VERSION_PATCH) +#else + glm::vec2(ENGINE_VERSION_MAJOR, ENGINE_VERSION_MINOR) +#endif ); }