@echo off setlocal set "ROOT=%~dp0..\.." for %%I in ("%ROOT%") do set "ROOT=%%~fI" set "VERSION_SCRIPT=%ROOT%\scripts\release\get-app-version.ps1" set "JRE_DIR=%SSH_MANAGER_WINDOWS_JRE_DIR%" cd /d "%ROOT%" where powershell >nul 2>nul if errorlevel 1 ( echo [ERROR] 未检测到 PowerShell,无法解析版本号 pause exit /b 1 ) for /f "usebackq delims=" %%V in (`powershell -NoProfile -ExecutionPolicy Bypass -File "%VERSION_SCRIPT%"`) do set "APP_VERSION=%%V" if not defined APP_VERSION ( echo [ERROR] 无法从 backend\pom.xml 读取版本号 pause exit /b 1 ) echo [INFO] 当前发布版本: %APP_VERSION% where npm >nul 2>nul if errorlevel 1 ( echo [ERROR] 未检测到 npm,请先安装 Node.js 18+ pause exit /b 1 ) where mvn >nul 2>nul if errorlevel 1 ( echo [ERROR] 未检测到 Maven,请先安装 Maven 3.6+ pause exit /b 1 ) if not defined JRE_DIR ( echo [ERROR] 请先设置环境变量 SSH_MANAGER_WINDOWS_JRE_DIR,指向已解压的 Windows JRE 目录 pause exit /b 1 ) if not exist "%JRE_DIR%\bin\javaw.exe" ( echo [ERROR] %JRE_DIR% 不是有效的 Windows JRE 目录,缺少 bin\javaw.exe pause exit /b 1 ) if not exist "%ROOT%\scripts\installer\ssh-manager.iss" ( echo [ERROR] 缺少安装器脚本 scripts\installer\ssh-manager.iss pause exit /b 1 ) if not exist "%ROOT%\scripts\installer\assets\ssh-manager.ico" ( echo [ERROR] 缺少安装器图标 scripts\installer\assets\ssh-manager.ico pause exit /b 1 ) if not exist "%ROOT%\docs\windows-buyer-guide.md" ( echo [ERROR] 缺少 docs\windows-buyer-guide.md pause exit /b 1 ) if not exist "%ROOT%\docs\windows-after-sales-faq.md" ( echo [ERROR] 缺少 docs\windows-after-sales-faq.md pause exit /b 1 ) where ISCC.exe >nul 2>nul if errorlevel 1 ( echo [WARN] 未检测到 ISCC.exe,本次只能验证构建链路,暂时无法生成 Setup.exe ) else ( echo [INFO] 已检测到 Inno Setup 编译器 ISCC.exe ) echo [1/4] 构建前端... cd /d "%ROOT%\frontend" call npm run build if errorlevel 1 ( echo [ERROR] 前端构建失败 pause exit /b 1 ) if not exist "%ROOT%\frontend\dist\index.html" ( echo [ERROR] 前端 dist 产物不完整,缺少 frontend\dist\index.html pause exit /b 1 ) echo [2/4] 打包后端(内嵌前端静态资源)... cd /d "%ROOT%\backend" call mvn -Pembed-frontend-dist -DskipTests package if errorlevel 1 ( echo [ERROR] 后端打包失败 pause exit /b 1 ) dir /b "%ROOT%\backend\target\*.jar" >nul 2>nul if errorlevel 1 ( echo [ERROR] 后端产物不完整,未找到 target\*.jar pause exit /b 1 ) echo [3/4] 检查安装器输入文件... if not exist "%ROOT%\scripts\windows\start-installed.ps1" ( echo [ERROR] 缺少 scripts\windows\start-installed.ps1 pause exit /b 1 ) if not exist "%ROOT%\scripts\windows\start-installed.cmd" ( echo [ERROR] 缺少 scripts\windows\start-installed.cmd pause exit /b 1 ) if not exist "%ROOT%\scripts\windows\start-installed.vbs" ( echo [ERROR] 缺少 scripts\windows\start-installed.vbs pause exit /b 1 ) if not exist "%ROOT%\scripts\windows\stop-installed.ps1" ( echo [ERROR] 缺少 scripts\windows\stop-installed.ps1 pause exit /b 1 ) if not exist "%ROOT%\scripts\windows\stop-installed.cmd" ( echo [ERROR] 缺少 scripts\windows\stop-installed.cmd pause exit /b 1 ) echo [4/4] 发布预检完成 echo [OK] Windows 发布预检通过 echo [OK] 版本号: %APP_VERSION% echo [OK] 下一步执行: echo scripts\release\build-windows-installer.bat pause endlocal