From c48c70a69637bdec0fade5805bbe62f20925f53d Mon Sep 17 00:00:00 2001 From: fxliang Date: Thu, 29 Aug 2024 22:52:56 +0800 Subject: [PATCH] fix xbuild.bat PRODUCT_VERSION --- xbuild.bat | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/xbuild.bat b/xbuild.bat index 638b4f0f6..8c33c9dd4 100644 --- a/xbuild.bat +++ b/xbuild.bat @@ -26,17 +26,23 @@ if not defined VERSION_PATCH set VERSION_PATCH=1 if not defined WEASEL_VERSION set WEASEL_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH% if not defined WEASEL_BUILD set WEASEL_BUILD=0 -if not defined PRODUCT_VERSION ( - rem use numeric build version for release build - set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD% - rem for non-release build, try to use git commit hash as product build version - if not defined RELEASE_BUILD ( - rem check if git is installed and available, then get the short commit id of head - git --version >nul 2>&1 - if not errorlevel 1 ( - rem get short commmit id of head - for /F %%i in ('git rev-parse --short HEAD') do (set PRODUCT_VERSION=%WEASEL_VERSION%-%%i) +rem use numeric build version for release build +set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD% +rem for non-release build, try to use git commit hash as product build version +if not defined RELEASE_BUILD ( + rem check if git is installed and available, then get the short commit id of head + git --version >nul 2>&1 + if not errorlevel 1 ( + for /f "delims=" %%i in ('git tag --sort=-creatordate ^| findstr /r "^0."') do ( + set LAST_TAG=%%i + goto found_tag + ) + :found_tag + for /f "delims=" %%i in ('git rev-list %LAST_TAG%..HEAD --count') do ( + set WEASEL_BUILD=%%i ) + rem get short commmit id of head + for /F %%i in ('git rev-parse --short HEAD') do (set PRODUCT_VERSION=%WEASEL_VERSION%.%WEASEL_BUILD%.%%i) ) ) @@ -181,10 +187,8 @@ if %build_installer% == 1 ( "%ProgramFiles(x86)%"\NSIS\Bin\makensis.exe ^ /DWEASEL_VERSION=%WEASEL_VERSION% ^ /DWEASEL_BUILD=%WEASEL_BUILD% ^ + /DPRODUCT_VERSION=%PRODUCT_VERSION% ^ output\install.nsi - if not defined RELEASE_BUILD ( - move output\archives\weasel-%WEASEL_VERSION%.%WEASEL_BUILD%-installer.exe output\archives\weasel-%PRODUCT_VERSION%-installer.exe - ) if errorlevel 1 goto error ) goto end