release: 封版 v0.4.16 中文正式版

This commit is contained in:
zhy200308
2026-08-12 14:48:09 +08:00
parent 1c5e015285
commit f248deac17
10 changed files with 185 additions and 65 deletions
+59 -20
View File
@@ -1,46 +1,85 @@
@echo off
setlocal EnableExtensions
chcp 65001 >nul
setlocal EnableExtensions DisableDelayedExpansion
cd /d "%~dp0"
echo == QFT Rust one-click package ==
echo == QFT 正式版中文打包 ==
where cargo >nul 2>nul
if errorlevel 1 (
echo ERROR: Rust cargo was not found in PATH.
echo 错误:PATH 中未找到 Rust cargo。
exit /b 1
)
echo [1/3] Testing and building the Rust Windows release...
pushd windows
cargo test
echo [1/4] 测试并构建 Windows 正式版...
pushd desktop
cargo test --locked
if errorlevel 1 (popd & exit /b 1)
cargo build --release
cargo build --release --locked
if errorlevel 1 (popd & exit /b 1)
popd
for /f "tokens=3" %%V in ('findstr /R /C:"^version =" "windows\Cargo.toml"') do set "QFT_VERSION=%%~V"
for /f "tokens=3" %%V in ('findstr /R /C:"^version =" "desktop\Cargo.toml"') do set "QFT_VERSION=%%~V"
for /f "tokens=3" %%V in ('findstr /R /C:"^[ ]*versionName =" "android\app\build.gradle.kts"') do set "QFT_ANDROID_VERSION=%%~V"
for /f "tokens=3" %%V in ('findstr /R /C:"^[ ]*versionCode =" "android\app\build.gradle.kts"') do set "QFT_ANDROID_CODE=%%V"
for /f "usebackq delims=" %%T in (`powershell -NoProfile -Command "Get-Date -Format yyyyMMdd-HHmmss"`) do set "QFT_STAMP=%%T"
for /f "usebackq delims=" %%C in (`git rev-parse --short HEAD 2^>nul`) do set "QFT_RELEASE_COMMIT=%%C"
if not defined QFT_VERSION set "QFT_VERSION=unknown"
set "QFT_PACKAGE=QFT-Rust-%QFT_VERSION%-%QFT_STAMP%-windows"
if not defined QFT_ANDROID_VERSION set "QFT_ANDROID_VERSION=unknown"
if not defined QFT_ANDROID_CODE set "QFT_ANDROID_CODE=unknown"
if not defined QFT_RELEASE_COMMIT set "QFT_RELEASE_COMMIT=unknown"
if /I "%QFT_ANDROID_VERSION%"=="%QFT_VERSION%" goto versions_ok
echo 错误:PC 版本 %QFT_VERSION% 与 Android 版本 %QFT_ANDROID_VERSION% 不一致,拒绝封版。
exit /b 1
:versions_ok
set "QFT_PACKAGE=QFT-正式版-v%QFT_VERSION%-Windows-%QFT_STAMP%"
set "QFT_PACKAGE_DIR=%CD%\dist\%QFT_PACKAGE%"
echo [2/3] Collecting Rust artifacts...
echo [2/4] 收集正式版文件...
mkdir "%QFT_PACKAGE_DIR%" || exit /b 1
copy /y "windows\target\release\qft-windows.exe" "%QFT_PACKAGE_DIR%\QFT-Windows.exe" >nul || exit /b 1
copy /y "README.md" "%QFT_PACKAGE_DIR%\README.md" >nul || exit /b 1
copy /y "TEST_REPORT.md" "%QFT_PACKAGE_DIR%\TEST_REPORT.md" >nul || exit /b 1
copy /y "docs\PROTOCOL.md" "%QFT_PACKAGE_DIR%\PROTOCOL.md" >nul || exit /b 1
copy /y "desktop\target\release\qft-desktop.exe" "%QFT_PACKAGE_DIR%\QFT超速文件传输.exe" >nul || exit /b 1
copy /y "README.md" "%QFT_PACKAGE_DIR%\使用说明.md" >nul || exit /b 1
copy /y "TEST_REPORT.md" "%QFT_PACKAGE_DIR%\测试报告.md" >nul || exit /b 1
copy /y "docs\PROTOCOL.md" "%QFT_PACKAGE_DIR%\传输协议.md" >nul || exit /b 1
copy /y "RELEASE_NOTES_%QFT_VERSION%.md" "%QFT_PACKAGE_DIR%\版本说明.md" >nul || exit /b 1
echo [3/3] Writing SHA-256 checksums and ZIP archive...
rem 仅收集已经由用户在 Windows 上构建好的 APK,不调用 Gradle/Android SDK。
set "QFT_APK=%QFT_ANDROID_APK%"
if defined QFT_APK goto apk_resolved
if exist "android\app\build\outputs\apk\release\app-release.apk" set "QFT_APK=android\app\build\outputs\apk\release\app-release.apk"
if defined QFT_APK goto apk_resolved
if exist "android\app\build\outputs\apk\debug\app-debug.apk" set "QFT_APK=android\app\build\outputs\apk\debug\app-debug.apk"
:apk_resolved
if not defined QFT_APK goto apk_missing
if not exist "%QFT_APK%" goto apk_missing
copy /y "%QFT_APK%" "%QFT_PACKAGE_DIR%\QFT安卓端-v%QFT_VERSION%.apk" >nul || exit /b 1
echo 已收集 Android APK:%QFT_APK%
goto apk_done
:apk_missing
echo 提示:未发现已构建 APK,本次生成 Windows 桌面端正式包。
echo 如需合并 APK,请先在 Windows 构建,或设置 QFT_ANDROID_APK 后重跑本脚本。
:apk_done
echo [3/4] 写入版本信息与 SHA-256 校验...
powershell -NoProfile -Command ^
"$dir = [IO.Path]::GetFullPath('%QFT_PACKAGE_DIR%');" ^
"$meta = @('QFT 超速文件传输 正式版', '产品版本:v%QFT_VERSION%', 'Android versionCode:%QFT_ANDROID_CODE%', '封版提交:%QFT_RELEASE_COMMIT%', '打包时间:%QFT_STAMP%', '平台:Windows x64');" ^
"[IO.File]::WriteAllLines((Join-Path $dir '版本信息.txt'), $meta, [Text.UTF8Encoding]::new($false));" ^
"$lines = Get-ChildItem -LiteralPath $dir -File ^| Where-Object Name -ne 'SHA256校验.txt' ^| Sort-Object Name ^| ForEach-Object { '{0} {1}' -f (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLower(), $_.Name };" ^
"[IO.File]::WriteAllLines((Join-Path $dir 'SHA256校验.txt'), $lines, [Text.UTF8Encoding]::new($false))"
if errorlevel 1 exit /b 1
echo [4/4] 创建中文 ZIP 正式包...
powershell -NoProfile -Command ^
"$dir = [IO.Path]::GetFullPath('%QFT_PACKAGE_DIR%');" ^
"$lines = Get-ChildItem -LiteralPath $dir -File ^| Sort-Object Name ^| ForEach-Object { '{0} {1}' -f (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLower(), $_.Name };" ^
"[IO.File]::WriteAllLines((Join-Path $dir 'SHA256SUMS.txt'), $lines, [Text.UTF8Encoding]::new($false));" ^
"Compress-Archive -LiteralPath $dir -DestinationPath ($dir + '.zip') -Force"
if errorlevel 1 exit /b 1
echo.
echo PACKAGE COMPLETE
echo Folder: %QFT_PACKAGE_DIR%
echo ZIP: %QFT_PACKAGE_DIR%.zip
echo 封版打包完成
echo 文件夹:%QFT_PACKAGE_DIR%
echo 压缩包:%QFT_PACKAGE_DIR%.zip
exit /b 0