mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-13 19:20:04 +00:00
959c210e86
* chore: stable updater * ✨ feat: add local update testing scripts and configuration - Introduced scripts for local update testing, including setup, server management, and manifest generation. - Added `dev-app-update.local.yml` for local server configuration. - Implemented `generate-manifest.sh` to create update manifests. - Created `run-test.sh` for streamlined testing process. - Updated `README.md` with instructions for local testing setup and usage. - Enhanced `UpdaterManager` to allow forced use of dev update configuration in packaged apps. Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix(desktop): update UpdaterManager test mocks for new exports Add missing mock exports for @/modules/updater/configs: - isStableChannel - githubConfig - UPDATE_SERVER_URL Add mock for @/env with getDesktopEnv Add setFeedURL method to autoUpdater mock * ✨ feat: add Conductor setup scripts and configuration * ✨ feat: enhance update modal functionality and refactor modal hooks - Added `useUpdateModal` for managing update modal state and behavior. - Refactored `UpdateModal` to utilize new modal management approach. - Improved `useWatchBroadcast` integration for handling update events. - Removed deprecated `createModalHooks` and related components from `FunctionModal`. - Updated `AddFilesToKnowledgeBase` and `CreateNew` modals to use new modal context for closing behavior. This refactor streamlines modal management and enhances the user experience during update processes. Signed-off-by: Innei <tukon479@gmail.com> * update flow (#11513) * ci: simplify desktop release workflow and add renderer tarball * 👷 ci: fix s3 upload credentials for desktop release * 🐛 fix(ci): use compact jq output for GitHub Actions matrix Add -c flag to jq commands to produce single-line JSON output, fixing "Invalid format" error when setting GITHUB_OUTPUT. * 🐛 fix(ci): add administration permission to detect self-hosted runner The /actions/runners API requires administration:read permission to list repository runners. * 🔧 refactor(ci): use workflow input for self-hosted runner selection Replace API-based runner detection with workflow input parameter since GITHUB_TOKEN lacks permission to call /actions/runners API. - Add `use_self_hosted_mac` input (default: true) - Release events always use self-hosted runner - Manual dispatch can toggle via input * feat(updater): add stable channel support with fallback mechanism - Configure electron-builder to generate stable-mac.yml for stable channel - Update CI workflow to handle both stable and latest manifest files - Implement fallback to GitHub provider when primary S3 provider fails - Reset to primary provider after successful update check * 🐛 fix(updater): remove invalid channel config from electron-builder - Remove unsupported 'channel' property from electron-builder config - Create stable*.yml files from latest*.yml in workflow instead - This ensures electron-updater finds correct manifest for stable channel * 🐛 fix(updater): use correct channel based on provider type - S3 provider: channel='stable' → looks for stable-mac.yml - GitHub provider: channel='latest' → looks for latest-mac.yml This fixes the 404 error when falling back to GitHub releases, which only have latest-mac.yml files. * refactor(env): remove unused OFFICIAL_CLOUD_SERVER and update env defaults Update environment variable handling by removing unused OFFICIAL_CLOUD_SERVER and setting defaults for UPDATE_CHANNEL and UPDATE_SERVER_URL from process.env during build stage. * 🐛 fix(ci): add version prefix to stable manifest URLs for S3 S3 directory structure: stable/{version}/xxx.dmg So stable-mac.yml URLs need version prefix: url: LobeHub-2.1.0-arm64.dmg → url: 2.1.1/LobeHub-2.1.0-arm64.dmg * ✨ feat(ci): add renderer tar manifest for integrity verification Creates stable-renderer.yml with SHA512 checksum for lobehub-renderer.tar.gz This allows the desktop app to verify renderer tarball integrity before extraction. * 🐛 fix(ci): fix YAML syntax error in renderer manifest generation * ✨ feat(ci): archive manifest files in version directory * refactor(ci): update desktop release workflows to streamline build process - Removed unnecessary dependencies in the build job for the desktop beta workflow. - Introduced a new gate job to conditionally proceed with publishing based on the success of previous jobs. - Updated macOS file merging to depend on the new gate job instead of the build job. - Simplified macOS runner selection logic in the stable workflow by using GitHub-hosted runners exclusively. Signed-off-by: Innei <tukon479@gmail.com> * refactor(electron): reorganize titlebar components and update imports - Moved titlebar components to a new directory structure for better organization. - Updated import paths for `SimpleTitleBar`, `TitleBar`, and related constants. - Introduced new components for connection management and navigation within the titlebar. - Added constants for title bar height to maintain consistency across components. This refactor enhances the maintainability of the titlebar code and improves the overall structure of the Electron application. Signed-off-by: Innei <tukon479@gmail.com> * feat(ci): add release notes handling to desktop stable workflow - Enhanced the desktop stable release workflow to include release notes. - Updated output variables to capture release notes from the GitHub event. - Adjusted environment variables in subsequent jobs to utilize the new release notes data. This addition improves the clarity and documentation of releases by ensuring that release notes are included in the workflow process. Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: call onClose after knowledge base modal closes * 🧪 test: fix UpdaterManager update channel mocks --------- Signed-off-by: Innei <tukon479@gmail.com>
5.2 KiB
5.2 KiB
本地更新测试指南
本目录包含用于在本地测试 Desktop 应用更新功能的工具和脚本。
目录结构
scripts/update-test/
├── README.md # 本文档
├── setup.sh # 一键设置脚本
├── start-server.sh # 启动本地更新服务器
├── stop-server.sh # 停止本地更新服务器
├── generate-manifest.sh # 生成 manifest 和目录结构
├── dev-app-update.local.yml # 本地测试用的更新配置模板
└── server/ # 本地服务器文件目录 (自动生成)
├── stable/ # stable 渠道
│ ├── latest-mac.yml
│ └── {version}/
│ ├── xxx.dmg
│ └── xxx.zip
├── beta/ # beta 渠道
│ └── ...
└── nightly/ # nightly 渠道
└── ...
快速开始
1. 首次设置
cd apps/desktop/scripts/update-test
chmod +x *.sh
./setup.sh
2. 构建测试包
# 回到 desktop 目录
cd ../..
# 构建未签名的本地测试包
bun run build
bun run build-local
3. 生成更新文件
cd scripts/update-test
# 从 release 目录自动检测并生成 (默认 stable 渠道)
./generate-manifest.sh --from-release
# 指定版本号 (用于模拟更新)
./generate-manifest.sh --from-release -v 0.0.1
# 指定渠道
./generate-manifest.sh --from-release -c beta -v 2.1.0-beta.1
4. 启动本地服务器
./start-server.sh
# 服务器默认在 http://localhost:8787 启动
5. 配置应用使用本地服务器
# 复制本地测试配置到 desktop 根目录
cp dev-app-update.local.yml ../../dev-app-update.yml
# 或者直接编辑 dev-app-update.yml,确保 URL 指向正确的渠道:
# url: http://localhost:8787/stable
6. 运行应用测试
cd ../..
bun run dev
7. 测试完成后
cd scripts/update-test
./stop-server.sh
# 恢复默认的 dev-app-update.yml(可选)
cd ../..
git checkout dev-app-update.yml
generate-manifest.sh 用法
用法: ./generate-manifest.sh [选项]
选项:
-v, --version VERSION 指定版本号 (例如: 2.0.1)
-c, --channel CHANNEL 指定渠道 (stable|beta|nightly, 默认: stable)
-d, --dmg FILE 指定 DMG 文件名
-z, --zip FILE 指定 ZIP 文件名
-n, --notes TEXT 指定 release notes
-f, --from-release 从 release 目录自动复制文件
-h, --help 显示帮助信息
示例:
./generate-manifest.sh --from-release
./generate-manifest.sh -v 2.0.1 -c stable --from-release
./generate-manifest.sh -v 2.1.0-beta.1 -c beta --from-release
详细说明
关于 macOS 签名验证
本地测试的包未经签名和公证,macOS 会阻止运行。解决方法:
方法 1:临时禁用 Gatekeeper(推荐)
# 禁用
sudo spctl --master-disable
# 测试完成后务必重新启用!
sudo spctl --master-enable
方法 2:手动移除隔离属性
# 对下载的 DMG 或解压后的 .app 执行
xattr -cr /path/to/YourApp.app
方法 3:系统偏好设置
- 打开「系统偏好设置」→「安全性与隐私」→「通用」
- 点击「仍要打开」允许未签名的应用
自定义 Release Notes
编辑 server/{channel}/latest-mac.yml 中的 releaseNotes 字段:
releaseNotes: |
## 🎉 v2.0.1 测试版本
### ✨ 新功能
- 功能 A
- 功能 B
### 🐛 修复
- 修复问题 X
测试不同场景
| 场景 | 操作 |
|---|---|
| 有新版本可用 | 设置 manifest 中的 version 大于当前应用版本 (0.0.0) |
| 无新版本 | 设置 version 小于或等于当前版本 |
| 下载失败 | 删除 server/{channel}/{version}/ 中的 DMG 文件 |
| 网络错误 | 停止本地服务器 |
| 测试不同渠道 | 修改 dev-app-update.yml 中的 URL 指向不同渠道 |
环境变量
也可以通过环境变量指定更新服务器:
UPDATE_SERVER_URL=http://localhost:8787/stable bun run dev
故障排除
1. 服务器启动失败
# 检查端口是否被占用
lsof -i :8787
# 使用其他端口
PORT=9000 ./start-server.sh
2. 更新检测不到
- 确认
dev-app-update.yml中的 URL 包含渠道路径 (如/stable) - 确认 manifest 中的版本号大于当前版本 (0.0.0)
- 查看日志:
tail -f ~/Library/Logs/lobehub-desktop-dev/main.log
3. 请求了错误的 yml 文件
- 如果请求的是
stable-mac.yml而不是latest-mac.yml,说明代码中设置了 channel - 确保在 dev 模式下运行,代码不会设置
autoUpdater.channel
4. 下载后无法安装
- 确认已禁用 Gatekeeper 或移除隔离属性
- 确认 DMG 文件完整
注意事项
⚠️ 安全提醒:
- 测试完成后务必重新启用 Gatekeeper
- 这些脚本仅用于本地开发测试
- 不要将未签名的包分发给其他用户