:: copy thirdparty
xcopy %project_path%\thirdparty\dlls\Win32\Release %project_path%\bin\Win32\Release /y /i

:: 去掉 project_path 可能携带的引号
set project_path=%project_path:"=%

:: cmake configure
cmake -G "Visual Studio 16 2019" -A Win32 -DQt5_DIR=%QTDIR%\lib\cmake\Qt5 -S "%project_path%\VVLive" -B "%project_path%\out/Win32-Release"
if NOT %errorlevel% equ 0 (
    echo [ERROR] Failed to cmake configure
    exit /b 1
)

:: cmake build
cmake --build "%project_path%\out/Win32-Release" --config Release
if NOT %errorlevel% equ 0 (
    echo [ERROR] Failed to cmake build
    exit /b 1
)

:: generate qt.bat
node %project_path%\tools_release\release.js %publish_folder_path% Win32

:: run qt.bat
cd /d %publish_folder_path%
if NOT exist qt.bat (
    echo [ERROR] qt.bat not exist
    exit /b 1
)
call qt.bat
if NOT %errorlevel% equ 0 (
    echo [ERROR] Failed to run qt.bat
    exit /b 1
)
cd /d %publish_folder_path%
del qt.bat

:: tag version
cd /d %project_path%
git commit -m "[release]:%pc_full_version%"
set tag_name="XingmengAnchor/%pc_full_version%"
git tag %tag_name%
git push origin %tag_name%
