Skip to content

feat(ci): Immutable release#2725

Open
tangge233 wants to merge 7 commits into
devfrom
feat/ci-immutable-release
Open

feat(ci): Immutable release#2725
tangge233 wants to merge 7 commits into
devfrom
feat/ci-immutable-release

Conversation

@tangge233
Copy link
Copy Markdown
Contributor

@tangge233 tangge233 commented Apr 18, 2026

Summary by Sourcery

引入一个由 PR 标题和草稿版本驱动的、不可变且手动触发的发布工作流,用以取代原有的 beta 和 stable 独立工作流。

新功能:

  • 新增一个发布触发工作流,用于解析已合并 PR 的标题以推导版本号和发布类型,然后携带合适的参数触发发布(publish)工作流。
  • 通过 workflow dispatch 输入支持可配置的发布构建,包括配置项、版本号和预发布(prerelease)标记,并支持创建草稿版本以及后续的正式发布。

增强:

  • 将 beta 和 stable 发布整合为单一的发布工作流,将构建产物上传到 GitHub 草稿版本,并同时处理两种架构。
  • 更新 GitHub Release 步骤,使用最新的 softprops/action-gh-release 动作,并将发布管理为草稿,待最终发布。
  • 将 MirrorChyan 上传和发布说明(release-note)工作流通过新的统一发布和草稿发布步骤进行路由,发布渠道由构建配置决定。

CI:

  • 使用统一的 release-publish 工作流加上基于 PR 合并的 release-trigger 工作流,替换之前的 beta 和 stable 发布工作流。
Original summary in English

Summary by Sourcery

Introduce an immutable, manually triggered release workflow driven by PR titles and draft releases, replacing separate beta and stable workflows.

New Features:

  • Add a release trigger workflow that parses merged PR titles to derive version and release type, then triggers the publish workflow with appropriate parameters.
  • Support configurable release builds via workflow dispatch inputs for configuration, version, and prerelease flag, including draft release creation and later publishing.

Enhancements:

  • Consolidate beta and stable publishing into a single release workflow that uploads artifacts to draft GitHub releases and handles both architectures.
  • Update GitHub Release steps to use the latest softprops/action-gh-release action and manage releases as drafts before final publication.
  • Route MirrorChyan upload and release-note workflows through the new unified release and publish-draft steps, with channels determined by build configuration.

CI:

  • Replace the previous beta and stable release workflows with a unified release-publish workflow plus a PR-merged-based release-trigger workflow.

@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Apr 18, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Apr 18, 2026

Reviewer's Guide

将发布工作流重构为单一、参数化的 release-publish 流水线,该流水线由新的基于 PR 合并驱动的 release-trigger 工作流触发;增加显式的版本/配置处理;使用不可变标签生成 GitHub 草稿发布,在二进制文件上传并触发镜像工作流后再正式发布。

PR 合并驱动的不可变发布流水线时序图

sequenceDiagram
    actor Maintainer
    participant GitHub as GitHub_PRs
    participant Workflow_RT as Workflow_release_trigger
    participant Workflow_RP as Workflow_release_publish
    participant Job_build as Job_build
    participant Job_changelog as Job_changelog
    participant Job_rename as Job_rename_and_release
    participant Job_publish as Job_publish_draft
    participant GHRelease as GitHub_Releases
    participant WF_MRCU as Workflow_mirrorchyan_uploading
    participant WF_MRCN as Workflow_mirrorchyan_release_note

    Maintainer->>GitHub: Merge PR with title release-stable: VERSION or beta-release: VERSION
    GitHub-->>Workflow_RT: Trigger on pull_request closed (merged)

    Workflow_RT->>Workflow_RT: Extract version and release type from PR title
    Workflow_RT->>Workflow_RP: Trigger release-publish.yml with inputs version, configuration, prerelease

    Workflow_RP->>Job_build: Start build matrix (configuration, architecture)
    Job_build-->>Workflow_RP: Build artifacts uploaded as artifacts

    Workflow_RP->>Job_changelog: Generate changelog via git-cliff
    Job_changelog->>GHRelease: Create or update draft release with tag vVERSION and body CHANGELOG.md

    Workflow_RP->>Job_rename: Start rename_and_release after build and changelog
    Job_rename->>Job_rename: Download artifacts and rename to PCL2_CE_configuration_architecture.exe
    Job_rename->>Job_rename: Sign binaries with gpg
    Job_rename->>GHRelease: Upload binaries and signatures to draft release

    Job_rename->>WF_MRCU: Trigger mirrorchyan_uploading.yml with channel and arch

    Workflow_RP->>Job_publish: Start publish_draft after rename_and_release
    Job_publish->>GHRelease: Publish draft release with tag vVERSION
    Job_publish->>WF_MRCN: Trigger mirrorchyan_release_note.yml
Loading

File-Level Changes

Change Details Files
将 beta/stable 发布统一为一个手动触发的工作流,并通过显式的配置和版本输入进行控制。
  • release-beta_publish.yml 重命名为 release-publish.yml,并修改工作流名称以更清晰地表达其用途。
  • 将触发条件从 release: published 改为带有 configurationversionprerelease 输入参数的 workflow_dispatch
  • 更新矩阵配置值,使用 inputs.configuration 的值,而不是硬编码的 Beta
  • 调整工作流权限,以允许写入 contents 和 actions。
.github/workflows/release-publish.yml
更改变更日志和发布创建逻辑,基于输入在草稿、版本化标签上运行,而不是依赖 GitHub Release 事件。
  • 移除依赖于 github.event.release.prerelease 的条件,因为该工作流不再由 release 事件驱动。
  • 使用 git-cliff 生成变更日志,并使用 softprops/action-gh-release@v3 创建或更新草稿发布。
  • 使用 v${{ inputs.version }} 作为标签名,将 name 设置为发布版本,并传递 inputs.prerelease 以标记预发布版本。
.github/workflows/release-publish.yml
将签名后的二进制文件上传到草稿发布,并根据配置正确路由到 MirrorChyan 上传。
  • 继续下载构建产物,根据配置/架构重命名,并生成 GPG 签名。
  • 在上传二进制文件时将 softprops/action-gh-release 更新到 v3,并确保它们附加到同一个草稿发布标签 v${{ inputs.version }}
  • inputs.configuration 推导 MirrorChyan 渠道(betastable),而不是硬编码 beta,并确保提供 GH_TOKEN
.github/workflows/release-publish.yml
在附件上传完成后增加最终步骤,用于发布草稿并通知 MirrorChyan 发布说明。
  • 新增一个依赖于重命名/上传的 publish_draft 任务,使用 softprops/action-gh-release@v3 发布标签为 v${{ inputs.version }} 的草稿。
  • 在发布后触发 mirrorchyan_release_note.yml 工作流,并使用 GH_TOKEN 进行认证。
  • 通过任务级依赖确保只有在所有架构都处理完成后才执行发布。
.github/workflows/release-publish.yml
引入一个新工作流,在具有正确格式标题的 PR 被合并时自动触发发布工作流。
  • 新增监听 pull_request closed 事件并过滤已合并 PR 的 release-trigger.yml
  • 使用 Bash 正则解析 PR 标题,检测支持 SemVer 且可选 v 前缀的 release-stable: VERSIONbeta-release: VERSION 模式。
  • 将发布类型映射为 ReleaseBeta 配置,并通过 GitHub CLI 触发 release-publish.yml,传入 versionconfigurationprerelease
.github/workflows/release-trigger.yml
删除独立的 stable 发布工作流,改用统一的发布流水线。
  • 删除 .github/workflows/release-stable_publish.yml,因为其职责已由参数化的 release-publish.yml 覆盖。
.github/workflows/release-stable_publish.yml

