提交
This commit is contained in:
@@ -1,4 +1,50 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
echo ============================================
|
||||
echo Build Backend
|
||||
echo ============================================
|
||||
|
||||
set "DEPLOY_DIR=%~dp0deploy"
|
||||
if not exist "%DEPLOY_DIR%" mkdir "%DEPLOY_DIR%"
|
||||
|
||||
:: Windows exe
|
||||
echo.
|
||||
echo [1/2] Building Windows amd64...
|
||||
set CGO_ENABLED=0
|
||||
set GOOS=windows
|
||||
set GOARCH=amd64
|
||||
go build -ldflags "-s -w" -o "%DEPLOY_DIR%\server.exe" main.go
|
||||
if %errorlevel% neq 0 (
|
||||
echo Windows build FAILED
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo OK: server.exe
|
||||
|
||||
:: Linux binary
|
||||
echo.
|
||||
echo [2/2] Building Linux amd64...
|
||||
set CGO_ENABLED=0
|
||||
set GOOS=linux
|
||||
set GOARCH=amd64
|
||||
$env:CGO_ENABLED="0"; $env:GOOS="linux"; $env:GOARCH="amd64"; go build -ldflags "-s -w" -o myapp main.go
|
||||
go build -ldflags "-s -w" -o "%DEPLOY_DIR%\server" main.go
|
||||
if %errorlevel% neq 0 (
|
||||
echo Linux build FAILED
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo OK: server
|
||||
|
||||
:: Copy config
|
||||
copy /y config.yaml "%DEPLOY_DIR%\config.yaml.example" >/dev/null
|
||||
|
||||
echo.
|
||||
echo ============================================
|
||||
echo Build Complete!
|
||||
echo ============================================
|
||||
echo.
|
||||
echo Output directory:
|
||||
echo %DEPLOY_DIR%
|
||||
echo.
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user