This repository was archived by the owner on Oct 22, 2026. It is now read-only.
Repository navigation
feat(subscription): 支持 -ua 和 -hwid 订阅请求参数 #79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 构建与发布工作流 | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'src/module/**' | |
| tags: | |
| - '*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build_and_release: | |
| name: 构建与发布 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 拉取代码 | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: 更新并准备变量 | |
| run: | | |
| COMMIT_COUNT=$(git rev-list --count HEAD) | |
| sed -i "s/^versionCode=.*/versionCode=$COMMIT_COUNT/" src/module/module.prop | |
| VERSION=$(grep '^version=' src/module/module.prop | cut -d= -f2) | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "COMMIT_COUNT=$COMMIT_COUNT" >> $GITHUB_ENV | |
| # 定义包名 | |
| FULL_NAME="NetProxy_${VERSION}_${COMMIT_COUNT}.zip" | |
| LITE_NAME="NetProxy_${VERSION}_${COMMIT_COUNT}_lite.zip" | |
| MINI_NAME="NetProxy_${VERSION}_${COMMIT_COUNT}_mini.zip" | |
| echo "FULL_NAME=$FULL_NAME" >> $GITHUB_ENV | |
| echo "LITE_NAME=$LITE_NAME" >> $GITHUB_ENV | |
| echo "MINI_NAME=$MINI_NAME" >> $GITHUB_ENV | |
| - name: 打包模块 | |
| run: | | |
| cd src/module | |
| # 1. 完整包 (全部组件) | |
| 7z a -tzip -mx=9 "../../${{ env.FULL_NAME }}" . | |
| # 2. 精简包 (排除 IPSET 相关文件) | |
| 7z a -tzip -mx=9 "../../${{ env.LITE_NAME }}" . -x!"bin/IPSET-LKM/*" -x!"bin/ipset" | |
| # 3. 纯脚本包 (排除所有二进制文件) | |
| 7z a -tzip -mx=9 "../../${{ env.MINI_NAME }}" . -x!"bin/sing-box" -x!"bin/proxylink" -x!"bin/ipset" -x!"bin/IPSET-LKM/*" -x!"bin/zashboard/*" | |
| cd ../.. | |
| - name: 发送模块到 Telegram (分支推送/手动触发) | |
| if: ${{ github.ref_type != 'tag' }} | |
| env: | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| CAPTION="模块构建成功通知 | |
| 版本: \`${{ env.VERSION }}\` (build ${{ env.COMMIT_COUNT }}) | |
| 说明: | |
| \`\`\` | |
| ${COMMIT_MSG:-"手动触发或无说明"} | |
| \`\`\` | |
| [提交记录](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) | |
| [构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" | |
| # 发送完整包 | |
| curl -s -F "chat_id=${{ secrets.TG_CHAT_ID }}" -F "document=@${{ env.FULL_NAME }}" -F "message_thread_id=2275" -F "parse_mode=Markdown" -F "caption=$CAPTION" https://api.telegram.org/bot${{ secrets.TG_BOT_TOKEN }}/sendDocument | |
| # 发送精简包 | |
| curl -s -F "chat_id=${{ secrets.TG_CHAT_ID }}" -F "document=@${{ env.LITE_NAME }}" -F "message_thread_id=2275" -F "caption=lite: 不含 IPSET 驱动,适用于内核已内置 IPSET 的设备" https://api.telegram.org/bot${{ secrets.TG_BOT_TOKEN }}/sendDocument | |
| # 发送纯脚本包 | |
| curl -s -F "chat_id=${{ secrets.TG_CHAT_ID }}" -F "document=@${{ env.MINI_NAME }}" -F "message_thread_id=2275" -F "caption=mini: 不含二进制文件和 IPSET 驱动,需自行放入 sing-box、proxylink、zashboard 等组件" https://api.telegram.org/bot${{ secrets.TG_BOT_TOKEN }}/sendDocument | |
| - name: 发布 GitHub Release (Tag 触发) | |
| if: ${{ github.ref_type == 'tag' }} | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| body_path: .github/changelog.md | |
| files: | | |
| ${{ env.FULL_NAME }} | |
| ${{ env.LITE_NAME }} | |
| ${{ env.MINI_NAME }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 发送 Release 通知到 Telegram (Tag 触发) | |
| if: ${{ github.ref_type == 'tag' }} | |
| uses: cbrgm/telegram-github-action@v1 | |
| with: | |
| token: ${{ secrets.TG_BOT_TOKEN }} | |
| to: ${{ secrets.TG_CHAT_ID }} | |
| thread-id: 2343 | |
| parse-mode: markdown | |
| message: | | |
| **新版本发布通知** | |
| 版本: `${{ github.ref_name }}` | |
| [查看更新日志并下载](${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}) | |
| **直接下载:** | |
| [完整包](${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ env.FULL_NAME }}) | |
| [精简包](${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ env.LITE_NAME }}) | |
| [纯脚本包](${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ env.MINI_NAME }}) | |
| - name: 失败通知 | |
| if: ${{ failure() }} | |
| env: | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| uses: cbrgm/telegram-github-action@v1 | |
| with: | |
| token: ${{ secrets.TG_BOT_TOKEN }} | |
| to: ${{ secrets.TG_CHAT_ID }} | |
| thread-id: 2275 | |
| parse-mode: markdown | |
| message: | | |
| **工作流执行失败!** | |
| 说明: | |
| \`\`\` | |
| ${COMMIT_MSG:-"无"} | |
| \`\`\` | |
| [点击查看构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) |