-
-
Notifications
You must be signed in to change notification settings - Fork 139
/
build.bat
48 lines (40 loc) · 1.26 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@echo off
setlocal enabledelayedexpansion
set BUILDDIR=%~dp0
set PATH=%BUILDDIR%.deps;%PATH%
set ARCHS=amd64 386
cd /d %BUILDDIR% || exit /b 1
for /f "tokens=3" %%a in ('findstr /r "Number.*=.*[0-9.]*" .\pkg\version\version.go') do set VERSION=%%a
set VERSION=%VERSION:"=%
:packages
echo [+] Downloading packages
go mod tidy || goto :error
:resources
echo [+] Generating resources
go generate || goto :error
:build
echo [+] Building program
for /f "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set BUILD_DATE=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2%
set MOD=github.com/koho/frpmgr
set GO111MODULE=on
set CGO_ENABLED=0
for %%a in (%ARCHS%) do (
set GOARCH=%%a
go build -trimpath -ldflags="-H windowsgui -s -w -X %MOD%/pkg/version.BuildDate=%BUILD_DATE%" -o bin\x!GOARCH:~-2!\frpmgr.exe .\cmd\frpmgr || goto :error
)
:archive
echo [+] Creating archives
for %%a in (%ARCHS%) do (
set ARCH=%%a
tar -ac -C bin\x!ARCH:~-2! -f bin\frpmgr-%VERSION%-x!ARCH:~-2!.zip frpmgr.exe || goto :error
)
:installer
echo [+] Building installer
call installer\build.bat %VERSION% || goto :error
:success
echo [+] Success
exit /b 0
:error
echo [-] Failed with error %errorlevel%.
exit /b %errorlevel%