Files
gdt-tool/docs/auto-update-config.md
2025-11-05 14:46:49 +08:00

62 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 自动更新配置
本项目使用 `electron-updater` 库实现自动更新功能,支持从私有 GitHub 仓库获取更新。
## 私有仓库配置
要启用私有仓库的自动更新功能,请按以下步骤操作:
### 1. 创建 GitHub Personal Access Token
1. 访问 GitHub 设置页面 (https://github.com/settings/tokens)
2. 点击 "Generate new token" (Classic tokens)
3. 选择适当的权限(至少需要 `repo` 权限来访问私有仓库)
4. 生成并复制 token
### 2. 配置环境变量
在项目根目录创建 `.env` 文件:
```bash
cp .env.example .env
```
编辑 `.env` 文件,添加你的 GitHub token:
```env
GH_TOKEN=your_github_personal_access_token
```
### 3. 构建配置
构建配置文件 `buildAssets/builder/config.js` 已经配置为使用环境变量中的 token:
```javascript
publish: [
{
provider: 'github',
owner: 'your_username',
repo: 'your_repository',
releaseType: 'release',
token: process.env.GH_TOKEN || '' // 从环境变量获取
}
];
```
## 发布更新
1. 更新 `package.json` 中的版本号
2. 提交更改并推送至 GitHub
3. 创建新的 GitHub Release
4. 运行构建命令:
```bash
pnpm build:all
```
## 注意事项
- 请确保 GitHub token 权限最小化,仅授予必要的访问权限
- 对于分发给公众的私有应用,用户需要有访问仓库的权限才能下载更新
- 在 CI/CD 环境中,确保在环境变量中配置了相应的 token