Skip to content

refactor: 发布复用测试构建产物,省一次全量构建 - #163

Merged
LevelDownRefine merged 1 commit into
mainfrom
refactor/release-reuse-build-artifacts
Oct 7, 2026
Merged

LevelDownRefine merged 1 commit into
mainfrom
refactor/release-reuse-build-artifacts

Conversation

@LevelDownRefine

@LevelDownRefine LevelDownRefine commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

背景

同一个 commit 被完整构建两遍:Build EXE & Run Exe Tests(push main/PR)与 Release Build(push v* tag)各自跑一遍 PyInstaller + cargo(≈8–11 min)。而 tag 指向的正是 main 上那个已被构建过的 commit。

改动

build-exe.yml

  • 顶层加 SOURCE_DATE_EPOCH / PYTHONHASHSEED(与 release.yml 完全一致 ⇒ 两个 workflow 产物字节相同);PYTHONUTF8 提到顶层。
  • Rust job 上传产物由 ZIP 改为未打包目录 deploy/dist/rust/OneDragon-Helper(发布流程要重盖版本戳后再归档)。

release.yml

  • 复用路径:按 $GITHUB_SHA 定位同 commit 上成功的 build-exe run → gh run download 两个产物 → release_package.py prepare 重盖版本戳 → archive → create release。
  • 找不到 / 形态不符 → 回退原全量构建。
  • permissions 补 actions: read(跨 workflow 下载产物)。

验证

  • 实跑 gh run list --workflow=build-exe.yml --event push --commit <sha> --status success 能命中目标 run,产物名一致。
  • 实拉现存 Qt 产物确认上传层级:单目录上传 ⇒ 产物根 = 目录内容,不多包一层 ⇒ --dir 回填层级正确。

自审(CodeRabbit 标准)

严重度 问题 处置
P1 shell: bash 带 -e:gh run list 失败会中断整个 job,到不了 fallback 加 || run_id=""
P1 shell: pwsh 只取最后一条命令退出码:两条 prepare/archive 首条失败被掩盖 ⇒ 可能发布带 dev 版本戳的包 两个步骤改 shell: bash
P2 复用产物无形态校验:产物过期/形态不符时 gh run download 仍成功,prepare 才炸且不回退 加 version.json 存在性守卫 → 走 fallback

已知限制

  • 产物保留 7 天;tag 晚于 main 提交 7 天、或紧接 merge 后打(build-exe 未完成)⇒ 复用失效,走 fallback(能发,只是慢)。
  • --workflow=build-exe.yml 硬编码:改名后静默退化为全量构建。
  • 复用路径仍照跑 uv sync + submodule checkout(≈1 min 空转,fallback 需要)。

注意

  • OneDragon-Helper-Rust-windows 产物形态由 ZIP 变目录(7 天保留的 CI 调试产物,唯一消费者是发布流程)。

Summary by CodeRabbit

  • Chores
    • Tagged releases now include downloadable GUI and Rust packages with checksum files.
    • Successful builds from the same commit may be reused for a release; if those builds are unavailable or incomplete, the packages are rebuilt and tested before publication.
    • Manual release runs continue to skip publication.

同一 commit 被 build-exe 与 release 各完整构建一遍(≈8-11min)。release 改为按 commit
复用 build-exe 产物,只重盖版本戳后归档;无可用产物则回退全量构建。

- build-exe: 顶层加可复现构建常量(与 release 一致);Rust 产物由 zip 改未打包目录
- release: 定位同 commit run → gh run download → prepare 重盖版本戳 → archive;补 actions: read
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a9dfcfb-428e-4460-9e77-a77815abd131
📥 Commits

Reviewing files that changed from the base of the PR and between 816b671 and 67071dc.

📒 Files selected for processing (2)
  • .github/workflows/build-exe.yml
  • .github/workflows/release.yml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The build workflow sets shared UTF-8 and deterministic-build values and uploads the checked Rust package directory. The release workflow looks for build artifacts from the same commit, reuses them when valid, or builds packages as a fallback. Tag releases now include GUI and Rust archives and checksums.

Changes

Build and Release Artifact Flow

Layer / File(s) Summary
Prepare build artifacts
.github/workflows/build-exe.yml
The workflow sets shared environment values for all jobs and uploads the checked Rust package directory. The headless and EXE jobs inherit the shared PYTHONUTF8 value.
Find and validate reusable artifacts
.github/workflows/release.yml
The release workflow searches for a successful build-exe.yml run on the current commit, fetches its GUI and Rust artifacts, and checks for version.json in both packages.
Build or publish release packages
.github/workflows/release.yml
The workflow re-stamps fetched packages or builds and tests packages when artifact reuse fails. It archives both packages and attaches both ZIPs and checksum files to tag releases.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 67071

The release workflow now reuses build artifacts from the same commit and falls back to a full build when they are unavailable. No merge-blocking issue was found.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了发布流程优先复用测试构建产物并减少一次全量构建的主要变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LevelDownRefine
LevelDownRefine merged commit aa4ad0a into main Oct 7, 2026
5 checks passed
@LevelDownRefine
LevelDownRefine deleted the refactor/release-reuse-build-artifacts branch October 7, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant