feat: 发布 v3.5.0 版本

This commit is contained in:
huangzhenpc
2025-02-14 16:15:04 +08:00
parent 8b2fbef54a
commit b11452aea8
7 changed files with 369 additions and 164 deletions

138
build.bat
View File

@@ -1,65 +1,119 @@
@echo off
chcp 65001
echo 开始打包流程...
setlocal EnableDelayedExpansion
echo 开始正式版本打包...
:: 设置工作目录为脚本所在目录
cd /d "%~dp0"
:: 激活虚拟环境
if exist "venv\Scripts\activate.bat" (
echo 激活虚拟环境...
call venv\Scripts\activate.bat
) else (
echo 警告: 未找到虚拟环境,使用系统 Python
)
:: 确保安装了必要的包
echo 检查依赖包...
pip install -r requirements.txt
:: 更新版本号
python update_version.py
:: 读取版本号
set /p VERSION=<version.txt
echo 当前版本: %VERSION%
echo 当前版本: !VERSION!
:: 提取主版本号和次版本号 (3.4.4 -> 3.4)
for /f "tokens=1,2 delims=." %%a in ("%VERSION%") do (
:: 提取主版本号和次版本号 (3.4.7 -> 3.4)
for /f "tokens=1,2 delims=." %%a in ("!VERSION!") do (
set MAJOR_VERSION=%%a.%%b
)
echo 主版本目录: %MAJOR_VERSION%
echo 主版本目录: !MAJOR_VERSION!
:: 创建版本目录
set VERSION_DIR=dist\%MAJOR_VERSION%
if not exist "%VERSION_DIR%" (
mkdir "%VERSION_DIR%"
echo 创建目录: %VERSION_DIR%
set VERSION_DIR=dist\!MAJOR_VERSION!
if not exist "!VERSION_DIR!" (
mkdir "!VERSION_DIR!"
echo 创建目录: !VERSION_DIR!
)
:: 使用新的spec文件进行打包
pyinstaller --noconfirm build_nezha.spec
:: 清理 Python 缓存文件
echo 清理Python缓存文件...
for /d /r . %%d in (__pycache__) do @if exist "%%d" rd /s /q "%%d"
del /s /q *.pyc >nul 2>&1
del /s /q *.pyo >nul 2>&1
:: 检查源文件是否存在
echo 检查文件: dist\听泉cursor助手%VERSION%.exe
if not exist "dist\听泉cursor助手%VERSION%.exe" (
echo 错误: 打包后的文件不存在
echo 预期文件路径: dist\听泉cursor助手%VERSION%.exe
:: 清理旧的打包文件
echo 清理旧文件...
if exist "build" rd /s /q "build"
if exist "*.spec" del /f /q "*.spec"
:: 使用优化选项进行打包
echo 开始打包...
pyinstaller ^
--noconfirm ^
--clean ^
--onefile ^
--noconsole ^
--icon=icon/two.ico ^
--name "听泉cursor助手!VERSION!" ^
--add-data "icon;icon" ^
--add-data "version.txt;." ^
--add-data "testversion.txt;." ^
--add-data "requirements.txt;." ^
--exclude-module _tkinter ^
--exclude-module tkinter ^
--exclude-module PIL.ImageTk ^
--exclude-module PIL.ImageWin ^
--exclude-module numpy ^
--exclude-module pandas ^
--exclude-module matplotlib ^
--exclude "__pycache__" ^
--exclude "*.pyc" ^
--exclude "*.pyo" ^
--exclude "*.pyd" ^
main.py
:: 检查打包结果并移动文件
set TEMP_FILE=dist\听泉cursor助手!VERSION!.exe
set TARGET_FILE=!VERSION_DIR!\听泉cursor助手v!VERSION!.exe
echo 检查文件: !TEMP_FILE!
if exist "!TEMP_FILE!" (
echo 正式版本打包成功!
:: 移动到版本目录
echo 移动文件到: !TARGET_FILE!
move "!TEMP_FILE!" "!TARGET_FILE!"
:: 显示文件大小
for %%I in ("!TARGET_FILE!") do (
echo 文件大小: %%~zI 字节
)
echo.
echo 正式版本构建完成!
echo 版本号: v!VERSION!
echo 文件位置: !TARGET_FILE!
) else (
echo 错误: 打包失败,文件不存在
echo 预期文件路径: !TEMP_FILE!
dir /b dist
pause
exit /b 1
)
:: 检查目标目录是否存在
echo 检查目标目录: %VERSION_DIR%
if not exist "%VERSION_DIR%" (
echo 错误: 目标目录不存在
pause
exit /b 1
:: 清理临时文件
echo 清理临时文件...
if exist "build" rd /s /q "build"
if exist "dist\听泉cursor助手!VERSION!.exe" del /f /q "dist\听泉cursor助手!VERSION!.exe"
if exist "*.spec" del /f /q "*.spec"
:: 退出虚拟环境
if exist "venv\Scripts\activate.bat" (
echo 退出虚拟环境...
deactivate
)
:: 移动文件到版本目录
echo 移动文件:
echo 源文件: dist\听泉cursor助手%VERSION%.exe
echo 目标文件: %VERSION_DIR%\听泉cursor助手v%VERSION%.exe
move "dist\听泉cursor助手%VERSION%.exe" "%VERSION_DIR%\听泉cursor助手v%VERSION%.exe"
if errorlevel 1 (
echo 移动文件失败,请检查:
echo 1. 源文件是否存在: dist\听泉cursor助手%VERSION%.exe
echo 2. 目标目录是否可写: %VERSION_DIR%
echo 3. 目标文件是否已存在: %VERSION_DIR%\听泉cursor助手v%VERSION%.exe
dir /b dist
dir /b "%VERSION_DIR%"
pause
exit /b 1
)
echo.
echo 打包完成!
echo 文件保存在: %VERSION_DIR%\听泉cursor助手v%VERSION%.exe
endlocal
pause