feat: 增加 GitHub Actions 多平台构建和 Release 自动化
- 添加 GitHub Actions 工作流,支持多平台构建: - macOS ARM64 (Apple Silicon) - macOS Intel (AMD64) - Windows x64 - Linux x64 - 支持自动触发(推送到 main 分支且包含 Go 代码修改) - 支持手动触发 - 更新 README 文档,添加二进制文件下载说明 - 添加浏览器自动下载提示 - 格式化所有 Go 源码文件 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
123
.github/workflows/release.yml
vendored
Normal file
123
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
- 'go.mod'
|
||||||
|
- 'go.sum'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
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 .
|
||||||
|
|
||||||
|
# macOS Intel
|
||||||
|
GOOS=darwin GOARCH=amd64 go build -o xiaohongshu-mcp-darwin-amd64 .
|
||||||
|
|
||||||
|
# Windows x64
|
||||||
|
GOOS=windows GOARCH=amd64 go build -o xiaohongshu-mcp-windows-amd64.exe .
|
||||||
|
|
||||||
|
# Linux x64
|
||||||
|
GOOS=linux GOARCH=amd64 go build -o xiaohongshu-mcp-linux-amd64 .
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.version.outputs.version }}
|
||||||
|
release_name: Release ${{ steps.version.outputs.version }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
body: |
|
||||||
|
## 🚀 新版本发布
|
||||||
|
|
||||||
|
**注意事项:**
|
||||||
|
- 首次运行时会自动下载无头浏览器(约 150MB),请确保网络连接正常
|
||||||
|
- 后续运行无需重复下载浏览器
|
||||||
|
|
||||||
|
**下载说明:**
|
||||||
|
- **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`
|
||||||
|
|
||||||
|
**使用方法:**
|
||||||
|
```bash
|
||||||
|
# 下载对应平台的文件后,直接运行
|
||||||
|
./xiaohongshu-mcp-darwin-arm64
|
||||||
|
|
||||||
|
# 或指定参数
|
||||||
|
./xiaohongshu-mcp-darwin-arm64 -headless=false
|
||||||
|
```
|
||||||
|
|
||||||
|
**构建信息:**
|
||||||
|
- Commit: ${{ github.sha }}
|
||||||
|
- Go Version: 1.24
|
||||||
|
|
||||||
|
- name: Upload macOS ARM64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./xiaohongshu-mcp-darwin-arm64
|
||||||
|
asset_name: xiaohongshu-mcp-darwin-arm64
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
|
- name: Upload macOS Intel
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./xiaohongshu-mcp-darwin-amd64
|
||||||
|
asset_name: xiaohongshu-mcp-darwin-amd64
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
|
- name: Upload Windows x64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./xiaohongshu-mcp-windows-amd64.exe
|
||||||
|
asset_name: xiaohongshu-mcp-windows-amd64.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
|
- name: Upload Linux x64
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./xiaohongshu-mcp-linux-amd64
|
||||||
|
asset_name: xiaohongshu-mcp-linux-amd64
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
43
README.md
43
README.md
@@ -138,10 +138,33 @@ https://github.com/user-attachments/assets/cc385b6c-422c-489b-a5fc-63e92c695b80
|
|||||||
|
|
||||||
## 1. 使用教程
|
## 1. 使用教程
|
||||||
|
|
||||||
### 1.1. 安装
|
### 1.1. 快速开始(推荐)
|
||||||
|
|
||||||
|
**方式一:下载预编译二进制文件**
|
||||||
|
|
||||||
|
直接从 [GitHub Releases](https://github.com/xpzouying/xiaohongshu-mcp/releases) 下载对应平台的二进制文件:
|
||||||
|
|
||||||
|
- **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`
|
||||||
|
|
||||||
|
下载后直接运行:
|
||||||
|
```bash
|
||||||
|
# macOS/Linux
|
||||||
|
chmod +x xiaohongshu-mcp-darwin-arm64
|
||||||
|
./xiaohongshu-mcp-darwin-arm64
|
||||||
|
|
||||||
|
# Windows
|
||||||
|
xiaohongshu-mcp-windows-amd64.exe
|
||||||
|
```
|
||||||
|
|
||||||
|
**⚠️ 重要提示**:首次运行时会自动下载无头浏览器(约 150MB),请确保网络连接正常。后续运行无需重复下载。
|
||||||
|
|
||||||
|
**方式二:源码编译**
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>安装配置详情</summary>
|
<summary>源码编译安装详情</summary>
|
||||||
|
|
||||||
依赖 Golang 环境,安装方法请参考 [Golang 官方文档](https://go.dev/doc/install)。
|
依赖 Golang 环境,安装方法请参考 [Golang 官方文档](https://go.dev/doc/install)。
|
||||||
|
|
||||||
@@ -168,8 +191,13 @@ Windows 遇到问题首先看这里:[Windows 安装指南](./docs/windows_guid
|
|||||||
|
|
||||||
第一次需要手动登录,需要保存小红书的登录状态。
|
第一次需要手动登录,需要保存小红书的登录状态。
|
||||||
|
|
||||||
运行
|
**使用二进制文件**:
|
||||||
|
```bash
|
||||||
|
# 下载 login 工具或使用源码编译
|
||||||
|
go run cmd/login/main.go
|
||||||
|
```
|
||||||
|
|
||||||
|
**使用源码**:
|
||||||
```bash
|
```bash
|
||||||
go run cmd/login/main.go
|
go run cmd/login/main.go
|
||||||
```
|
```
|
||||||
@@ -178,8 +206,17 @@ go run cmd/login/main.go
|
|||||||
|
|
||||||
启动 xiaohongshu-mcp 服务。
|
启动 xiaohongshu-mcp 服务。
|
||||||
|
|
||||||
|
**使用二进制文件**:
|
||||||
```bash
|
```bash
|
||||||
|
# 默认:无头模式,没有浏览器界面
|
||||||
|
./xiaohongshu-mcp-darwin-arm64
|
||||||
|
|
||||||
|
# 非无头模式,有浏览器界面
|
||||||
|
./xiaohongshu-mcp-darwin-arm64 -headless=false
|
||||||
|
```
|
||||||
|
|
||||||
|
**使用源码**:
|
||||||
|
```bash
|
||||||
# 默认:无头模式,没有浏览器界面
|
# 默认:无头模式,没有浏览器界面
|
||||||
go run .
|
go run .
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user