You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub版本与标签未正常创建问题排查求助

问题排查与修复方案

你的GitHub Workflow执行成功但未生成标签和Release,主要是以下几个配置遗漏:

1. tag_release Job 缺少代码拉取步骤

anothrNick/github-tag-action 需要读取仓库的Git历史和版本文件(如package.json)来计算新版本,但当前tag_release job里没有拉取代码的步骤。添加actions/checkout@v3并拉取完整Git历史:

tag_release:
  needs: [simple_deployment_pipeline]
  runs-on: ubuntu-20.04
  steps:
    - name: 拉取代码仓库
      uses: actions/checkout@v3
      with:
        fetch-depth: 0  # 拉取完整Git历史,确保工具能计算版本
    - name: Bump version and push tag
      uses: anothrNick/github-tag-action@1.36.0
      if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        DEFAULT_BUMP: patch
        RELEASE_BRANCHES: master

2. 可选:显式配置Token权限

如果是组织仓库或权限受限,可在Workflow顶部添加权限声明,确保Token有写入内容的权限:

name: Deployment pipeline

permissions:
  contents: write  # 授予推送标签的权限

on:
  push:
    branches:
      - master
  # 其余原有配置...

3. 可选:自动创建GitHub Release

如果需要同时生成Release(而非仅标签),可在打标签步骤后添加创建Release的动作:

- name: Bump version and push tag
      id: tag  # 添加ID以引用输出值
      uses: anothrNick/github-tag-action@1.36.0
      # 其余原有配置...
    
    - name: 创建GitHub Release
      uses: actions/create-release@v1
      if: ${{ github.event_name == 'push' && !contains(join(github.event.commits.*.message, ' '), '#skip') }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ steps.tag.outputs.new_tag }}
        release_name: Release ${{ steps.tag.outputs.new_tag }}
        body: ${{ steps.tag.outputs.changelog }}
        draft: false
        prerelease: false

4. 验证提交消息规则

检查你的提交消息中是否包含#skip关键词,Workflow的if条件会跳过含该关键词的推送,导致标签不生成。


内容的提问来源于stack exchange,提问作者Julius Goddard

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 05:50:20