add:添加一个自动生成脚本。

This commit is contained in:
taynpg 2025-01-22 10:34:46 +08:00
parent f169d19238
commit 5aac360f9c
3 changed files with 50 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
downloads
*.exe
.DS_Store
build

44
build.bat Normal file
View File

@ -0,0 +1,44 @@
@echo off
REM 设置Go程序的文件名和输出目录
set SOURCE_FILE=main.go
set OUTPUT_DIR=build
REM 定义版本号
set VERSION=v1.0
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

View File

@ -7,6 +7,7 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
)
@ -32,6 +33,10 @@ type Asset struct {
}
func main() {
fmt.Printf("GOARCH: %s\n", runtime.GOARCH)
fmt.Printf("GOOS: %s\n", runtime.GOOS)
// 选择仓库
repo := chooseRepository(repositories)
apiURL := convertToAPIURL(repo)