Tips and commands

Interacting with Sourcery

  • 触发新的评审: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub issue: 回复 Sourcery 的评审评论,要求其从该评论创建 issue。你也可以直接回复评审评论 @sourcery-ai issue 来从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai 即可随时生成标题。你也可以在 pull request 中评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 描述正文的任意位置写上 @sourcery-ai summary,即可在你指定的位置随时生成 PR 摘要。你也可以在 pull request 中评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成评审者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 一次性解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 忽略所有 Sourcery 评审: 在 pull request 中评论 @sourcery-ai dismiss,以忽略所有现有的 Sourcery 评审。特别适用于你想从头开始新的评审——别忘了再评论 @sourcery-ai review 来触发新的评审!

Customizing Your Experience

打开你的 dashboard 来:

  • 启用或禁用诸如 Sourcery 自动生成的 pull request 摘要、评审者指南等评审功能。
  • 更改评审语言。
  • 添加、删除或编辑自定义评审指令。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Refactors the release workflows into a single, parameterized release-publish pipeline triggered by a new PR-merge-driven release-trigger workflow, adds explicit version/configuration handling, generates draft GitHub releases with immutable tags, and then publishes them after binaries are uploaded and mirror workflows are triggered.

Sequence diagram for PR-merge driven immutable release pipeline

sequenceDiagram
    actor Maintainer
    participant GitHub as GitHub_PRs
    participant Workflow_RT as Workflow_release_trigger
    participant Workflow_RP as Workflow_release_publish
    participant Job_build as Job_build
    participant Job_changelog as Job_changelog
    participant Job_rename as Job_rename_and_release
    participant Job_publish as Job_publish_draft
    participant GHRelease as GitHub_Releases
    participant WF_MRCU as Workflow_mirrorchyan_uploading
    participant WF_MRCN as Workflow_mirrorchyan_release_note

    Maintainer->>GitHub: Merge PR with title release-stable: VERSION or beta-release: VERSION
    GitHub-->>Workflow_RT: Trigger on pull_request closed (merged)

    Workflow_RT->>Workflow_RT: Extract version and release type from PR title
    Workflow_RT->>Workflow_RP: Trigger release-publish.yml with inputs version, configuration, prerelease

    Workflow_RP->>Job_build: Start build matrix (configuration, architecture)
    Job_build-->>Workflow_RP: Build artifacts uploaded as artifacts

    Workflow_RP->>Job_changelog: Generate changelog via git-cliff
    Job_changelog->>GHRelease: Create or update draft release with tag vVERSION and body CHANGELOG.md

    Workflow_RP->>Job_rename: Start rename_and_release after build and changelog
    Job_rename->>Job_rename: Download artifacts and rename to PCL2_CE_configuration_architecture.exe
    Job_rename->>Job_rename: Sign binaries with gpg
    Job_rename->>GHRelease: Upload binaries and signatures to draft release

    Job_rename->>WF_MRCU: Trigger mirrorchyan_uploading.yml with channel and arch

    Workflow_RP->>Job_publish: Start publish_draft after rename_and_release
    Job_publish->>GHRelease: Publish draft release with tag vVERSION
    Job_publish->>WF_MRCN: Trigger mirrorchyan_release_note.yml
Loading

File-Level Changes

Change Details Files
Unify beta/stable release publishing into a single manually-triggered workflow with explicit configuration and version inputs.
  • Rename release-beta_publish.yml to release-publish.yml and change workflow name to clarify its purpose.
  • Switch trigger from release: published to workflow_dispatch with configuration, version, and prerelease inputs.
  • Update matrix configuration values to use the inputs.configuration value instead of hardcoded Beta.
  • Adjust workflow permissions to allow writing contents and actions.
