refactor: 改进发布策略,将自动发布改为手动触发
- 修改 release.yml 为仅构建不打 tag,构建产物保存为 artifacts - 新增 tag-release.yml 用于手动触发发布和打 tag - 删除所有历史自动生成的 tags - 采用更合理的版本管理策略,避免版本号膨胀 现在的工作流: 1. push to main 时自动构建(不打 tag) 2. 需要发布时手动触发 Tag and Release workflow 3. 手动输入语义化版本号(如 v1.0.0)和发布说明 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
72
.github/workflows/release.yml
vendored
72
.github/workflows/release.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Build and Release
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,7 +7,6 @@ on:
|
|||||||
- '**.go'
|
- '**.go'
|
||||||
- 'go.mod'
|
- 'go.mod'
|
||||||
- 'go.sum'
|
- 'go.sum'
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -26,14 +25,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: '1.24'
|
go-version: '1.24'
|
||||||
|
|
||||||
- name: Generate version
|
- name: Display build info
|
||||||
id: version
|
|
||||||
run: |
|
run: |
|
||||||
TIMESTAMP=$(date +%Y.%m.%d.%H%M)
|
echo "Building commit: $(git rev-parse --short HEAD)"
|
||||||
COMMIT_SHA=$(git rev-parse --short HEAD)
|
echo "Build time: $(date +%Y.%m.%d.%H%M)"
|
||||||
VERSION="v${TIMESTAMP}-${COMMIT_SHA}"
|
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
|
||||||
echo "Generated version: ${VERSION}"
|
|
||||||
|
|
||||||
- name: Build for multiple platforms
|
- name: Build for multiple platforms
|
||||||
run: |
|
run: |
|
||||||
@@ -54,56 +49,11 @@ jobs:
|
|||||||
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-mcp-linux-amd64 .
|
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-mcp-linux-amd64 .
|
||||||
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-login-linux-amd64 ./cmd/login
|
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-login-linux-amd64 ./cmd/login
|
||||||
|
|
||||||
- name: Create Release
|
- name: Upload artifacts
|
||||||
id: create_release
|
uses: actions/upload-artifact@v3
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.version.outputs.version }}
|
name: binaries-${{ github.sha }}
|
||||||
name: Release ${{ steps.version.outputs.version }}
|
path: |
|
||||||
draft: false
|
xiaohongshu-mcp-*
|
||||||
prerelease: false
|
xiaohongshu-login-*
|
||||||
body: |
|
retention-days: 7
|
||||||
## 🚀 新版本发布
|
|
||||||
|
|
||||||
**注意事项:**
|
|
||||||
- 首次运行时会自动下载无头浏览器(约 150MB),请确保网络连接正常
|
|
||||||
- 后续运行无需重复下载浏览器
|
|
||||||
|
|
||||||
**下载说明:**
|
|
||||||
|
|
||||||
**主程序(MCP 服务):**
|
|
||||||
- **macOS Apple Silicon**: `xiaohongshu-mcp-darwin-arm64`
|
|
||||||
- **macOS Intel**: `xiaohongshu-mcp-darwin-amd64`
|
|
||||||
- **Windows x64**: `xiaohongshu-mcp-windows-amd64.exe`
|
|
||||||
- **Linux x64**: `xiaohongshu-mcp-linux-amd64`
|
|
||||||
|
|
||||||
**登录工具:**
|
|
||||||
- **macOS Apple Silicon**: `xiaohongshu-login-darwin-arm64`
|
|
||||||
- **macOS Intel**: `xiaohongshu-login-darwin-amd64`
|
|
||||||
- **Windows x64**: `xiaohongshu-login-windows-amd64.exe`
|
|
||||||
- **Linux x64**: `xiaohongshu-login-linux-amd64`
|
|
||||||
|
|
||||||
**使用方法:**
|
|
||||||
```bash
|
|
||||||
# 1. 首先运行登录工具
|
|
||||||
./xiaohongshu-login-darwin-arm64
|
|
||||||
|
|
||||||
# 2. 然后启动 MCP 服务
|
|
||||||
./xiaohongshu-mcp-darwin-arm64
|
|
||||||
|
|
||||||
# 或指定参数
|
|
||||||
./xiaohongshu-mcp-darwin-arm64 -headless=false
|
|
||||||
```
|
|
||||||
|
|
||||||
**构建信息:**
|
|
||||||
- Commit: ${{ github.sha }}
|
|
||||||
- Go Version: 1.24
|
|
||||||
files: |
|
|
||||||
xiaohongshu-mcp-darwin-arm64
|
|
||||||
xiaohongshu-mcp-darwin-amd64
|
|
||||||
xiaohongshu-mcp-windows-amd64.exe
|
|
||||||
xiaohongshu-mcp-linux-amd64
|
|
||||||
xiaohongshu-login-darwin-arm64
|
|
||||||
xiaohongshu-login-darwin-amd64
|
|
||||||
xiaohongshu-login-windows-amd64.exe
|
|
||||||
xiaohongshu-login-linux-amd64
|
|
||||||
153
.github/workflows/tag-release.yml
vendored
Normal file
153
.github/workflows/tag-release.yml
vendored
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
name: Tag and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: 'Version tag (e.g., v1.0.0)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
release_notes:
|
||||||
|
description: 'Release notes (optional)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tag-and-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Validate version format
|
||||||
|
run: |
|
||||||
|
VERSION="${{ github.event.inputs.version }}"
|
||||||
|
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9\.]+)?$ ]]; then
|
||||||
|
echo "Error: Version must follow semantic versioning (e.g., v1.0.0, v1.0.0-beta.1)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if tag already exists
|
||||||
|
if git rev-parse "$VERSION" >/dev/null 2>&1; then
|
||||||
|
echo "Error: Tag $VERSION already exists"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Version $VERSION is valid"
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '1.24'
|
||||||
|
|
||||||
|
- name: Build for multiple platforms
|
||||||
|
run: |
|
||||||
|
# 主程序构建
|
||||||
|
# macOS ARM64 (Apple Silicon)
|
||||||
|
GOOS=darwin GOARCH=arm64 go build -o xiaohongshu-mcp-darwin-arm64 .
|
||||||
|
GOOS=darwin GOARCH=arm64 go build -o xiaohongshu-login-darwin-arm64 ./cmd/login
|
||||||
|
|
||||||
|
# macOS Intel
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -o xiaohongshu-mcp-darwin-amd64 .
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -o xiaohongshu-login-darwin-amd64 ./cmd/login
|
||||||
|
|
||||||
|
# Windows x64
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o xiaohongshu-mcp-windows-amd64.exe .
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o xiaohongshu-login-windows-amd64.exe ./cmd/login
|
||||||
|
|
||||||
|
# Linux x64
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-mcp-linux-amd64 .
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-login-linux-amd64 ./cmd/login
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
# Get the previous tag
|
||||||
|
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
if [ -z "$PREV_TAG" ]; then
|
||||||
|
echo "No previous tag found, including all commits"
|
||||||
|
COMMITS=$(git log --oneline --format="- %s (%h)" | head -20)
|
||||||
|
else
|
||||||
|
echo "Generating changelog from $PREV_TAG to HEAD"
|
||||||
|
COMMITS=$(git log $PREV_TAG..HEAD --oneline --format="- %s (%h)")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Save to output
|
||||||
|
{
|
||||||
|
echo "commits<<EOF"
|
||||||
|
echo "$COMMITS"
|
||||||
|
echo "EOF"
|
||||||
|
} >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create tag and release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.event.inputs.version }}
|
||||||
|
name: Release ${{ github.event.inputs.version }}
|
||||||
|
draft: false
|
||||||
|
prerelease: ${{ contains(github.event.inputs.version, '-') }}
|
||||||
|
body: |
|
||||||
|
## 🚀 新版本发布: ${{ github.event.inputs.version }}
|
||||||
|
|
||||||
|
${{ github.event.inputs.release_notes }}
|
||||||
|
|
||||||
|
### 📋 更新内容
|
||||||
|
|
||||||
|
${{ steps.changelog.outputs.commits }}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 📦 下载说明
|
||||||
|
|
||||||
|
**主程序(MCP 服务):**
|
||||||
|
- **macOS Apple Silicon**: `xiaohongshu-mcp-darwin-arm64`
|
||||||
|
- **macOS Intel**: `xiaohongshu-mcp-darwin-amd64`
|
||||||
|
- **Windows x64**: `xiaohongshu-mcp-windows-amd64.exe`
|
||||||
|
- **Linux x64**: `xiaohongshu-mcp-linux-amd64`
|
||||||
|
|
||||||
|
**登录工具:**
|
||||||
|
- **macOS Apple Silicon**: `xiaohongshu-login-darwin-arm64`
|
||||||
|
- **macOS Intel**: `xiaohongshu-login-darwin-amd64`
|
||||||
|
- **Windows x64**: `xiaohongshu-login-windows-amd64.exe`
|
||||||
|
- **Linux x64**: `xiaohongshu-login-linux-amd64`
|
||||||
|
|
||||||
|
### 🔧 使用方法
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 首先运行登录工具获取 cookie
|
||||||
|
./xiaohongshu-login-darwin-arm64
|
||||||
|
|
||||||
|
# 2. 然后启动 MCP 服务
|
||||||
|
./xiaohongshu-mcp-darwin-arm64
|
||||||
|
|
||||||
|
# 或指定参数
|
||||||
|
./xiaohongshu-mcp-darwin-arm64 -headless=false
|
||||||
|
```
|
||||||
|
|
||||||
|
### ⚠️ 注意事项
|
||||||
|
|
||||||
|
- 首次运行时会自动下载无头浏览器(约 150MB),请确保网络连接正常
|
||||||
|
- 后续运行无需重复下载浏览器
|
||||||
|
- 登录工具生成的 cookie 保存在 `~/.xiaohongshu/cookies.json`
|
||||||
|
|
||||||
|
### 📊 构建信息
|
||||||
|
|
||||||
|
- **Commit**: ${{ github.sha }}
|
||||||
|
- **Go Version**: 1.24
|
||||||
|
- **Build Time**: ${{ github.event.repository.updated_at }}
|
||||||
|
files: |
|
||||||
|
xiaohongshu-mcp-darwin-arm64
|
||||||
|
xiaohongshu-mcp-darwin-amd64
|
||||||
|
xiaohongshu-mcp-windows-amd64.exe
|
||||||
|
xiaohongshu-mcp-linux-amd64
|
||||||
|
xiaohongshu-login-darwin-arm64
|
||||||
|
xiaohongshu-login-darwin-amd64
|
||||||
|
xiaohongshu-login-windows-amd64.exe
|
||||||
|
xiaohongshu-login-linux-amd64
|
||||||
Reference in New Issue
Block a user