- 添加 permissions: contents: write 配置 - 解决 403 权限错误问题 - 允许 GitHub Actions 创建 releases 和上传文件 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
109 lines
3.3 KiB
YAML
109 lines
3.3 KiB
YAML
name: Build and Release
|
||
|
||
on:
|
||
push:
|
||
branches: [ main ]
|
||
paths:
|
||
- '**.go'
|
||
- 'go.mod'
|
||
- 'go.sum'
|
||
workflow_dispatch:
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest
|
||
|
||
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 version
|
||
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: |
|
||
# 主程序构建
|
||
# 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: Create Release
|
||
id: 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: |
|
||
## 🚀 新版本发布
|
||
|
||
**注意事项:**
|
||
- 首次运行时会自动下载无头浏览器(约 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 |