@echo off setlocal enabledelayedexpansion set "SCRIPT_DIR=%~dp0" set "ROOT=%SCRIPT_DIR%.." :: --------------------------------------------------------------- :: 读取版本号 :: --------------------------------------------------------------- for /f "usebackq delims=" %%i in (`powershell -Command "try { (Get-Content '%ROOT%\src-tauri\tauri.conf.json' -Raw | ConvertFrom-Json).version } catch { Write-Output '0.0.0' }"`) do set "VERSION=%%i" if "%VERSION%"=="0.0.0" ( echo 错误:无法读取 tauri.conf.json 中的版本号 exit /b 1 ) set "OUT_DIR=%ROOT%\releases\%VERSION%" set "PKG=bookmgr-client" set "DIST=%ROOT%\dist" set "BUNDLE=%ROOT%\src-tauri\target\release\bundle" echo ==^> 收集 %PKG% v%VERSION% 产物 → %OUT_DIR% :: --------------------------------------------------------------- :: 准备输出目录 :: --------------------------------------------------------------- if exist "%OUT_DIR%" rmdir /s /q "%OUT_DIR%" mkdir "%OUT_DIR%" :: --------------------------------------------------------------- :: Web — 从 dist/ 打 tar.gz 和 zip :: --------------------------------------------------------------- if exist "%DIST%\index.html" ( set "TARBALL=%OUT_DIR%\%PKG%-%VERSION%-web.tar.gz" echo [web] !TARBALL! tar -czf "!TARBALL!" -C "%DIST%" . set "ZIPBALL=%OUT_DIR%\%PKG%-%VERSION%-web.zip" echo [web] !ZIPBALL! powershell -Command "Compress-Archive -Path '%DIST%\*' -DestinationPath '!ZIPBALL!' -Force" ) else ( echo [web] 跳过(dist/ 未就绪,请先运行 pnpm build) ) :: --------------------------------------------------------------- :: Windows — msi / nsis :: --------------------------------------------------------------- if exist "%BUNDLE%\msi" ( for %%f in ("%BUNDLE%\msi\%PKG%_*.msi") do ( if exist "%%f" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-windows-x86_64.msi" echo [msi] !DST! copy /y "%%f" "!DST!" >nul ) ) ) if exist "%BUNDLE%\nsis" ( for %%f in ("%BUNDLE%\nsis\%PKG%_*.exe") do ( if exist "%%f" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-windows-x86_64-setup.exe" echo [nsis] !DST! copy /y "%%f" "!DST!" >nul ) ) ) :: --------------------------------------------------------------- :: Linux — AppImage / deb / rpm / pacman :: --------------------------------------------------------------- if exist "%BUNDLE%\appimage" ( for %%f in ("%BUNDLE%\appimage\%PKG%_*_amd64.AppImage") do ( if exist "%%f" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-linux-amd64.AppImage" echo [appimage] !DST! copy /y "%%f" "!DST!" >nul ) ) ) if exist "%BUNDLE%\deb" ( for %%f in ("%BUNDLE%\deb\%PKG%_*_amd64.deb") do ( if exist "%%f" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-linux-amd64.deb" echo [deb] !DST! copy /y "%%f" "!DST!" >nul ) ) ) if exist "%BUNDLE%\rpm" ( for %%f in ("%BUNDLE%\rpm\%PKG%-*x86_64.rpm") do ( if exist "%%f" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-linux-x86_64.rpm" echo [rpm] !DST! copy /y "%%f" "!DST!" >nul ) ) ) if exist "%BUNDLE%\pacman" ( for %%f in ("%BUNDLE%\pacman\%PKG%-*.pkg.tar.zst") do ( if exist "%%f" ( set "fn=%%~nxf" :: 替换 pkgrel 为 linux 标识 set "newname=!fn:-1-x86_64=-linux-x86_64!" set "DST=%OUT_DIR%\!newname!" echo [pacman] !DST! copy /y "%%f" "!DST!" >nul ) ) ) :: --------------------------------------------------------------- :: Android — APK :: --------------------------------------------------------------- set "APK_DIR=%ROOT%\src-tauri\gen\android\app\build\outputs\apk" if exist "%APK_DIR%" ( for %%a in (arm64 x86_64 universal) do ( set "SRC=%APK_DIR%\%%a\release\app-%%a-release.apk" if exist "!SRC!" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-android-%%a.apk" echo [apk] !DST! copy /y "!SRC!" "!DST!" >nul ) ) ) :: --------------------------------------------------------------- :: macOS — dmg :: --------------------------------------------------------------- if exist "%BUNDLE%\dmg" ( for %%f in ("%BUNDLE%\dmg\%PKG%_*.dmg") do ( if exist "%%f" ( set "DST=%OUT_DIR%\%PKG%-%VERSION%-macos-arm64.dmg" echo [dmg] !DST! copy /y "%%f" "!DST!" >nul ) ) ) :: --------------------------------------------------------------- echo. echo ==^> 完成 dir "%OUT_DIR%"