feat(build): integrate frontend build into backend binary and update scripts

This commit is contained in:
2026-09-22 22:57:08 +08:00
parent 15144fb9d4
commit 4be6d2add0
15 changed files with 175 additions and 109 deletions
+19 -11
View File
@@ -1,12 +1,20 @@
@echo off
setlocal enabledelayedexpansion
:: Get git commit hash (shortened to 7 characters, can also use full)
for /f %%i in ('git rev-parse --short HEAD') do set COMMIT=%%i
:: Get UTC time
for /f %%i in ('powershell -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ'"') do set BUILD_DATE=%%i
:: Build -ldflags
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
@echo off
setlocal enabledelayedexpansion
:: The console is embedded in the binary (web\embed.go), so compiling without
:: web\dist fails. Say that plainly rather than leaving go:embed's error.
if not exist "web\dist\index.html" (
echo The web console is not built: web\dist is missing.
echo Run build-win-x86_64.bat once, or "npm run build" in frontend\.
exit /b 1
)
:: Get git commit hash (shortened to 7 characters, can also use full)
for /f %%i in ('git rev-parse --short HEAD') do set COMMIT=%%i
:: Get UTC time
for /f %%i in ('powershell -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ssZ'"') do set BUILD_DATE=%%i
:: Build -ldflags
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
go run -ldflags "%LDFLAGS%" .