.github/workflows/release-publish.yml
Change changelog and release creation to operate on draft, versioned tags using inputs instead of the GitHub Release event.
  • Remove conditions depending on github.event.release.prerelease since the workflow is no longer release-event driven.
  • Generate the changelog with git-cliff and use softprops/action-gh-release@v3 to create or update a draft release.
  • Use v${{ inputs.version }} as tag name, set name to the release version, and pass through inputs.prerelease to mark prereleases.
.github/workflows/release-publish.yml
Upload signed binaries to the draft release and correctly route MirrorChyan upload based on configuration.
  • Continue downloading build artifacts, renaming them per configuration/architecture, and generating GPG signatures.
  • Update softprops/action-gh-release to v3 when uploading binaries and ensure they’re attached to the same draft release tag v${{ inputs.version }}.
  • Derive MirrorChyan channel (beta vs stable) from the inputs.configuration instead of hardcoding beta, and ensure GH_TOKEN is provided.
.github/workflows/release-publish.yml
Add a final step to publish the draft release after artifacts are attached and notify MirrorChyan of release notes.
  • Introduce a publish_draft job depending on rename/upload that uses softprops/action-gh-release@v3 to publish the draft with tag v${{ inputs.version }}.
  • Trigger the mirrorchyan_release_note.yml workflow after publishing, authenticated via GH_TOKEN.
  • Ensure publish happens only after all architectures have been processed by using a job-level dependency.
.github/workflows/release-publish.yml
Introduce a new workflow that automatically triggers the release workflow when PRs with properly formatted titles are merged.
  • Add release-trigger.yml that listens for pull_request closed events and filters to merged PRs.
  • Parse the PR title using Bash regex to detect release-stable: VERSION or beta-release: VERSION patterns with SemVer support and optional v prefix.
  • Map release type to Release vs Beta configuration and pass version, configuration, and prerelease to trigger release-publish.yml via the GitHub CLI.
.github/workflows/release-trigger.yml
Remove the separate stable release workflow in favor of the unified release pipeline.
  • Delete .github/workflows/release-stable_publish.yml as its responsibilities are now covered by release-publish.yml parameterization.
.github/workflows/release-stable_publish.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了 1 个问题,并给出了一些整体性的反馈:

  • rename_and_release 这个 job 中,shell 赋值语句 MRC_CHANNEL = "stable" 因为在 = 两侧有空格而无效,会导致语法错误;应该写成 MRC_CHANNEL="stable"(其他类似的赋值语句也需要相应修改)。
  • 新增的 release-trigger.yml workflow 中调用了 gh workflow run,但该 workflow 的 permissions 目前只授予了 contents: read;你很可能需要再添加 actions: write(如果需要的话,可能还要加 contents: write),这样 gh 命令才能成功触发另一个 workflow。
给 AI Agent 的提示
请根据以下代码评审意见进行修改:

## 整体评论
-`rename_and_release` 这个 job 中,shell 赋值语句 `MRC_CHANNEL = "stable"` 因为在 `=` 两侧有空格而无效,会导致语法错误;应该写成 `MRC_CHANNEL="stable"`(其他类似的赋值语句也需要相应修改)。
- 新增的 `release-trigger.yml` workflow 中调用了 `gh workflow run`,但该 workflow 的 `permissions` 目前只授予了 `contents: read`;你很可能需要再添加 `actions: write`(如果需要的话,可能还要加 `contents: write`),这样 `gh` 命令才能成功触发另一个 workflow。

## 单独评论

### 评论 1
<location path=".github/workflows/release-trigger.yml" line_range="3-12" />
<code_context>
-name: Publish (Beta)
+name: Release Beta (Actual)

 permissions:
-  contents: read
+  contents: write
</code_context>
<issue_to_address>
**issue (bug_risk):** 为了让 `gh workflow run` 成功执行,workflow 使用的 token 很可能需要 `actions: write` 权限。

这个 workflow 目前只设置了 `contents: write`,但 `gh workflow run` 需要 `GITHUB_TOKEN` 具备 `actions: write`(在某些配置下还需要 `workflow`)权限。请更新 `permissions` 配置块,至少包含:

```yaml
permissions:
  contents: write
  actions: write
```

否则 `gh workflow run` 调用很可能会因为权限不足而失败。
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • In the rename_and_release job, the shell assignment MRC_CHANNEL = "stable" is invalid due to the spaces around =, which will cause a syntax error; it should be MRC_CHANNEL="stable" (and similarly for any other assignments).
  • The new release-trigger.yml workflow calls gh workflow run, but the workflow’s permissions only grant contents: read; you likely need to add actions: write (and possibly contents: write if required) so the gh command can successfully trigger the other workflow.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the `rename_and_release` job, the shell assignment `MRC_CHANNEL = "stable"` is invalid due to the spaces around `=`, which will cause a syntax error; it should be `MRC_CHANNEL="stable"` (and similarly for any other assignments).
- The new `release-trigger.yml` workflow calls `gh workflow run`, but the workflow’s `permissions` only grant `contents: read`; you likely need to add `actions: write` (and possibly `contents: write` if required) so the `gh` command can successfully trigger the other workflow.

## Individual Comments

### Comment 1
<location path=".github/workflows/release-trigger.yml" line_range="3-12" />
<code_context>
-name: Publish (Beta)
+name: Release Beta (Actual)

 permissions:
-  contents: read
+  contents: write
</code_context>
<issue_to_address>
**issue (bug_risk):** The workflow token likely needs `actions: write` permission for `gh workflow run` to succeed.

This workflow currently only sets `contents: write`, but `gh workflow run` needs `actions: write` on `GITHUB_TOKEN` (and in some setups also `workflow`). Please update the permissions block to include at least:

```yaml
permissions:
  contents: write
  actions: write
```

Otherwise the `gh workflow run` call is likely to fail with insufficient permissions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread .github/workflows/release-trigger.yml
ruattd
ruattd previously approved these changes Apr 19, 2026
MoYuan-CN
MoYuan-CN previously approved these changes Apr 19, 2026
@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Apr 19, 2026
LinQingYuu
LinQingYuu previously approved these changes Apr 19, 2026
pynickle
pynickle previously approved these changes Apr 19, 2026
@tangge233 tangge233 dismissed stale reviews from pynickle, LinQingYuu, MoYuan-CN, and ruattd via 2eb6785 April 20, 2026 13:37
Add project_file and artifact_name_suffix inputs to the reusable
workflow, allowing the build matrix to compile both .csproj and .vbproj
targets. Artifact names now include a suffix to distinguish between
language variants.
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels Apr 28, 2026
@SALTWOOD
Copy link
Copy Markdown
Member

女娲,推错仓库了(

SALTWOOD
SALTWOOD previously approved these changes Apr 28, 2026
Copy link
Copy Markdown
Contributor Author

@tangge233 tangge233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SALTWOOD 修改不完全,这样 MRC 那边文件名匹配会有问题

@SALTWOOD
Copy link
Copy Markdown
Member

@SALTWOOD 修改不完全,这样 MRC 那边文件名匹配会有问题

已 revert(

Comment thread .github/workflows/release-publish.yml Outdated
matrix:
include:
- configuration: Beta
- configuration: ${{ inputs.configuration}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- configuration: ${{ inputs.configuration}}
- configuration: ${{ inputs.configuration }}

Comment thread .github/workflows/release-publish.yml Outdated
- configuration: ${{ inputs.configuration}}
architecture: x64
- configuration: Beta
- configuration: ${{ inputs.configuration}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- configuration: ${{ inputs.configuration}}
- configuration: ${{ inputs.configuration }}

@MoYuan-CN MoYuan-CN dismissed their stale review April 30, 2026 11:40

Resolved. As I don't have time to review the rest of this PR, I'm dismissing my self-review to keep the process better organized, rather than submitting an approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L PR 大小评估:大型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants