fix(build): build.bat 全 ASCII + Node 脚本处理中文路径 + pnpm-workspace.yaml 构建脚本白名单
This commit is contained in:
1 parent
de4bd63594
commit
1399bae59e
4 files changed
+40
-45
No files matched your search
+16
-42
@@ -4,9 +4,13 @@ REM Build Windows artifacts on the build machine (Meowhome).
|
||||
REM Output:
|
||||
REM dist\scoreboard.exe server (frontend embedded via go:embed)
|
||||
REM dist\console\ Scoreboard Console installer + portable dir
|
||||
REM
|
||||
REM IMPORTANT: keep this file ASCII-only. cmd.exe mis-parses UTF-8 non-ASCII text
|
||||
REM inside batch files (especially inside if(...) blocks). Anything that needs a
|
||||
REM non-ASCII path is done by a Node script under deploy\.
|
||||
setlocal
|
||||
|
||||
REM electron / electron-builder 的下载走国内镜像 + gh 代理,避免 GitHub 直连超时
|
||||
REM electron / electron-builder downloads: use mirrors so GitHub is reachable
|
||||
set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/"
|
||||
set "ELECTRON_BUILDER_BINARIES_MIRROR=https://gh-proxy.com/https://github.com/electron-userland/electron-builder-binaries/releases/download/"
|
||||
set "CSC_IDENTITY_AUTO_DISCOVERY=false"
|
||||
@@ -25,65 +29,35 @@ cd ..
|
||||
echo === [3/4] server build ===
|
||||
cd server
|
||||
if not exist ..\dist mkdir ..\dist
|
||||
REM 版本号注入 /api/health:优先取最近的 git tag,没有 tag 时退到短哈希
|
||||
set "APP_VERSION=dev"
|
||||
for /f "delims=" %%I in ('git describe --tags --always 2^>nul') do set "APP_VERSION=%%I"
|
||||
REM 内部署名从构建机本地文件注入(deploy\signature.local.txt 已 gitignore,不进公开仓库);
|
||||
REM 文件不存在时二进制里也是空的,源码永远不含真实署名。
|
||||
REM internal signature is injected from a machine-local file (gitignored, never in repo)
|
||||
set "INTERNAL_SIGNATURE="
|
||||
if exist "..\deploy\signature.local.txt" set /p INTERNAL_SIGNATURE=<"..\deploy\signature.local.txt"
|
||||
if defined INTERNAL_SIGNATURE (
|
||||
REM 单引号包裹整个 -X:署名里的空格不会被 ldflags 拆开(go 的 ldflags 解析器认单引号)
|
||||
go build -ldflags "-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.InternalSignature=%INTERNAL_SIGNATURE%' -X main.version=%APP_VERSION%" -o ..\dist\scoreboard.exe . || exit /b 1
|
||||
REM single quotes keep spaces inside the value intact for go's ldflags parser
|
||||
go build -ldflags "-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.InternalSignature=%INTERNAL_SIGNATURE%'" -o ..\dist\scoreboard.exe . || exit /b 1
|
||||
echo internal signature injected
|
||||
) else (
|
||||
go build -ldflags "-X main.version=%APP_VERSION%" -o ..\dist\scoreboard.exe . || exit /b 1
|
||||
go build -o ..\dist\scoreboard.exe . || exit /b 1
|
||||
echo no internal signature
|
||||
)
|
||||
cd ..
|
||||
|
||||
echo === [4/4] console package (electron-builder) ===
|
||||
REM 安装器许可页顶部文案由本机署名生成(.nsh 是生成物,已 gitignore)
|
||||
set "SIGNATURE_TEXT="
|
||||
if exist "deploy\signature.local.txt" set /p SIGNATURE_TEXT=<"deploy\signature.local.txt"
|
||||
> "console\resources\installer-signature.nsh" echo !macro customHeader
|
||||
if defined SIGNATURE_TEXT (
|
||||
>> "console\resources\installer-signature.nsh" echo !define MUI_LICENSEPAGE_TEXT_TOP "内部署名:%SIGNATURE_TEXT%"
|
||||
) else (
|
||||
>> "console\resources\installer-signature.nsh" echo !define MUI_LICENSEPAGE_TEXT_TOP "请阅读并接受许可协议"
|
||||
)
|
||||
>> "console\resources\installer-signature.nsh" echo !macroend
|
||||
REM win.icon 由 electron-builder 内部调 rcedit 写进 PE 资源;
|
||||
REM 它需要的 winCodeSign / nsis 从 gh-proxy 取,签名关闭。
|
||||
REM win.icon is written into the PE resources by electron-builder (via rcedit);
|
||||
REM it needs winCodeSign / nsis, fetched through the gh proxy above.
|
||||
taskkill /im "Scoreboard Console.exe" /f >nul 2>&1
|
||||
taskkill /im scoreboard.exe /f >nul 2>&1
|
||||
REM 部署包根目录要带 rules\ 与使用说明;rules\ 由 package.json 的 extraFiles 拷入。
|
||||
REM 注意:cmd 对 UTF-8 中文放进 if(...) 块会解析错乱,所以块内一律用 ASCII,
|
||||
REM 中文只出现在顶层命令的路径字面量里。
|
||||
if not exist "rules" echo [warn] rules\ missing
|
||||
if not exist "console\extra" mkdir "console\extra"
|
||||
if exist "console\extra\使用说明.txt" del /q "console\extra\使用说明.txt"
|
||||
if exist "docs\使用说明.txt" goto :usage_from_txt
|
||||
if exist "docs\使用手册.md" goto :usage_from_md
|
||||
echo [docs] no usage doc, skip
|
||||
goto :usage_done
|
||||
:usage_from_txt
|
||||
copy /y "docs\使用说明.txt" "console\extra\使用说明.txt" >nul
|
||||
echo usage doc added
|
||||
goto :usage_done
|
||||
:usage_from_md
|
||||
copy /y "docs\使用手册.md" "console\extra\使用说明.txt" >nul
|
||||
echo usage doc added (from manual)
|
||||
:usage_done
|
||||
if not exist "rules" echo [warn] rules dir missing
|
||||
node deploy\prepare-extra.mjs || exit /b 1
|
||||
cd console
|
||||
call pnpm install --frozen-lockfile || exit /b 1
|
||||
call pnpm run dist || exit /b 1
|
||||
cd ..
|
||||
|
||||
echo.
|
||||
echo === 构建完成 ===
|
||||
echo dist\scoreboard.exe 服务端
|
||||
echo dist\console\ Console 安装包 + 免安装目录
|
||||
echo === BUILD OK ===
|
||||
echo dist\scoreboard.exe server
|
||||
echo dist\console\ console installer + portable dir
|
||||
dir /b dist\console
|
||||
endlocal
|
||||
exit /b 0
|
||||
Reference in new issue
Block a user