Files
Scoreboard/deploy/build.bat
T

59 lines
2.2 KiB
Batchfile

@echo off
chcp 65001 >nul
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
setlocal
REM electron / electron-builder 的下载走国内镜像 + gh 代理,避免 GitHub 直连超时
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"
cd /d "%~dp0.."
echo === [1/4] git pull ===
git pull || exit /b 1
echo === [2/4] web deps + build ===
cd web
call pnpm install --frozen-lockfile || exit /b 1
call pnpm build || exit /b 1
cd ..
echo === [3/4] server build ===
cd server
if not exist ..\dist mkdir ..\dist
REM 内部署名从构建机本地文件注入(deploy\signature.local.txt 已 gitignore,不进公开仓库);
REM 文件不存在时二进制里也是空的,源码永远不含真实署名。
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%'" -o ..\dist\scoreboard.exe . || exit /b 1
echo internal signature injected
) else (
go build -o ..\dist\scoreboard.exe . || exit /b 1
echo no internal signature
)
cd ..
echo === [4/4] console package (electron-builder) ===
REM win.icon 由 electron-builder 内部调 rcedit 写进 PE 资源;
REM 它需要的 winCodeSign / nsis 从 gh-proxy 取,签名关闭。
taskkill /im "Scoreboard Console.exe" /f >nul 2>&1
taskkill /im scoreboard.exe /f >nul 2>&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 安装包 + 免安装目录
dir /b dist\console
endlocal
exit /b 0