Skip to content

feat(windows): 增加原生服务安装包 - #493

Merged
tbphp merged 6 commits into
v2from
tbphp/windows-service-installer
Aug 29, 2026
Merged

feat(windows): 增加原生服务安装包#493
tbphp merged 6 commits into
v2from
tbphp/windows-service-installer

Conversation

@tbphp

@tbphp tbphp commented Aug 29, 2026

Copy link
Copy Markdown
Owner

关联 Issue / Related Issue

无 / None

变更内容 / Change Content

  • Bug 修复 / Bug fix
  • 新功能 / New feature
  • 其他改动 / Other changes
  • 保留现有 gpt-load-windows-amd64.exe 便携前台运行方式,新增 gpt-load-windows-setup.exe 安装包产物。
  • 基于 Windows SCM 增加原生服务安装、启动、停止、重启、状态和卸载命令;服务使用 LocalService 与独立 Service SID,并配置优雅停止、事件日志及失败恢复策略。
  • 使用 Inno Setup 安装同一核心 EXE,自动注册并启动服务,创建桌面和开始菜单管理页面快捷方式,首次安装显示管理密钥;卸载保留 %ProgramData%\GPT-Load\data
  • 收紧服务配置、数据和密钥文件 ACL,仅允许 NT SERVICE\gpt-load 与 Administrators 访问。
  • 扩展 Windows CI 与 Release 流程,覆盖真实服务生命周期、安装器构建、校验和、安装/健康检查/卸载 smoke,并更新中英文与日文 README。

兼容性:无数据迁移;现有便携 Windows EXE 的无参数前台运行行为和产物名称保持不变。

验证:

  • make check
  • Windows amd64 交叉 go vet、二进制构建及 Windows 测试二进制编译
  • PowerShell Parser 语法检查
  • actionlint v1.7.12
  • git diff --check

未验证范围:本地非 Windows 环境未执行真实 SCM/UAC/Inno 安装流程;已加入 windows-2025 PR/Release CI 门禁,远端结果待运行。

自查清单 / Checklist

  • 我已运行 make check,或在说明中写明无法运行的原因和未验证范围。 / I ran make check, or documented why it could not run and what remains unverified.
  • 本 PR 范围聚焦,未包含无关改动。 / This PR is focused and contains no unrelated changes.
  • 我已更新必要的公开文档或发布说明。 / I updated any required public documentation or release notes.
  • 我已确认提交、日志和测试数据不包含敏感信息。 / I confirmed that commits, logs, and fixtures contain no sensitive data.
  • 如适用,我已说明兼容性或数据迁移影响。 / Where applicable, I documented compatibility or data-migration impact.

Summary by CodeRabbit

  • 新功能

    • 新增 Windows 桌面安装程序,支持服务安装、自动启动、快捷方式、覆盖更新和卸载。
    • 支持 Windows 服务安装、启动、停止、重启、状态查询及卸载。
    • 安装失败时自动回滚;卸载后保留用户数据。
    • 安装程序支持简体中文,并可显示管理密钥。
    • 发布包同时提供便携版与安装版 Windows 产物。
  • 安全性

    • 强化 Windows 服务配置、数据目录和密钥文件的访问权限。
  • 文档

    • 更新中、英、日文 Windows 安装、服务管理及数据目录说明。

Copilot AI lite review requested due to automatic review settings August 29, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T15:16:42.824327Z 12ddfee New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: a9124acb-f10a-4954-9998-2fc8a6ef9749

📥 Commits

Reviewing files that changed from the base of the PR and between b1113ae and 12ddfee.

📒 Files selected for processing (3)
  • .github/scripts/release-windows-installer-smoke.ps1
  • internal/webui/windows_installer_contract_test.go
  • packaging/windows/gpt-load.iss

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

本次变更新增 Windows 服务命令、服务运行时和停止流程。新增服务专用 ACL,覆盖目录和密钥文件。新增 Inno Setup 安装器、覆盖安装、卸载和健康检查流程。CI 和发布流程加入 Windows 安装包构建、校验和冒烟测试。英文、中文和日文文档补充了 Windows 安装器和数据目录说明。

Merge Risk: 🔵 Low · up to 12ddf

This PR adds Windows service installation and installer upgrade/rollback behavior. A failed service update or interrupted installation could leave partially restored service or installation state, so merge is reasonable with explicit owner awareness and follow-up on atomic recovery.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 1.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 104 functions across 23 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题简洁明确,准确概括了新增 Windows 原生服务安装包这一主要变更。
Description check ✅ Passed 描述完整说明了变更内容、兼容性、验证结果和未验证范围。关联 Issue 明确标记为无,功能类型和自查清单也已填写。
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 1.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 104 functions across 23 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch tbphp/windows-service-installer

Warning

Some tools did not complete. Review the errors below.

🔧 golangci-lint (2.12.2)

Error: can't load config: the Go language version (go1.26) used to build golangci-lint is lower than the targeted Go version (1.27.0)
The command is terminated due to an error: can't load config: the Go language version (go1.26) used to build golangci-lint is lower than the targeted Go version (1.27.0)


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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 845a3f09f0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread service_manager_windows.go Outdated
Comment thread service_manager_windows.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Note

Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.

🟡 Other comments (1)
main_test.go-59-64 (1)

59-64: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

移除对未安装服务状态的隐式假设。

在 Windows 主机已安装 gpt-load 服务时,Line 57 的 service status 会返回 0。Line 59 会使测试失败。此测试应按 runtime.GOOS 使用平台期望,或避免调用真实 SCM 状态查询。


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: 6daca098-580a-490a-8b5b-b9b054b2790b

📥 Commits

Reviewing files that changed from the base of the PR and between 515c958 and 845a3f0.

📒 Files selected for processing (29)
  • .github/release-assets.txt
  • .github/scripts/ci-windows-service-smoke.ps1
  • .github/scripts/release-windows-installer-smoke.ps1
  • .github/workflows/ci.yml
  • .github/workflows/release.yml
  • README.md
  • README_CN.md
  • README_JP.md
  • internal/platform/securefile/managed_windows.go
  • internal/platform/securefile/managed_windows_test.go
  • internal/platform/securefile/securefile_windows.go
  • internal/platform/securefile/securefile_windows_test.go
  • internal/platform/securefile/service_acl_windows.go
  • internal/platform/securefile/windows_acl_policy.go
  • internal/platform/securefile/windows_acl_policy_test.go
  • internal/webui/windows_installer_contract_test.go
  • internal/webui/workflow_test.go
  • main.go
  • main_test.go
  • packaging/windows/gpt-load.iss
  • runtime.go
  • runtime_test.go
  • service_cli.go
  • service_cli_test.go
  • service_manager_windows.go
  • service_manager_windows_test.go
  • service_nonwindows.go
  • service_windows.go
  • service_windows_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Comment thread .github/scripts/release-windows-installer-smoke.ps1 Outdated
Comment thread service_manager_windows.go Outdated
Comment thread service_windows.go
@tbphp tbphp self-assigned this Aug 29, 2026
@tbphp tbphp added enhancement New feature or request dependencies Pull requests that update a dependency file labels Aug 29, 2026
@tbphp tbphp added this to the v2.0.0 milestone Aug 29, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c77849369e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread service_manager_windows.go
Comment thread packaging/windows/gpt-load.iss

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packaging/windows/gpt-load.iss (1)

35-35: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

安装包编译失败:ChineseSimplified.isl 不随 Inno Setup 分发。

CI 报错显示编译器无法打开 C:\Program Files (x86)\Inno Setup 6\Languages\ChineseSimplified.isl,退出码 2。简体中文属于非官方翻译,官方安装包只提供 Default.isl 与官方语言文件。上游 issue 讨论也给出同样结论:该文件不存在于 Inno Setup 6 的 Languages 目录,需要自行提供该文件不在 Languages 目录内,需作为变通方案加入仓库,编译日志显示 "Couldn't open include file",因为中文翻译尚非官方翻译。

因此 build-windows-setup 作业以及依赖它的 package-checksumspublication-preflight 门禁在任何干净 runner 上都会失败,gpt-load-windows-setup.exe 无法产出。

请选择一种修复方式:把 ChineseSimplified.isl 随包放入 packaging/windows/ 并改用相对路径引用;或在工作流中把该文件复制到 Inno Setup 的 Languages 目录后再编译。

🔧 方案 A:随仓库提供语言文件
-Name: "chinesesimplified"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
+Name: "chinesesimplified"; MessagesFile: "ChineseSimplified.isl"

同时将 ChineseSimplified.isl(UTF-8 with BOM)添加到 packaging/windows/ 目录。

🔧 方案 B:在工作流中安装语言文件
# 在 .github/workflows/release.yml 与 ci.yml 的 ISCC 步骤之前执行
$languages = "C:\Program Files (x86)\Inno Setup 6\Languages"
Invoke-WebRequest `
  -Uri "https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/ChineseSimplified.isl" `
  -OutFile (Join-Path $languages "ChineseSimplified.isl")

Source: Pipeline failures


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: QUIET

Plan: Pro Plus

Run ID: 68de37db-77ad-40a9-8409-82f61b27e549

📥 Commits

Reviewing files that changed from the base of the PR and between 845a3f0 and c778493.

📒 Files selected for processing (14)
  • .github/scripts/ci-windows-service-smoke.ps1
  • .github/scripts/release-windows-installer-smoke.ps1
  • .github/workflows/ci.yml
  • internal/webui/windows_installer_contract_test.go
  • main_test.go
  • packaging/windows/gpt-load.iss
  • service_cli.go
  • service_cli_test.go
  • service_manager_windows.go
  • service_manager_windows_test.go
  • service_wait.go
  • service_wait_test.go
  • service_windows.go
  • service_windows_test.go

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1113ae978

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packaging/windows/gpt-load.iss

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12ddfeec61

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +279 to +281
FreshInstallCleanupEligible :=
(not DirExists(ExpandConstant('{app}'))) and
(not RegKeyExists(HKLM64, WindowsUninstallKey));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Clean up failed reinstalls with an existing app directory

When reinstalling after an uninstall or earlier failure left {app} behind but no binary, service, or uninstall registration, this condition disables fresh-install cleanup solely because the directory exists. If service installation or startup then fails, RestorePreviousInstallation has nothing to restore and skips CleanupFailedFreshInstallation, leaving the newly copied executable, uninstaller, shortcuts, and uninstall key despite Setup returning exit code 10. The fresh evidence after the prior report is that the newly added cleanup remains gated by not DirExists('{app}'); track and remove artifacts created by this run while preserving pre-existing contents.

Useful? React with 👍 / 👎.

@tbphp
tbphp merged commit 5c16ed8 into v2 Aug 29, 2026
7 checks passed
@tbphp
tbphp deleted the tbphp/windows-service-installer branch August 29, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants