45 lines
1.0 KiB
Batchfile
45 lines
1.0 KiB
Batchfile
@echo off
|
|
REM 设置Go程序的文件名和输出目录
|
|
set SOURCE_FILE=main.go
|
|
set OUTPUT_DIR=build
|
|
|
|
REM 定义版本号
|
|
set VERSION=v1.1
|
|
|
|
REM 检查是否存在输出目录,如果不存在则创建
|
|
if not exist %OUTPUT_DIR% (
|
|
mkdir %OUTPUT_DIR%
|
|
)
|
|
|
|
REM 构建 32 位 Windows 版本
|
|
echo Building 32-bit Windows version...
|
|
set GOOS=windows
|
|
set GOARCH=386
|
|
go build -o %OUTPUT_DIR%\tooldown_%VERSION%.win.x86.exe %SOURCE_FILE%
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to build 32-bit Windows version.
|
|
exit /b 1
|
|
)
|
|
|
|
REM 构建 64 位 Windows 版本
|
|
echo Building 64-bit Windows version...
|
|
set GOARCH=amd64
|
|
go build -o %OUTPUT_DIR%\tooldown_%VERSION%.win.x64.exe %SOURCE_FILE%
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to build 64-bit Windows version.
|
|
exit /b 1
|
|
)
|
|
|
|
REM 构建 64 位 Linux 版本
|
|
echo Building 64-bit Linux version...
|
|
set GOOS=linux
|
|
set GOARCH=amd64
|
|
go build -o %OUTPUT_DIR%\tooldown_%VERSION%.linux.x64 %SOURCE_FILE%
|
|
if %ERRORLEVEL% neq 0 (
|
|
echo Failed to build 64-bit Linux version.
|
|
exit /b 1
|
|
)
|
|
|
|
echo All builds completed successfully!
|
|
exit /b 0
|