Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
136 lines (117 loc) · 3.25 KB
/
Copy pathbuild.sh
File metadata and controls
136 lines (117 loc) · 3.25 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
echo "========================================"
echo "VideoDown-Go 构建脚本"
echo "========================================"
echo
# 检查 Go 是否安装
if ! command -v go &> /dev/null; then
echo "错误: 未找到 Go 语言环境,请先安装 Go"
echo "下载地址: https://golang.org/dl/"
exit 1
fi
echo "检测到 Go 环境:"
go version
echo
# 清理之前的构建
echo "清理之前的构建文件..."
rm -rf build
mkdir -p build
echo
# 下载依赖
echo "下载 Go 依赖..."
go mod download
if [ $? -ne 0 ]; then
echo "错误: 依赖下载失败"
exit 1
fi
echo
# 读取版本号
if [ -f "version.txt" ]; then
version=$(cat version.txt)
echo "版本号: $version"
else
echo "警告: 未找到 version.txt 文件,使用默认版本号"
version="V1.0.0"
fi
# 提取数字版本号(去除V前缀)
numeric_version=${version#V}
echo "数字版本号: $numeric_version"
echo
# 构建 Linux 版本
echo "构建 Linux 64位 版本..."
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$version" -o "build/VideoDown-Go-linux-amd64" main.go
if [ $? -ne 0 ]; then
echo "错误: Linux 版本构建失败"
exit 1
fi
echo "Linux 64位版本构建完成"
# 构建 macOS 版本
echo "构建 macOS 64位 版本..."
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.Version=$version" -o "build/VideoDown-Go-darwin-amd64" main.go
if [ $? -ne 0 ]; then
echo "错误: macOS 版本构建失败"
exit 1
fi
echo "macOS 64位版本构建完成"
# 构建 macOS ARM64 版本 (Apple Silicon)
echo "构建 macOS ARM64 版本..."
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X main.Version=$version" -o "build/VideoDown-Go-darwin-arm64" main.go
if [ $? -ne 0 ]; then
echo "错误: macOS ARM64 版本构建失败"
exit 1
fi
echo "macOS ARM64版本构建完成"
# 复制必要文件到构建目录
echo
echo "复制必要文件..."
cp "README.md" "build/"
cp "LICENSE" "build/"
cp "install.md" "build/"
cp -r "templates" "build/"
if [ -d "static" ]; then
cp -r "static" "build/"
fi
# 创建 bin 目录结构说明
echo "创建工具目录说明..."
mkdir -p "build/bin"
cat > "build/bin/README.txt" << EOF
请将以下工具放入此目录:
Windows:
- ffmpeg.exe
- ffplay.exe
- ffprobe.exe
- yt-dlp.exe
macOS/Linux:
- ffmpeg
- ffplay
- ffprobe
- yt-dlp
下载地址:
FFmpeg (optimized for video downloaders): https://github.com/yt-dlp/FFmpeg-Builds?tab=readme-ov-file#ffmpeg-static-auto-builds
yt-dlp: https://github.com/yt-dlp/yt-dlp/releases
对于 macOS 用户,推荐使用 Homebrew 安装:
brew install ffmpeg yt-dlp
对于 Linux 用户,可以使用包管理器安装:
# Ubuntu/Debian
sudo apt install ffmpeg
# 然后从 GitHub 下载 yt-dlp
EOF
# 设置可执行权限
chmod +x "build/VideoDown-Go-linux-amd64"
chmod +x "build/VideoDown-Go-darwin-amd64"
chmod +x "build/VideoDown-Go-darwin-arm64"
# 显示构建结果
echo
echo "========================================"
echo "构建完成!"
echo "========================================"
echo
echo "构建文件位置: build/"
ls -la "build/"
echo
echo "注意事项:"
echo "1. 用户需要自行下载 FFmpeg 和 yt-dlp 工具"
echo "2. 将工具放入 bin/ 目录中"
echo "3. 详细安装说明请查看 install.md"
echo
echo "构建完成!"