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

如何重置release-please-action的发布版本号?配置release-as未生效

重置release-please-action版本号失效的问题解决

问题描述

我尝试重置release-please-action发布的版本号,在GitHub Action配置文件中添加了release-as: "0.0.1"参数,但未生效。

我的Action配置

jobs:
  release-please:
    runs-on: ubuntu-latest
    steps:
      - uses: google-github-actions/release-please-action@v2
        with:
          release-type: node
          package-name: release-please-action
          default-branch: dev
          handleGHRelease: true
          skip-github-release: true
          release-as: "0.0.1"

运行输出

Run google-github-actions/release-please-action@v2
  with:
    release-type: node
    package-name: release-please-action
    default-branch: dev
    handleGHRelease: true
    skip-github-release: true
    release-as: 0.0.1
    token: ***
    fork: false
    clean: true
    bump-minor-pre-major: false
    bump-patch-for-minor-pre-major: false
    monorepo-tags: false
    pull-request-title-pattern: chore${scope}: release${component} ${version}
(node:1565) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
⚠ No merged release PR found
✖ Unable to build candidate
✔ found 2 commits since a626739a3ca8
✔ release as patch: There are 0 BREAKING CHANGES and 0 features
✔ updating package-lock.json from 1.4.0 to 1.4.1
⚠ file npm-shrinkwrap.json did not exist
⚠ file samples/package.json did not exist
⚠ CHANGELOG.md not found
✔ creating CHANGELOG.md
✔ updating package.json from 0.0.1 to 1.4.1
✔ Starting GitHub PR workflow...
✔ Successfully found branch HEAD sha "f031f892aedc3f952f309a".
✔ Skipping branch creation step...
✔ Got the latest commit tree
✔ Successfully created a tree with the desired changes with SHA 93504b339a3b10d40
✔ Successfully created commit. See commit at https://api.github.com/repos/useraccount/FFYselfservingAPI/git/commits/04950bb981ffe48
✔ Successfully updated reference release-v1.4.1 to 0495ec509adc1212a8e5ab34831fb0bb981ffe48
✔ Found existing pull request for reference useraccount:release-v1.4.1. Skipping creating a new pull request.
✔ Successfully opened pull request: 25.
✔ update pull-request #25: chore: release 1.4.1
✔ adding label autorelease: pending to https://github.com/useraccount/FFYselfservingAPI/pull/25
✔ find stale PRs with label "autorelease: pending"

实际运行后,版本仍从1.4.0升级到1.4.1,而非从0.0.1开始。

问题原因

release-please-action的核心逻辑是基于Git标签、已合并的Release PR等历史版本记录来追踪版本轨迹,即使配置了release-as,如果历史版本痕迹未清理,工具会优先沿用旧的版本线,忽略release-as的覆盖请求。从输出可以看到,工具仍在基于1.4.0的基准版本计算补丁版本。

解决步骤

  1. 清理历史版本痕迹

    • 删除仓库中所有与旧版本相关的Git标签(如v1.4.0、v1.4.1)
    • 关闭并删除之前生成的Release相关PR(如输出中的#25)
    • 若仓库存在已发布的GitHub Releases,同步删除对应版本
  2. 修正默认分支的版本文件
    手动将dev分支上的package.json版本号修改为0.0.1,提交并推送到仓库。

  3. 调整Action配置(可选)
    在原有配置基础上添加force: true参数(v2版本支持),强制工具使用指定版本生成Release PR:

    with:
      # ...原有配置
      release-as: "0.0.1"
      force: true
    
  4. 重新运行Action
    触发Action后,工具会基于清理后的状态和0.0.1的基准版本生成对应的Release PR。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 23:47:36