fix(api): 修正Hypixel插件的报错信息 #8
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: | |
| push: | |
| branches: [AxTBot-v2.1] # 在当前分支推送时触发 | |
| jobs: | |
| Build-And-Release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. 检出代码 | |
| - name: 签出代码 | |
| uses: actions/checkout@v4 | |
| # 2. 设置 Python 环境 | |
| - name: 设置Python环境 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| # 3. 安装依赖 | |
| - name: 安装依赖 | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install tomli # 安装tomli用于版本检查 | |
| # 4. 从 pyproject.toml 提取版本号 | |
| - name: 获取版本号 | |
| id: version | |
| run: | | |
| VERSION=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # 5. 检查版本是否已存在 | |
| - name: 检查版本是否已发布 | |
| id: check-release | |
| run: | | |
| # 获取已存在的标签列表 | |
| git fetch --tags | |
| # 检查当前版本标签是否存在 | |
| if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then | |
| echo "版本 ${{ steps.version.outputs.version }} 已存在,跳过发布" | |
| echo "skip_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "新版本 ${{ steps.version.outputs.version }},继续发布" | |
| echo "skip_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| # 6. 创建 Git 标签 | |
| - name: 创建Git tag | |
| if: ${{ steps.check-release.outputs.skip_release == 'false' }} | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const version = '${{ steps.version.outputs.version }}' | |
| await github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: `refs/tags/v${version}`, | |
| sha: context.sha | |
| }) | |
| # 7. 发布到 GitHub Release | |
| - name: 上传至GitHub Release | |
| if: ${{ steps.check-release.outputs.skip_release == 'false' }} | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| files: dist/* | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |