build: 回归 electron-builder 打包(win.icon 写入 PE 图标),下载走 gh-proxy
This commit is contained in:
1 parent
ad3770cfc9
commit
2f75c31509
3 files changed
+25
-90
No files matched your search
@@ -20,7 +20,7 @@
|
||||
"productName": "Scoreboard Console",
|
||||
"directories": {
|
||||
"output": "../dist/console",
|
||||
"buildResources": "build"
|
||||
"buildResources": "resources"
|
||||
},
|
||||
"files": [
|
||||
"main/**/*",
|
||||
@@ -37,9 +37,14 @@
|
||||
{
|
||||
"from": "../config.yaml",
|
||||
"to": "config.yaml"
|
||||
},
|
||||
{
|
||||
"from": "scoreboard.png",
|
||||
"to": "scoreboard.png"
|
||||
}
|
||||
],
|
||||
"win": {
|
||||
"icon": "resources/icon.ico",
|
||||
"target": [
|
||||
{
|
||||
"target": "nsis",
|
||||
|
||||
File renamed without changes.
+19
-89
@@ -2,32 +2,27 @@
|
||||
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\ScoreboardConsole\ portable GUI manager (double-click to run)
|
||||
REM
|
||||
REM We do NOT use electron-builder NSIS: it downloads signing tools from GitHub,
|
||||
REM which fails on restricted networks. The portable app is assembled by extracting
|
||||
REM the official electron zip straight into the output directory.
|
||||
REM dist\scoreboard.exe server (frontend embedded via go:embed)
|
||||
REM dist\console\ Scoreboard Console installer + portable dir
|
||||
setlocal
|
||||
|
||||
REM Must match console\package.json devDependencies.electron (pinned in console\pnpm-lock.yaml)
|
||||
set "ELECTRON_VERSION=38.8.6"
|
||||
set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron"
|
||||
set "CONSOLE_OUT=dist\ScoreboardConsole"
|
||||
set "ELECTRON_ZIP=dist\cache\electron-v%ELECTRON_VERSION%-win32-x64.zip"
|
||||
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/5] git pull ===
|
||||
echo === [1/4] git pull ===
|
||||
git pull || exit /b 1
|
||||
|
||||
echo === [2/5] web deps + build ===
|
||||
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/5] server build ===
|
||||
echo === [3/4] server build ===
|
||||
cd server
|
||||
if not exist ..\dist mkdir ..\dist
|
||||
REM 内部署名从构建机本地文件注入(deploy\signature.local.txt 已 gitignore,不进公开仓库);
|
||||
@@ -44,85 +39,20 @@ if defined INTERNAL_SIGNATURE (
|
||||
)
|
||||
cd ..
|
||||
|
||||
echo === [4/5] console deps ===
|
||||
cd console
|
||||
call pnpm install --frozen-lockfile || exit /b 1
|
||||
cd ..
|
||||
|
||||
echo === [5/5] assemble portable console ===
|
||||
REM Old build may still be running; electron runtime files are read-only,
|
||||
REM so the runtime is extracted once and only our own resources\app is rebuilt.
|
||||
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
|
||||
if not exist "%CONSOLE_OUT%\Scoreboard Console.exe" call :install_runtime || exit /b 1
|
||||
if exist "%CONSOLE_OUT%\resources\app" rmdir /s /q "%CONSOLE_OUT%\resources\app"
|
||||
mkdir "%CONSOLE_OUT%\resources\app" 2>nul
|
||||
xcopy /e /i /y "console\main" "%CONSOLE_OUT%\resources\app\main" >nul || exit /b 1
|
||||
xcopy /e /i /y "console\renderer" "%CONSOLE_OUT%\resources\app\renderer" >nul || exit /b 1
|
||||
copy /y "console\package.json" "%CONSOLE_OUT%\resources\app\package.json" >nul || exit /b 1
|
||||
REM config.json must sit next to the exe: the console resolves it from the exe dir
|
||||
copy /y "console\config.json" "%CONSOLE_OUT%\config.json" >nul || exit /b 1
|
||||
copy /y "dist\scoreboard.exe" "%CONSOLE_OUT%\scoreboard.exe" >nul || exit /b 1
|
||||
copy /y "config.yaml" "%CONSOLE_OUT%\config.yaml" >nul || exit /b 1
|
||||
REM app icon: the console loads it from the exe directory for tray / window icon
|
||||
copy /y "console\scoreboard.png" "%CONSOLE_OUT%\scoreboard.png" >nul || exit /b 1
|
||||
|
||||
call :apply_icon
|
||||
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 %CONSOLE_OUT%\Scoreboard Console.exe GUI 管理器(双击运行)
|
||||
dir "%CONSOLE_OUT%"
|
||||
echo dist\scoreboard.exe 服务端
|
||||
echo dist\console\ Console 安装包 + 免安装目录
|
||||
dir /b dist\console
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
REM ---- install electron runtime from the official zip (cached) ------------------
|
||||
:install_runtime
|
||||
if not exist "dist\cache" mkdir "dist\cache" || exit /b 1
|
||||
if not exist "%ELECTRON_ZIP%" (
|
||||
echo downloading electron %ELECTRON_VERSION% ...
|
||||
curl -L --fail --max-time 900 -o "%ELECTRON_ZIP%" "%ELECTRON_MIRROR%/%ELECTRON_VERSION%/electron-v%ELECTRON_VERSION%-win32-x64.zip" || exit /b 1
|
||||
)
|
||||
echo extracting electron runtime ...
|
||||
powershell -NoProfile -Command "Expand-Archive -LiteralPath '%ELECTRON_ZIP%' -DestinationPath '%CONSOLE_OUT%' -Force" || exit /b 1
|
||||
if exist "%CONSOLE_OUT%\electron.exe" ren "%CONSOLE_OUT%\electron.exe" "Scoreboard Console.exe"
|
||||
if not exist "%CONSOLE_OUT%\Scoreboard Console.exe" (
|
||||
echo [ERROR] electron runtime install failed
|
||||
exit /b 1
|
||||
)
|
||||
exit /b 0
|
||||
|
||||
REM ---- stamp the app icon / version info into the exe --------------------------
|
||||
REM electron-builder 的 "win.icon" 内部也是调 rcedit 改 PE 资源;rcedit 打包在
|
||||
REM winCodeSign 里(GitHub 下载不通),这里从国内镜像取,用本机 7z 解出。
|
||||
:apply_icon
|
||||
set "RCEDIT=deploy\tools\rcedit-x64.exe"
|
||||
if exist "dist\cache\winCodeSign-2.6.0\rcedit-x64.exe" set "RCEDIT=dist\cache\winCodeSign-2.6.0\rcedit-x64.exe"
|
||||
if not exist "%RCEDIT%" call :fetch_rcedit
|
||||
if not exist "%RCEDIT%" (
|
||||
echo [warn] rcedit unavailable, exe icon skipped
|
||||
exit /b 0
|
||||
)
|
||||
"%RCEDIT%" "%CONSOLE_OUT%\Scoreboard Console.exe" ^
|
||||
--set-icon "console\build\icon.ico" ^
|
||||
--set-version-string "ProductName" "Scoreboard Console" ^
|
||||
--set-version-string "FileDescription" "Scoreboard Console" ^
|
||||
--set-version-string "CompanyName" "AskaEth" ^
|
||||
--set-file-version "0.1.0" ^
|
||||
--set-product-version "0.1.0" || exit /b 1
|
||||
echo app icon stamped
|
||||
exit /b 0
|
||||
|
||||
:fetch_rcedit
|
||||
set "SEVEN_ZIP="
|
||||
if exist "%ProgramFiles%\7-Zip\7z.exe" set "SEVEN_ZIP=%ProgramFiles%\7-Zip\7z.exe"
|
||||
if not defined SEVEN_ZIP if exist "%USERPROFILE%\7z.exe" set "SEVEN_ZIP=%USERPROFILE%\7z.exe"
|
||||
if not defined SEVEN_ZIP exit /b 0
|
||||
if not exist "dist\cache" mkdir "dist\cache" 2>nul
|
||||
if not exist "dist\cache\winCodeSign-2.6.0.7z" (
|
||||
echo downloading winCodeSign (for rcedit) ...
|
||||
curl -L --fail --max-time 600 -o "dist\cache\winCodeSign-2.6.0.7z" "https://npmmirror.com/mirrors/electron-builder-binaries/winCodeSign-2.6.0/winCodeSign-2.6.0.7z" || exit /b 0
|
||||
)
|
||||
"%SEVEN_ZIP%" x -y -o"dist\cache\winCodeSign-2.6.0" "dist\cache\winCodeSign-2.6.0.7z" rcedit-x64.exe >nul || exit /b 0
|
||||
exit /b 0
|
||||
Reference in new issue
Block a user