feat(build): add scripts for building frontend and backend for Linux and Windows
Build / windows-latest (push) Canceled after 0s
Build / ubuntu-latest (push) Canceled after 0s

This commit is contained in:
2026-09-10 20:59:21 +08:00
parent 23fc14cc17
commit b970d66bc0
5 changed files with 275 additions and 66 deletions
+54 -33
View File
@@ -1,33 +1,54 @@
@echo off
setlocal enabledelayedexpansion
echo Building for Windows (amd64)...
:: 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
:: Set environment variables for Windows build
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=0
:: Build -ldflags
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
:: Set output file name
set OUTPUT=nukumizu-windows-amd64.exe
echo Commit: %COMMIT%
echo BuildDate: %BUILD_DATE%
echo Output: %OUTPUT%
go build -ldflags "%LDFLAGS%" -o "%OUTPUT%" .
if %errorlevel% equ 0 (
echo Build succeeded: %OUTPUT%
) else (
echo Build failed.
)
@echo off
setlocal enabledelayedexpansion
:: Build from the repository root, however the script was invoked.
cd /d "%~dp0"
:: Optional first argument: --frontend also builds the Vue frontend, which web/
:: serves at runtime from frontend/dist. Omitted, only the backend is compiled.
set BUILD_FRONTEND=0
if /i "%~1"=="--frontend" set BUILD_FRONTEND=1
if not "%BUILD_FRONTEND%"=="1" goto :backend
echo Building frontend...
cd frontend
call npm ci
if errorlevel 1 goto :fail
call npm run build
if errorlevel 1 goto :fail
cd ..
:backend
echo Building for Windows (amd64)...
:: 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).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ')"') do set BUILD_DATE=%%i
:: Set environment variables for Windows build
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=0
:: Build -ldflags
set LDFLAGS=-X main.BuildTime=%BUILD_DATE% -X main.CommitHash=%COMMIT%
:: Set output file name
set OUTPUT=nukumizu-windows-amd64.exe
echo Commit: %COMMIT%
echo BuildDate: %BUILD_DATE%
echo Output: %OUTPUT%
go build -ldflags "%LDFLAGS%" -o "%OUTPUT%" .
if errorlevel 1 goto :fail
echo Build succeeded: %OUTPUT%
exit /b 0
:fail
echo Build failed.
exit /b 1