From 6e3b9b96da023da53c87e3dccfb68b9a0b23047a Mon Sep 17 00:00:00 2001 From: xming521 <1223398803@qq.com> Date: Thu, 19 Jun 2025 21:12:28 +0800 Subject: [PATCH] fix tg ci --- .github/weclone-release-event.json | 50 +++++++++++ .github/workflows/tg_release_notification.yml | 87 +++++++++++++++++-- 2 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 .github/weclone-release-event.json diff --git a/.github/weclone-release-event.json b/.github/weclone-release-event.json new file mode 100644 index 0000000..b3c2640 --- /dev/null +++ b/.github/weclone-release-event.json @@ -0,0 +1,50 @@ +{ + "action": "published", + "release": { + "id": 123456789, + "tag_name": "v0.2.24", + "target_commitish": "main", + "name": "v0.2.24", + "body": "## 🥰 What's Changed\n - Update torch version to 2.7.0 and vllm version to 0.9.1, switch offline inference to chat-style invocation\n - Add `test_model_args` and `vllm_args` configuration items to allow custom test dataset files\n - Add config file path option in CLI, support setting WECLONE_CONFIG_PATH environment variable\n - Update max_new_tokens and enable_thinking parameters in data cleaning strategy to optimize inference\n - Partial feature adaptation for qwen3\n \n ## 🐛 Bug fix\n fix #158 fix #83 fix #77 fix #69 \n \n **Full Changelog**: https://github.com/xming521/WeClone/compare/v0.2.23...v0.2.24\n \n ## 🥰 更新内容\n - 更新torch版本至2.7.0,vllm版本到0.9.1,离线推理改为chat方式调用\n - 添加`test_model_args` and `vllm_args`配置项,允许自定义测试集文件\n - CLI中添加配置文件路径选项,支持设置WECLONE_CONFIG_PATH环境变量\n - 更新数据清理策略中的max_new_tokens和enable_thinking参数以优化推理过程\n - 部分功能适配qwen3", + "draft": false, + "prerelease": false, + "created_at": "2024-01-15T10:30:00Z", + "published_at": "2024-01-15T10:30:00Z", + "author": { + "login": "xming521", + "id": 12345, + "avatar_url": "https://avatars.githubusercontent.com/u/12345?v=4", + "html_url": "https://github.com/xming521" + }, + "html_url": "https://github.com/xming521/WeClone/releases/tag/v0.2.24", + "assets_url": "https://api.github.com/repos/xming521/WeClone/releases/123456789/assets", + "upload_url": "https://uploads.github.com/repos/xming521/WeClone/releases/123456789/assets{?name,label}", + "tarball_url": "https://api.github.com/repos/xming521/WeClone/tarball/v0.2.24", + "zipball_url": "https://api.github.com/repos/xming521/WeClone/zipball/v0.2.24", + "assets": [] + }, + "repository": { + "id": 987654321, + "name": "WeClone", + "full_name": "xming521/WeClone", + "owner": { + "login": "xming521", + "id": 12345 + }, + "private": false, + "html_url": "https://github.com/xming521/WeClone", + "description": "WeClone - AI Clone Repository", + "fork": false, + "created_at": "2023-01-01T00:00:00Z", + "updated_at": "2024-01-15T10:30:00Z", + "pushed_at": "2024-01-15T10:25:00Z", + "clone_url": "https://github.com/xming521/WeClone.git", + "default_branch": "main" + }, + "sender": { + "login": "xming521", + "id": 12345, + "avatar_url": "https://avatars.githubusercontent.com/u/12345?v=4", + "html_url": "https://github.com/xming521" + } +} diff --git a/.github/workflows/tg_release_notification.yml b/.github/workflows/tg_release_notification.yml index ee92a3f..3d0e91c 100644 --- a/.github/workflows/tg_release_notification.yml +++ b/.github/workflows/tg_release_notification.yml @@ -8,15 +8,90 @@ jobs: notify: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install telegramify-markdown + run: | + npm init -y + npm install telegramify-markdown + + - name: Convert release body to Telegram format + id: convert-markdown + run: | + # 先将release body保存到文件 + cat > release_body.txt << 'RELEASE_BODY_EOF' + ${{ github.event.release.body }} + RELEASE_BODY_EOF + + # 然后创建转换脚本 + cat > convert-release.js << 'EOF' + const telegramifyMarkdown = require('telegramify-markdown'); + const fs = require('fs'); + + // 从文件读取release body内容(避免shell解析问题) + let releaseBody = ''; + try { + releaseBody = fs.readFileSync('release_body.txt', 'utf8'); + } catch (error) { + console.error('读取release body失败:', error); + releaseBody = process.env.RELEASE_BODY || ''; + } + + console.log('=== 原始release body ==='); + console.log(releaseBody); + + // 转换为Telegram格式 + const telegramBody = telegramifyMarkdown(releaseBody); + + // 构建完整的消息 + const tagName = process.env.TAG_NAME || ''; + const releaseUrl = process.env.RELEASE_URL || ''; + + const fullMessage = `🚀 *WeClone New Version Released* + 🏷️ *Version*: \`${tagName}\` + 🔗 *Link*: [Github Release](${releaseUrl}) + 📋 *Release Notes*: + ${telegramBody}`; + + // 输出到GitHub Actions + console.log('转换后的消息:'); + console.log(fullMessage); + + // 将消息保存到环境变量 + fs.writeFileSync('telegram_message.txt', fullMessage); + EOF + + # 设置环境变量 + export RELEASE_BODY="${{ github.event.release.body }}" + export TAG_NAME="${{ github.event.release.tag_name }}" + export RELEASE_URL="${{ github.event.release.html_url }}" + export REPO_NAME="${{ github.repository }}" + + # 运行转换脚本 + node convert-release.js + + # 读取转换后的消息并设置为输出 + echo "TELEGRAM_MESSAGE<> $GITHUB_OUTPUT + cat telegram_message.txt >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + # - name: Display converted message + # run: | + # echo "=== 转换后的Telegram消息 ===" + # echo "${{ steps.convert-markdown.outputs.TELEGRAM_MESSAGE }}" + - name: Send Telegram Message uses: appleboy/telegram-action@master with: to: ${{ secrets.TELEGRAM_CHAT_ID }} token: ${{ secrets.TELEGRAM_BOT_TOKEN }} - message: | - 🚀 新版本发布! - 🏷️ 版本: ${{ github.event.release.tag_name }} - 🔗 链接: ${{ github.event.release.html_url }} - 发布说明: - ${{ github.event.release.body }} + message: ${{ steps.convert-markdown.outputs.TELEGRAM_MESSAGE }} format: markdown + disable_web_page_preview: false +