mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: 优化前端构建分发和模型价格更新机制
1. 前端构建分发优化: - 修改 GitHub Actions workflow,构建前端后推送到 web-dist 分支 - 更新 manage.sh 安装脚本,从 web-dist 分支获取预构建文件 - 解决部分机器无法本地编译前端的问题 - 添加测试脚本 test-web-dist.sh 验证流程 2. 模型价格更新功能: - 添加手动更新模型价格脚本 update-model-pricing.js - 新增 npm run update:pricing 命令 - 在 manage.sh 添加 update-pricing 命令和菜单选项 - 支持备份、进度显示和统计信息 3. 其他改进: - 优化安装流程,减少对 Node.js 环境的依赖 - 提供多种更新模型价格的方式 - 改进错误处理和回退机制 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
73
.github/workflows/auto-release-pipeline.yml
vendored
73
.github/workflows/auto-release-pipeline.yml
vendored
@@ -123,8 +123,6 @@ jobs:
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "new_tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
# 前端构建已移至 Docker 构建流程中
|
||||
|
||||
- name: Update VERSION file
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
@@ -138,6 +136,77 @@ jobs:
|
||||
git add VERSION
|
||||
git commit -m "chore: sync VERSION file with release ${{ steps.next_version.outputs.new_tag }} [skip ci]"
|
||||
|
||||
# 构建前端并推送到 web-dist 分支
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: web/admin-spa/package-lock.json
|
||||
|
||||
- name: Build Frontend
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
echo "Building frontend for version ${{ steps.next_version.outputs.new_version }}..."
|
||||
cd web/admin-spa
|
||||
npm ci
|
||||
npm run build
|
||||
echo "Frontend build completed"
|
||||
|
||||
- name: Push Frontend Build to web-dist Branch
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
# 创建临时目录
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
echo "Using temp directory: $TEMP_DIR"
|
||||
|
||||
# 复制构建产物到临时目录
|
||||
cp -r web/admin-spa/dist/* "$TEMP_DIR/"
|
||||
|
||||
# 检查 web-dist 分支是否存在
|
||||
if git ls-remote --heads origin web-dist | grep -q web-dist; then
|
||||
echo "Checking out existing web-dist branch"
|
||||
git fetch origin web-dist:web-dist
|
||||
git checkout web-dist
|
||||
else
|
||||
echo "Creating new web-dist branch"
|
||||
git checkout --orphan web-dist
|
||||
fi
|
||||
|
||||
# 清空当前目录(保留 .git)
|
||||
git rm -rf . 2>/dev/null || true
|
||||
|
||||
# 复制构建产物
|
||||
cp -r "$TEMP_DIR"/* .
|
||||
|
||||
# 添加 README
|
||||
cat > README.md << 'EOF'
|
||||
# Claude Relay Service - Web Frontend Build
|
||||
|
||||
This branch contains the pre-built frontend assets for Claude Relay Service.
|
||||
|
||||
**DO NOT EDIT FILES IN THIS BRANCH DIRECTLY**
|
||||
|
||||
These files are automatically generated by the CI/CD pipeline.
|
||||
|
||||
Version: ${{ steps.next_version.outputs.new_version }}
|
||||
Build Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
|
||||
EOF
|
||||
|
||||
# 提交并推送
|
||||
git add -A
|
||||
git commit -m "chore: update frontend build for v${{ steps.next_version.outputs.new_version }} [skip ci]"
|
||||
git push origin web-dist --force
|
||||
|
||||
# 切换回主分支
|
||||
git checkout main
|
||||
|
||||
# 清理临时目录
|
||||
rm -rf "$TEMP_DIR"
|
||||
|
||||
echo "Frontend build pushed to web-dist branch successfully"
|
||||
|
||||
- name: Install git-cliff
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user