diff --git a/.github/workflows/build-runtime.yml b/.github/workflows/build-runtime.yml index 7721a94..f15d08c 100644 --- a/.github/workflows/build-runtime.yml +++ b/.github/workflows/build-runtime.yml @@ -1,12 +1,19 @@ name: Build Portable Runtime (Alpha) -# Daily: build the newest runtime fork commit with the dependency patch queue -# (patches/series.txt) and publish it as a GitHub prerelease = the alpha -# channel (portable-runtime-spec.md section 6). Never publishes stable: -# promotion needs a real-host smoke test and a person (AGENTS.md rule 6). +# The runtime fork calls this workflow to build and publish previews. +# A manual run in Reims-Go builds artifacts for verification. on: - schedule: - - cron: "23 3 * * *" # 03:23 UTC daily; skipped when upstream has not moved + workflow_call: + inputs: + upstream_commit: + type: string + default: "" + publish: + type: boolean + default: false + rebuild: + type: boolean + default: false workflow_dispatch: inputs: upstream_commit: @@ -14,17 +21,16 @@ on: required: false default: "" publish: - description: "Publish as an alpha prerelease (never stable)" + description: "Publish a preview when run in the runtime fork" type: boolean - default: true + default: false rebuild: description: "Build a new patch revision (runtime--pN) even if this upstream commit is already released" type: boolean default: false permissions: - contents: write - issues: write + contents: read concurrency: group: build-runtime @@ -33,7 +39,6 @@ concurrency: env: UPSTREAM_URL: https://github.com/yxc0915/reims-vgpu.git UPSTREAM_BRANCH: codex/intel-vm-suspend - KEEP_ALPHAS: "7" # unpromoted alpha prereleases kept; older ones are deleted jobs: resolve: @@ -92,14 +97,14 @@ jobs: if: needs.resolve.outputs.skip != 'true' runs-on: windows-latest timeout-minutes: 150 - outputs: - short: ${{ steps.patches.outputs.short }} - release_id: ${{ steps.patches.outputs.release_id }} - applied: ${{ steps.patches.outputs.applied }} - merged: ${{ steps.patches.outputs.merged }} - conflict: ${{ steps.patches.outputs.conflict }} + permissions: + contents: write steps: - uses: actions/checkout@v4 + with: + repository: ${{ job.workflow_repository }} + ref: ${{ job.workflow_sha }} + persist-credentials: false - name: Setup MSYS2 CLANG64 id: msys2 @@ -161,8 +166,6 @@ jobs: if ($LASTEXITCODE) { throw 'metal2vulkan checkout failed' } $short = (git -C $work rev-parse --short=7 HEAD).Trim() $releaseId = "$short${{ needs.resolve.outputs.suffix }}" - "short=$short" >> $env:GITHUB_OUTPUT - "release_id=$releaseId" >> $env:GITHUB_OUTPUT # Applies what applies, skips what upstream already has, stops on a # conflict without touching the patch (AGENTS.md rule 4). @@ -173,9 +176,7 @@ jobs: } finally { if (Test-Path $resultFile) { $r = Get-Content -Raw $resultFile | ConvertFrom-Json - "applied=$(@($r.applied) -join ',')" >> $env:GITHUB_OUTPUT "merged=$(@($r.merged) -join ',')" >> $env:GITHUB_OUTPUT - "conflict=$($r.conflict)" >> $env:GITHUB_OUTPUT "APPLIED_PATCHES=$(@($r.applied) -join ',')" >> $env:GITHUB_ENV } } @@ -256,7 +257,7 @@ jobs: retention-days: 14 - name: Publish alpha prerelease (never stable) - if: github.event_name == 'schedule' || inputs.publish + if: github.repository == 'yxc0915/reims-vgpu' && inputs.publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} MERGED: ${{ steps.patches.outputs.merged }} @@ -283,56 +284,5 @@ jobs: Build: $env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID "@ - gh release create "runtime-$c" @assets --prerelease --title "Portable Runtime runtime-$c (alpha)" --notes $notes + gh release create "runtime-$c" @assets --repo $env:GITHUB_REPOSITORY --target '${{ needs.resolve.outputs.commit }}' --prerelease --title "Portable Runtime runtime-$c (alpha)" --notes $notes if ($LASTEXITCODE) { throw "gh release create failed ($LASTEXITCODE)" } - - - name: Prune old alpha prereleases - if: github.event_name == 'schedule' || inputs.publish - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: pwsh - run: | - # Only unpromoted runtime prereleases; stable releases are never touched. - $alphas = gh release list -R $env:GITHUB_REPOSITORY --limit 1000 --json tagName,isPrerelease,isDraft,createdAt | ConvertFrom-Json | - Where-Object { $_.tagName -like 'runtime-*' -and $_.isPrerelease -and -not $_.isDraft } | - Sort-Object createdAt -Descending - $alphas | Select-Object -Skip ([int]$env:KEEP_ALPHAS) | ForEach-Object { - Write-Host "Deleting old alpha $($_.tagName)" - gh release delete $_.tagName -R $env:GITHUB_REPOSITORY --yes --cleanup-tag - } - - report: - needs: [resolve, build] - if: always() && needs.resolve.outputs.skip != 'true' && (failure() || needs.build.outputs.merged != '') - runs-on: ubuntu-latest - steps: - - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RESULT: ${{ needs.build.result }} - COMMIT: ${{ needs.resolve.outputs.commit }} - CONFLICT: ${{ needs.build.outputs.conflict }} - MERGED: ${{ needs.build.outputs.merged }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - run: | - set -euo pipefail - # One open issue per kind; later runs add a comment instead of a new issue. - file_issue() { - local title="$1" body="$2" n - n="$(gh issue list -R "$GITHUB_REPOSITORY" --state open --search "in:title \"$title\"" --json number,title -q ".[] | select(.title == \"$title\") | .number" | head -n1)" - if [ -n "$n" ]; then - gh issue comment "$n" -R "$GITHUB_REPOSITORY" --body "$body" - else - gh issue create -R "$GITHUB_REPOSITORY" --title "$title" --body "$body" - fi - } - if [ "$RESULT" != "success" ]; then - if [ -n "$CONFLICT" ]; then - why="Patch \`$CONFLICT\` neither applies to upstream \`$COMMIT\` nor is already there. Per AGENTS.md rule 4 the patch was not edited; a person decides how to rebase or retire it." - else - why="The build, packaging or alpha gate failed for upstream \`$COMMIT\`; see the log." - fi - file_issue "Runtime alpha build failed" "$why"$'\n\n'"Run: $RUN_URL"$'\n\n'"No alpha was published." - fi - if [ -n "$MERGED" ]; then - file_issue "Patch queue: patches already upstream" "Upstream \`$COMMIT\` already contains: \`$MERGED\`. They were skipped. Record the merge commit in portable-runtime-spec.md section 5, then remove them from patches/ and patches/series.txt."$'\n\n'"Run: $RUN_URL" - fi diff --git a/AGENTS.md b/AGENTS.md index 1047b63..5a2953c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,7 +48,7 @@ ## 事实核验与安全规则 1. **上游行为以一手源码为准**:引用 `reims-ctl` / `reims-vgpu` 行为时核对对应上游 commit 与 `文件:行号`;未实测项显式标注「待验证」。 -2. **人工确认红线**:UAC 提权启用 WHPX、重启 Windows、macOS 图形安装向导、向上游提交 PR、将运行时升级为 `stable` 正式发布,均须由人确认触发。自动化例外:[`.github/workflows/build-runtime.yml`](.github/workflows/build-runtime.yml) 每日从上游构建,通过 `alpha` 准入检查后自动发布为 GitHub 预发布(`alpha` 通道),并自动清理较旧的未升级 `alpha` 预发布。 +2. **人工确认红线**:UAC 提权启用 WHPX、重启 Windows、macOS 图形安装向导、向上游提交 PR、将运行时升级为 `stable` 正式发布,均须由人确认触发。自动化例外:Reims vGPU fork 的 Preview 工作流每天构建,通过 `alpha` 准入检查后在运行时仓库发布 GitHub 预发布。 3. **敏感与专有内容零入库**:严禁提交 SMC OSK、SMBIOS 真实序列号、MAC 地址、任何 Apple IPSW / BaseSystem / 解密固件或闭源二进制。 4. **运行时源码与依赖补丁**:Reims vGPU 和 QEMU 的源码修改由各自运行时 fork 维护。客户端构建使用 [`patches/series.txt`](patches/series.txt) 应用其余依赖补丁。源码入口、顺序与状态见 [`patches/README.md`](patches/README.md)。补丁打不上就停下报告,不要自动改写补丁。 5. **运行时包如实声明来源**:`manifest.json` 必须写清上游各仓库 commit 与实际应用的全部补丁;带补丁的包不得宣称为纯上游构建。 diff --git a/docs/portable-runtime-spec.md b/docs/portable-runtime-spec.md index 1cd4a3b..ed3e8cc 100644 --- a/docs/portable-runtime-spec.md +++ b/docs/portable-runtime-spec.md @@ -84,17 +84,17 @@ reims-runtime-/ 打包前脚本会核对构建目录的 `git diff` 是否与声明的补丁逐字节一致;存在未声明修改或补丁不匹配时立即停止。 ### 3.2 每日 CI 构建 -[`.github/workflows/build-runtime.yml`](../.github/workflows/build-runtime.yml) 每日定时(也支持手动指定 commit)在 `windows-latest`(MSYS2 CLANG64)执行: +Reims vGPU fork 的 [Preview 工作流](https://github.com/yxc0915/reims-vgpu/blob/master/.github/workflows/runtime-preview.yml) 每日调用 [Reims-Go 的运行时构建工作流](../.github/workflows/build-runtime.yml),也支持手动指定提交。在 `windows-latest`(MSYS2 CLANG64)执行以下步骤。 1. 读取 Reims vGPU fork 的运行时分支,并检出其中固定的 QEMU fork 提交。若该 Reims vGPU 提交已有运行时 Release,则跳过。 2. 按 [`patches/series.txt`](../patches/series.txt) 顺序为固定的依赖版本应用补丁。已合入上游的补丁会跳过并报告,遇到冲突时中止构建。 3. 执行上游 `scripts/install-ctl.sh --yes` 编译,调用 `scripts/pack-runtime.ps1 -Channel alpha` 打包。 4. 运行 [`scripts/check-runtime-alpha.ps1`](../scripts/check-runtime-alpha.ps1) 校验附件哈希、许可证、挂起能力声明,以及在不含 MSYS2 的 `PATH` 下验证 vGPU 设备枚举、CLI 版本和 `qcow2` 创建读取。 -5. 通过后发布为 GitHub 预发布(`alpha`),并自动清理超过保留上限(最近 7 个)的旧 `alpha` 预发布;正式版不受影响。 +5. 通过后在 Reims vGPU fork 的 Releases 发布 Preview,标记为 GitHub 预发布(`alpha`)。从 Reims-Go 仓库发起的手动构建提供 CI 产物供验证。 > **CI 边界**:GitHub 托管的 Windows Server runner 不提供 WHPX,也无法复现 Windows 10 兼容性问题。CI 只验证可编译与控制面基本可用,实际能否启动 macOS 桌面必须经过第 5 节的真机冒烟。 ### 3.3 客户端下载与安装 -`internal/runtime` 默认从 GitHub Releases(tag `runtime-`)拉取,沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。 +`internal/runtime` 从 GitHub Releases 查找 `runtime-`。正式运行时来自 `Nwflower/Reims-Go`,开启内核 Alpha 后同时列出 `yxc0915/reims-vgpu` 的 Preview。下载沿用环境变量与 Windows 系统代理,支持 HTTP `Range` 续传、强制 `SHA256SUMS.txt` 校验、临时目录原子解压与多版本切换。 --- @@ -118,7 +118,7 @@ Reims vGPU 和 QEMU 的修改由各自的运行时 fork 维护。客户端仓库 | **`stable`** | 正式发布(Release) | 从 `alpha` 晋升:在真实 Windows 10/11 宿主运行 [`scripts/smoke-runtime.ps1`](../scripts/smoke-runtime.ps1),验证纯净目录 `doctor`、启动至 macOS 桌面、截屏与正常关机,经人工确认后晋升 | - 客户端默认仅获取 `stable` 通道;`alpha` 需用户在界面开启「接收 Alpha 版」或在 CLI 传入 `--alpha`。 -- 晋升 `stable` 不重新打包,仅将既有 GitHub 预发布转为正式发布,确保用户下载的二进制与冒烟验证的资产完全一致(因此包内 `manifest.json` 的构建通道字段保持 `alpha`,客户端以 Release 状态区分通道)。 +- 晋升 `stable` 时,在 `Nwflower/Reims-Go` 正式 Release 分发已通过冒烟的原始资产及同一份校验清单。客户端以 Release 状态区分通道,包内 `manifest.json` 保留构建时的 `alpha` 标记。 --- diff --git a/internal/runtime/remote.go b/internal/runtime/remote.go index 144004e..964add3 100644 --- a/internal/runtime/remote.go +++ b/internal/runtime/remote.go @@ -1,8 +1,7 @@ package runtime -// Online install: runtime packages are GitHub Release assets of the reims-go -// repository (decided 2026-11-28, AGENTS.md). A runtime release is tagged -// "runtime-" and carries: +// Online install lists stable packages from Reims-Go and alpha packages from +// the Reims vGPU fork. A runtime release is tagged "runtime-" and carries: // // reims-runtime-win-x64-.tar.zst // reims-runtime-src-.tar.zst (matching sources, spec §7) @@ -34,11 +33,12 @@ import ( ) const ( - DefaultReleasesRepo = "Nwflower/reims-go" - DefaultAPIBase = "https://api.github.com" - DefaultWebBase = "https://github.com" - runtimeTagPrefix = "runtime-" - sumsAsset = fetch.SumsAsset + DefaultReleasesRepo = "Nwflower/reims-go" + DefaultAlphaReleasesRepo = "yxc0915/reims-vgpu" + DefaultAPIBase = "https://api.github.com" + DefaultWebBase = "https://github.com" + runtimeTagPrefix = "runtime-" + sumsAsset = fetch.SumsAsset ) var errRateLimited = errors.New("GitHub API rate limit reached") @@ -67,27 +67,31 @@ func NormalizeChannel(s string) string { // app releases and (until pruned) daily alpha runtimes. const maxReleasePages = 10 -// Source is where runtime releases are listed. REIMS_GO_RELEASES_REPO overrides -// the repository (for forks and testing). +// Source lists runtime releases. If AlphaRepo is set, it supplies the previews +// and Repo supplies the stable releases. REIMS_GO_RELEASES_REPO uses one repo +// for both channels (for forks and testing). type Source struct { - APIBase string - WebBase string - Repo string - Client *http.Client + APIBase string + WebBase string + Repo string + AlphaRepo string + Client *http.Client } // DefaultSource returns the default GitHub runtime source. func DefaultSource() Source { - repo := os.Getenv("REIMS_GO_RELEASES_REPO") - if repo == "" { - repo = DefaultReleasesRepo + s := Source{ + APIBase: DefaultAPIBase, + WebBase: DefaultWebBase, + Repo: DefaultReleasesRepo, + AlphaRepo: DefaultAlphaReleasesRepo, + Client: netproxy.NewClient(), } - return Source{ - APIBase: DefaultAPIBase, - WebBase: DefaultWebBase, - Repo: repo, - Client: netproxy.NewClient(), + if repo := os.Getenv("REIMS_GO_RELEASES_REPO"); repo != "" { + s.Repo = repo + s.AlphaRepo = "" } + return s } // Remote is a runtime package published as a release. @@ -156,6 +160,28 @@ func (s Source) webBase() string { // ListRemote lists published runtime packages, newest first. Alpha runtimes // are included only when includeAlpha is set. func (s Source) ListRemote(ctx context.Context, includeAlpha bool) ([]Remote, error) { + if !includeAlpha || s.AlphaRepo == "" { + return s.listRemote(ctx, includeAlpha) + } + stable, err := s.listRemote(ctx, false) + if err != nil { + return nil, err + } + s.Repo = s.AlphaRepo + previews, err := s.listRemote(ctx, true) + if err != nil { + return nil, err + } + for _, r := range previews { + if r.Channel == ChannelAlpha { + stable = append(stable, r) + } + } + sortRemotesNewestFirst(stable) + return stable, nil +} + +func (s Source) listRemote(ctx context.Context, includeAlpha bool) ([]Remote, error) { base := strings.TrimRight(s.APIBase, "/") url := fmt.Sprintf("%s/repos/%s/releases?per_page=100", base, s.Repo) var rels []ghRelease diff --git a/internal/runtime/remote_test.go b/internal/runtime/remote_test.go index 922fd74..69fe7ff 100644 --- a/internal/runtime/remote_test.go +++ b/internal/runtime/remote_test.go @@ -5,12 +5,14 @@ import ( "context" "crypto/sha256" "encoding/hex" + "encoding/json" "fmt" "net/http" "net/http/httptest" "os" "path/filepath" "strings" + "sync/atomic" "testing" "time" ) @@ -93,6 +95,57 @@ func TestListRemoteFiltersChannelsAndIncompleteReleases(t *testing.T) { } } +func TestDefaultSourceListsPreviewsFromRuntimeFork(t *testing.T) { + t.Setenv("REIMS_GO_RELEASES_REPO", "") + release := func(commit, date string, alpha bool) ghRelease { + return ghRelease{ + TagName: "runtime-" + commit, PublishedAt: date, Prerelease: alpha, + Assets: []ghAsset{ + {Name: "reims-runtime-win-x64-" + commit + ".tar.zst", URL: "archive"}, + {Name: "reims-runtime-src-" + commit + ".tar.zst", URL: "source"}, + {Name: sumsAsset, URL: "sums"}, + }, + } + } + var previewRequests atomic.Int32 + mux := http.NewServeMux() + mux.HandleFunc("/repos/"+DefaultReleasesRepo+"/releases", func(w http.ResponseWriter, _ *http.Request) { + _ = json.NewEncoder(w).Encode([]ghRelease{ + release("official-stable", "2026-11-30T00:00:00Z", false), + release("old-alpha", "2026-11-30T12:00:00Z", true), + }) + }) + mux.HandleFunc("/repos/"+DefaultAlphaReleasesRepo+"/releases", func(w http.ResponseWriter, _ *http.Request) { + previewRequests.Add(1) + _ = json.NewEncoder(w).Encode([]ghRelease{ + release("fork-preview", "2026-12-01T00:00:00Z", true), + release("fork-stable", "2026-12-01T01:00:00Z", false), + }) + }) + srv := httptest.NewServer(mux) + defer srv.Close() + src := DefaultSource() + src.APIBase, src.Client = srv.URL, srv.Client() + + stable, err := src.ListRemote(context.Background(), false) + if err != nil || len(stable) != 1 || stable[0].Commit != "official-stable" || previewRequests.Load() != 0 { + t.Fatalf("stable list = %+v, %v, preview requests = %d", stable, err, previewRequests.Load()) + } + all, err := src.ListRemote(context.Background(), true) + if err != nil || len(all) != 2 || all[0].Commit != "fork-preview" || all[0].Channel != ChannelAlpha || + all[1].Commit != "official-stable" || previewRequests.Load() != 1 { + t.Fatalf("alpha list = %+v, %v, preview requests = %d", all, err, previewRequests.Load()) + } + + t.Setenv("REIMS_GO_RELEASES_REPO", DefaultReleasesRepo) + override := DefaultSource() + override.APIBase, override.Client = srv.URL, srv.Client() + all, err = override.ListRemote(context.Background(), true) + if err != nil || len(all) != 2 || all[0].Commit != "old-alpha" || previewRequests.Load() != 1 { + t.Fatalf("override list = %+v, %v, preview requests = %d", all, err, previewRequests.Load()) + } +} + func TestDownloadResumesAndVerifies(t *testing.T) { g := newFakeGitHub(t) src := g.source() diff --git a/patches/README.md b/patches/README.md index cc09515..c6710fa 100644 --- a/patches/README.md +++ b/patches/README.md @@ -40,8 +40,8 @@ Reims vGPU 分支通过 `vendor/qemu` 固定 QEMU 提交,并在 `reims-go-runt ## 补丁退役检查表 -当上游合入等价修复(每日构建会自动跳过该补丁并开 Issue 提醒)后,按以下步骤清理: +每日构建会跳过已合入的等价补丁,并在日志中报告。确认后按以下步骤清理。 1. 删除 `patches/` 下对应的 `.patch` 文件,并同步更新 [`series.txt`](series.txt) 与本文件。 -2. 等待次日定时构建或手动触发 [`.github/workflows/build-runtime.yml`](../.github/workflows/build-runtime.yml) 产出新的 `alpha` 运行时。 +2. 等待下一次定时构建,或在 Reims vGPU fork 手动触发 [Preview 工作流](https://github.com/yxc0915/reims-vgpu/actions/workflows/runtime-preview.yml)。 3. 在真实宿主运行 [`scripts/smoke-runtime.ps1`](../scripts/smoke-runtime.ps1) 完成冒烟并人工确认后,将对应 Release 升级为 `stable`。