Skip to content

Commit 63ae89d

Browse files
committed
fix: 修复 GitHub Actions release 工作流语法错误
- 重新创建完整的 release.yml 文件 - 修复空文件导致的 'No event triggers defined in on' 错误 - 确保工作流能正确触发和运行
1 parent e69ce13 commit 63ae89d

File tree

1 file changed

+253
-0
lines changed

1 file changed

+253
-0
lines changed

.github/workflows/release.yml

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
release:
14+
name: Create Release
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # 获取所有历史以便生成变更日志
22+
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: '1.25'
27+
28+
- name: Install bc (for cross-build script)
29+
run: sudo apt-get update && sudo apt-get install -y bc
30+
31+
- name: Download dependencies
32+
run: make deps
33+
34+
- name: Run tests
35+
run: make test
36+
37+
- name: Cross compile all platforms
38+
run: |
39+
# 使用我们的交叉编译脚本
40+
chmod +x scripts/cross-build.sh
41+
./scripts/cross-build.sh
42+
43+
- name: Generate release notes
44+
run: |
45+
# 获取当前和前一个标签
46+
CURRENT_TAG="${{ github.ref_name }}"
47+
PREVIOUS_TAG=$(git tag --sort=-version:refname | grep -A1 "$CURRENT_TAG" | tail -1)
48+
49+
# 如果没有前一个标签,使用第一个提交
50+
if [ -z "$PREVIOUS_TAG" ] || [ "$PREVIOUS_TAG" = "$CURRENT_TAG" ]; then
51+
PREVIOUS_TAG=$(git rev-list --max-parents=0 HEAD)
52+
fi
53+
54+
echo "生成从 $PREVIOUS_TAG 到 $CURRENT_TAG 的变更日志"
55+
56+
# 获取提交信息
57+
COMMITS=$(git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..$CURRENT_TAG 2>/dev/null || git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD)
58+
59+
# 获取文件变更统计
60+
STATS=$(git diff --stat $PREVIOUS_TAG..$CURRENT_TAG 2>/dev/null || git diff --stat $PREVIOUS_TAG..HEAD || echo "首次发布")
61+
62+
cat > release-notes.md << EOF
63+
## FileCodeBox $CURRENT_TAG
64+
65+
### 📝 本次更新
66+
67+
$COMMITS
68+
69+
### 📊 变更统计
70+
\`\`\`
71+
$STATS
72+
\`\`\`
73+
74+
### 🚀 功能特性
75+
- ✅ 多平台可执行文件支持 (Linux, macOS, Windows, FreeBSD)
76+
- ✅ 支持 AMD64、ARM64、386、ARM 架构
77+
- ✅ Docker 镜像自动构建和发布
78+
- ✅ 文件上传下载服务
79+
- ✅ 用户认证系统
80+
- ✅ 管理员控制面板
81+
- ✅ 多种存储后端支持 (本地/S3/WebDAV/NFS)
82+
- ✅ 分片上传支持
83+
- ✅ MCP (Model Context Protocol) 服务器支持
84+
85+
### 📦 安装方式
86+
87+
#### 方式一:直接下载可执行文件
88+
89+
选择对应平台的文件下载:
90+
- 🐧 **Linux x64**: \`filecodebox-$CURRENT_TAG-linux-amd64\`
91+
- 🐧 **Linux ARM64**: \`filecodebox-$CURRENT_TAG-linux-arm64\`
92+
- 🐧 **Linux x86**: \`filecodebox-$CURRENT_TAG-linux-386\`
93+
- 🐧 **Linux ARM**: \`filecodebox-$CURRENT_TAG-linux-arm\`
94+
- 🍎 **macOS Intel**: \`filecodebox-$CURRENT_TAG-darwin-amd64\`
95+
- 🍎 **macOS Apple Silicon**: \`filecodebox-$CURRENT_TAG-darwin-arm64\`
96+
- 🪟 **Windows x64**: \`filecodebox-$CURRENT_TAG-windows-amd64.exe\`
97+
- 🪟 **Windows x86**: \`filecodebox-$CURRENT_TAG-windows-386.exe\`
98+
- 🔧 **FreeBSD x64**: \`filecodebox-$CURRENT_TAG-freebsd-amd64\`
99+
- 🔧 **FreeBSD ARM64**: \`filecodebox-$CURRENT_TAG-freebsd-arm64\`
100+
101+
#### 方式二:Docker 部署
102+
103+
\`\`\`bash
104+
# 拉取镜像
105+
docker pull ghcr.io/zy84338719/filecodebox:$CURRENT_TAG
106+
107+
# 运行容器
108+
docker run -d \\
109+
--name filecodebox \\
110+
-p 12345:12345 \\
111+
-v ./data:/app/data \\
112+
ghcr.io/zy84338719/filecodebox:$CURRENT_TAG
113+
\`\`\`
114+
115+
#### 方式三:Docker Compose
116+
117+
\`\`\`yaml
118+
version: '3.8'
119+
services:
120+
filecodebox:
121+
image: ghcr.io/zy84338719/filecodebox:$CURRENT_TAG
122+
ports:
123+
- "12345:12345"
124+
volumes:
125+
- ./data:/app/data
126+
restart: unless-stopped
127+
\`\`\`
128+
129+
#### 方式四:源码编译
130+
131+
\`\`\`bash
132+
git clone https://github.com/zy84338719/filecodebox.git
133+
cd filecodebox
134+
git checkout $CURRENT_TAG
135+
make build
136+
\`\`\`
137+
138+
### 🔧 快速开始
139+
140+
1. **下载并启动服务**
141+
- 下载对应平台的文件
142+
- 运行 \`./filecodebox\` (Linux/macOS) 或 \`filecodebox.exe\` (Windows)
143+
144+
2. **访问服务**
145+
- 用户界面: http://localhost:12345
146+
- 管理员界面: http://localhost:12345/admin
147+
- API 文档: http://localhost:12345/swagger/index.html
148+
- 默认管理员密码: \`FileCodeBox2025\`
149+
150+
3. **基本配置**
151+
- 修改管理员密码
152+
- 配置存储后端
153+
- 设置用户系统开关
154+
155+
### 📋 系统要求
156+
157+
- **操作系统**: Linux, macOS, Windows, FreeBSD
158+
- **架构**: AMD64, ARM64, 386, ARM
159+
- **内存**: 最小 64MB,推荐 256MB+
160+
- **存储**: 根据使用量而定
161+
- **网络**: HTTP/HTTPS 端口访问
162+
163+
### 🔒 安全说明
164+
165+
- 首次启动请立即修改默认管理员密码
166+
- 生产环境建议配置 HTTPS
167+
- 定期备份数据目录
168+
- 建议配置防火墙规则
169+
170+
### 🆘 问题反馈
171+
172+
如遇到问题,请访问:
173+
- **GitHub Issues**: https://github.com/${{ github.repository }}/issues
174+
- **文档**: https://github.com/${{ github.repository }}#readme
175+
176+
### 📖 更新说明
177+
178+
- 支持通过 \`./filecodebox -version\` 查看版本信息
179+
- 版本号现在使用 Git tag 自动管理
180+
- 构建系统已优化,支持 Makefile 和脚本构建
181+
182+
---
183+
184+
**构建信息**
185+
- 构建时间: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
186+
- Git 提交: ${{ github.sha }}
187+
- Go 版本: $(go version | cut -d' ' -f3)
188+
EOF
189+
190+
- name: Create Release
191+
uses: softprops/action-gh-release@v1
192+
with:
193+
files: dist/*
194+
name: FileCodeBox ${{ github.ref_name }}
195+
body_path: release-notes.md
196+
draft: false
197+
prerelease: ${{ contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'rc') }}
198+
generate_release_notes: false
199+
env:
200+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
201+
202+
docker:
203+
name: Build and push Docker image
204+
runs-on: ubuntu-latest
205+
needs: release
206+
207+
steps:
208+
- name: Checkout code
209+
uses: actions/checkout@v4
210+
211+
- name: Set up Docker Buildx
212+
uses: docker/setup-buildx-action@v3
213+
214+
- name: Log in to GitHub Container Registry
215+
uses: docker/login-action@v3
216+
with:
217+
registry: ghcr.io
218+
username: ${{ github.actor }}
219+
password: ${{ secrets.GITHUB_TOKEN }}
220+
221+
- name: Extract metadata
222+
id: meta
223+
uses: docker/metadata-action@v5
224+
with:
225+
images: ghcr.io/zy84338719/filecodebox
226+
tags: |
227+
type=semver,pattern={{version}}
228+
type=semver,pattern={{major}}.{{minor}}
229+
type=semver,pattern={{major}}
230+
type=raw,value=latest
231+
labels: |
232+
org.opencontainers.image.title=FileCodeBox
233+
org.opencontainers.image.description=高性能文件分享服务 - Go语言实现
234+
org.opencontainers.image.vendor=FileCodeBox
235+
org.opencontainers.image.url=https://github.com/${{ github.repository }}
236+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
237+
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}#readme
238+
org.opencontainers.image.licenses=MIT
239+
240+
- name: Build and push Docker image
241+
uses: docker/build-push-action@v5
242+
with:
243+
context: .
244+
platforms: linux/amd64,linux/arm64
245+
push: true
246+
tags: ${{ steps.meta.outputs.tags }}
247+
labels: ${{ steps.meta.outputs.labels }}
248+
cache-from: type=gha
249+
cache-to: type=gha,mode=max
250+
build-args: |
251+
VERSION=${{ github.ref_name }}
252+
COMMIT=${{ github.sha }}
253+
BUILD_TIME=${{ github.event.head_commit.timestamp }}

0 commit comments

Comments
 (0)