ci: 停掉每次推 main 的自动发布,交叉编译降级为 PR 检查 (#757)

release.yml 每次推 main 都会打一个日期 tag 并建一个 GitHub Release。
它想填的是"两次发版之间让用户拿到修复"的空档,但本项目发版就是推个
tag 等几分钟,没有这个空档,机制本身没有存在必要。

而且它的清理步骤从未生效:grep 把 '^v' 锚在第一列,但 gh release list
第一列是标题("Release v2026..."),永远匹配不到,加上 continue-on-error
失败也不报警。本该只留 10 个,实际堆了 108 个 release 和 tag。
它还把自动构建标成 prerelease: false,下次推 main 就会顶掉 v2.0.0
成为 GitHub 上的 Latest。

删掉整个 release.yml。发版不受影响:tag-release.yml 与 docker-release.yml
只认语义化 tag,独立运行,且自带全平台二进制产物。

原先只有它在每次推送时做交叉编译,删掉后平台相关的编译错误会拖到发版
才暴露,所以把这项检查搬进 test.yml,只编译不留产物。

存量 108 个日期 release 和 tag 保持不动:不再新增后它们就是静止的历史
档案,删除不可逆且可能打断别人收藏的下载链接。

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
zy
2026-07-26 21:55:33 +08:00
committed by GitHub
parent 35bafecc07
commit bd729d313b
4 changed files with 11 additions and 169 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ on:
push:
tags:
# 只匹配语义化版本 tag(如 v1.2.8、v1.3.0-beta.1),
# 不匹配 release.yml 自动生成的日期 tag(如 v2026.07.23.0205-85aed8b
# 不匹配历史遗留的日期 tag(如 v2026.07.23.0205-85aed8b
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
-167
View File
@@ -1,167 +0,0 @@
name: Build and Release
on:
push:
branches: [ main ]
paths-ignore:
- 'README.md'
- 'README_EN.md'
- 'CLAUDE.md'
- '.all-contributorsrc'
- '.gitignore'
- '.dockerignore'
- 'Dockerfile'
- '.claude/**'
- '.cursor/**'
- '.github/**'
- '.vscode/**'
- 'assets/**'
- 'configs/**'
- 'cookies/**'
- 'docker/**'
- 'deploy/**'
- 'docs/**'
- 'donate/**'
- 'examples/**'
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
# 只在推送到 main 时运行,或手动触发
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24'
- name: Generate release name
id: version
run: |
TIMESTAMP=$(date +%Y.%m.%d.%H%M)
COMMIT_SHA=$(git rev-parse --short HEAD)
VERSION="v${TIMESTAMP}-${COMMIT_SHA}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Generated version: ${VERSION}"
- name: Build for multiple platforms
run: |
# 主程序构建
# 禁用 CGO 以生成静态链接的二进制文件,避免 GLIBC 依赖问题
# macOS ARM64 (Apple Silicon)
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o xiaohongshu-mcp-darwin-arm64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o xiaohongshu-login-darwin-arm64 ./cmd/login
# macOS Intel
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o xiaohongshu-mcp-darwin-amd64 .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o xiaohongshu-login-darwin-amd64 ./cmd/login
# Windows x64
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o xiaohongshu-mcp-windows-amd64.exe .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o xiaohongshu-login-windows-amd64.exe ./cmd/login
# Linux x64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o xiaohongshu-mcp-linux-amd64 .
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o xiaohongshu-login-linux-amd64 ./cmd/login
# Linux ARM64
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o xiaohongshu-mcp-linux-arm64 .
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o xiaohongshu-login-linux-arm64 ./cmd/login
- name: Package binaries
run: |
# 创建压缩包
# macOS ARM64
tar czf xiaohongshu-mcp-darwin-arm64.tar.gz xiaohongshu-mcp-darwin-arm64 xiaohongshu-login-darwin-arm64
# macOS Intel
tar czf xiaohongshu-mcp-darwin-amd64.tar.gz xiaohongshu-mcp-darwin-amd64 xiaohongshu-login-darwin-amd64
# Windows x64
zip xiaohongshu-mcp-windows-amd64.zip xiaohongshu-mcp-windows-amd64.exe xiaohongshu-login-windows-amd64.exe
# Linux x64
tar czf xiaohongshu-mcp-linux-amd64.tar.gz xiaohongshu-mcp-linux-amd64 xiaohongshu-login-linux-amd64
# Linux ARM64
tar czf xiaohongshu-mcp-linux-arm64.tar.gz xiaohongshu-mcp-linux-arm64 xiaohongshu-login-linux-arm64
- name: Clean up old releases
run: |
# 获取所有自动构建的 releases (v开头的时间戳格式)
RELEASES=$(gh release list --limit 100 | grep -E '^v[0-9]{4}\.[0-9]{2}\.[0-9]{2}\.[0-9]{4}-' | awk '{print $3}' | tail -n +11)
# 删除超过 10 个的旧 releases 和对应的 tags
for release in $RELEASES; do
echo "Deleting old release: $release"
gh release delete "$release" --yes --cleanup-tag
done
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.version }}
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: false
body: |
## 🔧 自动构建版本
**注意:这是自动构建的预发布版本,用于测试。正式版本请等待手动发布。**
### 📦 下载说明
选择适合您系统的压缩包下载:
- **macOS Apple Silicon (M1/M2/M3)**: `xiaohongshu-mcp-darwin-arm64.tar.gz`
- **macOS Intel**: `xiaohongshu-mcp-darwin-amd64.tar.gz`
- **Windows x64**: `xiaohongshu-mcp-windows-amd64.zip`
- **Linux x64**: `xiaohongshu-mcp-linux-amd64.tar.gz`
- **Linux ARM64**: `xiaohongshu-mcp-linux-arm64.tar.gz`
每个压缩包包含:
- `xiaohongshu-mcp-*`: MCP 服务主程序
- `xiaohongshu-login-*`: 登录工具
### 🔧 使用方法
```bash
# 1. 解压文件(macOS/Linux
tar xzf xiaohongshu-mcp-darwin-arm64.tar.gz
# 或 Windows
# 解压 xiaohongshu-mcp-windows-amd64.zip
# 2. 运行登录工具
./xiaohongshu-login-darwin-arm64
# 3. 启动 MCP 服务
./xiaohongshu-mcp-darwin-arm64
```
### 🐳 Docker 镜像
正式版本请使用 Docker 镜像:推送语义化版本 tag(如 `git tag v1.2.8 && git push origin v1.2.8`)会自动构建并发布到 Docker Hub 和阿里云。
### 📊 构建信息
- **Commit**: ${{ github.sha }}
- **Branch**: main
- **Build Time**: ${{ steps.version.outputs.version }}
files: |
xiaohongshu-mcp-darwin-arm64.tar.gz
xiaohongshu-mcp-darwin-amd64.tar.gz
xiaohongshu-mcp-windows-amd64.zip
xiaohongshu-mcp-linux-amd64.tar.gz
xiaohongshu-mcp-linux-arm64.tar.gz
+1 -1
View File
@@ -3,7 +3,7 @@ name: Tag and Release
on:
push:
tags:
# 只匹配语义化版本 tag,不匹配 release.yml 自动生成的日期 tag
# 只匹配语义化版本 tag,不匹配历史遗留的日期 tag
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
workflow_dispatch:
+9
View File
@@ -27,6 +27,15 @@ jobs:
- name: Unit tests
run: go test ./...
# 交叉编译检查:发布产物覆盖五个平台,但 CI 默认只在 linux/amd64 上构建,
# 平台相关的编译错误会拖到发版时才暴露。这里只编译不留产物,几秒钟。
- name: Cross-compile check
run: |
for target in darwin/arm64 darwin/amd64 linux/amd64 linux/arm64 windows/amd64; do
echo "==> $target"
GOOS=${target%/*} GOARCH=${target#*/} CGO_ENABLED=0 go build ./...
done
# 集成测试只编译不运行:保证它们始终跟当前 API 一致、不烂掉,
# 但绝不在 CI 启动有头浏览器(-run '^$' 匹配空,一个用例都不跑)。
- name: Compile integration tests (no run)