Skip to content

Commit ed97363

Browse files
authored
✨ feat: support desktop release framework and workflow (#6474)
* add desktop fix build update release desktop ci improve desktop build for pr workflow update desktop build workflow test auto updater fix fix release nightly channel support shortcut framework improve nightly version rule add zip release only add mac publish fix static file relative issue support delete files fix lint enable asar add setting open in editor in menu add electron store framework and locale update flow fix default searchFCModel refactor the electron server ipc to stable mode improve electron dev workflow improve electron build workflow make qwen2.5b default improve comment workflow fix types refactor code improve window size of settings/provider 路由拦截器v3.5 fix RouteIntercept issue improve log use productName in package.json update add pin list for feature flag update sure settings update make ollama as default provider in desktop fix desktop close page issue fix desktop default variants improve to reduce bundle improve to reduce bundle again improve set desktop version workflow add nightly icons add prebuild scripts to reduce package size add to test prebuild fix workflow try to add sign and notarize for mac in workflow try to add sign and notarize add i18n for menu and main update menu i18n add i18n framework add menu implement and setting improve layout design for desktop update Author fix failed register protocol fix prod building fix tests fix open error of mac and windows improve lint update pr comment add service framework add fileSearchService improve fix release workflow add header improve pr workflow fetch improve client fetch add linux upload workflow improve workflow and implement fix build electron in ci build the desktop framework fix build electron in ci update tsconfig fix desktop build workflow finish desktop build workflow fix workflow build steps update workflow test release workflow refactor update update improve loading state refactor the 404 error * 重构存储路径,统一到一个 lobehub-storage 下,方便未来用户自定义存储路径 * fix lint * update * try to fix windows open issue * rename * fix storage * refactor the remote server sync * refactor the request method * 完成服务端同步实现逻辑 * fix lint * save size * refactor to make sure different instance of ipc channel * clean log * fix refresh * fix tools calling * fix auth callback issue * update workflow * add window ico * push * update * add beta release * fix update issue * 完成官方实例链接 * fix * fix stdio
1 parent 99b45f3 commit ed97363

File tree

195 files changed

+10921
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+10921
-384
lines changed

.env.desktop

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ APP_URL=http://localhost:3015
33
FEATURE_FLAGS=-check_updates,+pin_list
44
KEY_VAULTS_SECRET=oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE=
55
DATABASE_URL=postgresql://postgres@localhost:5432/postgres
6-
DEFAULT_AGENT_CONFIG="model=qwen2.5;provider=ollama;chatConfig.searchFCModel.provider=ollama;chatConfig.searchFCModel.model=qwen2.5"
7-
SYSTEM_AGENT="default=ollama/qwen2.5"
86
SEARCH_PROVIDERS=search1api
7+
NEXT_PUBLIC_SERVICE_MODE='server'
Lines changed: 59 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
name: Release Desktop
1+
name: Desktop PR Build
22

33
on:
4-
# uncomment when official desktop version released
5-
# release:
6-
# types: [published] # 发布 release 时触发构建
74
pull_request:
85
types: [synchronize, labeled, unlabeled] # PR 更新或标签变化时触发
96

@@ -12,17 +9,17 @@ concurrency:
129
group: ${{ github.ref }}-${{ github.workflow }}
1310
cancel-in-progress: true
1411

12+
# Add default permissions
13+
permissions: read-all
14+
1515
env:
1616
PR_TAG_PREFIX: pr- # PR 构建版本的前缀标识
1717

1818
jobs:
1919
test:
2020
name: Code quality check
2121
# 添加 PR label 触发条件,只有添加了 Build Desktop 标签的 PR 才会触发构建
22-
if: |
23-
(github.event_name == 'pull_request' &&
24-
contains(github.event.pull_request.labels.*.name, 'Build Desktop')) ||
25-
github.event_name != 'pull_request'
22+
if: contains(github.event.pull_request.labels.*.name, 'Build Desktop')
2623
runs-on: ubuntu-latest # 只在 ubuntu 上运行一次检查
2724
steps:
2825
- name: Checkout base
@@ -38,7 +35,7 @@ jobs:
3835
- name: Setup pnpm
3936
uses: pnpm/action-setup@v2
4037
with:
41-
version: 8
38+
version: 9
4239

4340
- name: Install deps
4441
run: pnpm install
@@ -50,21 +47,14 @@ jobs:
5047
env:
5148
NODE_OPTIONS: --max-old-space-size=6144
5249

53-
# - name: Test
54-
# run: pnpm run test
55-
5650
version:
5751
name: Determine version
5852
# 与 test job 相同的触发条件
59-
if: |
60-
(github.event_name == 'pull_request' &&
61-
contains(github.event.pull_request.labels.*.name, 'Build Desktop')) ||
62-
github.event_name != 'pull_request'
53+
if: contains(github.event.pull_request.labels.*.name, 'Build Desktop')
6354
runs-on: ubuntu-latest
6455
outputs:
6556
# 输出版本信息,供后续 job 使用
6657
version: ${{ steps.set_version.outputs.version }}
67-
is_pr_build: ${{ steps.set_version.outputs.is_pr_build }}
6858
steps:
6959
- uses: actions/checkout@v4
7060
with:
@@ -82,40 +72,20 @@ jobs:
8272
# 从 apps/desktop/package.json 读取基础版本号
8373
base_version=$(node -p "require('./apps/desktop/package.json').version")
8474
85-
if [ "${{ github.event_name }}" == "pull_request" ]; then
86-
# PR 构建:在基础版本号上添加 PR 信息
87-
branch_name="${{ github.head_ref }}"
88-
# 清理分支名,移除非法字符
89-
sanitized_branch=$(echo "${branch_name}" | sed -E 's/[^a-zA-Z0-9_.-]+/-/g')
90-
# 创建特殊的 PR 版本号:基础版本号-PR前缀-分支名-提交哈希
91-
version="${base_version}-${{ env.PR_TAG_PREFIX }}${sanitized_branch}-$(git rev-parse --short HEAD)"
92-
echo "version=${version}" >> $GITHUB_OUTPUT
93-
echo "is_pr_build=true" >> $GITHUB_OUTPUT
94-
echo "📦 Release Version: ${version} (based on base version ${base_version})"
95-
96-
elif [ "${{ github.event_name }}" == "release" ]; then
97-
# Release 事件直接使用 release tag 作为版本号,去掉可能的 v 前缀
98-
version="${{ github.event.release.tag_name }}"
99-
version="${version#v}"
100-
echo "version=${version}" >> $GITHUB_OUTPUT
101-
echo "is_pr_build=false" >> $GITHUB_OUTPUT
102-
echo "📦 Release Version: ${version}"
103-
104-
else
105-
# 其他情况(如手动触发)使用 apps/desktop/package.json 的版本号
106-
version="${base_version}"
107-
echo "version=${version}" >> $GITHUB_OUTPUT
108-
echo "is_pr_build=false" >> $GITHUB_OUTPUT
109-
echo "📦 Release Version: ${version}"
110-
fi
75+
# PR 构建:在基础版本号上添加 PR 信息
76+
pr_number="${{ github.event.pull_request.number }}"
77+
ci_build_number="${{ github.run_number }}" # CI 构建编号
78+
version="${base_version}-nightly.pr${pr_number}.${ci_build_number}"
79+
echo "version=${version}" >> $GITHUB_OUTPUT
80+
echo "📦 Release Version: ${version} (based on base version ${base_version})"
81+
11182
env:
11283
NODE_OPTIONS: --max-old-space-size=6144
11384

11485
# 输出版本信息总结,方便在 GitHub Actions 界面查看
11586
- name: Version Summary
11687
run: |
11788
echo "🚦 Release Version: ${{ steps.set_version.outputs.version }}"
118-
echo "🔄 Is PR Build: ${{ steps.set_version.outputs.is_pr_build }}"
11989
12090
build:
12191
needs: [version, test]
@@ -137,43 +107,57 @@ jobs:
137107
- name: Setup pnpm
138108
uses: pnpm/action-setup@v2
139109
with:
140-
version: 8
110+
version: 9
141111

112+
# node-linker=hoisted 模式将可以确保 asar 压缩可用
142113
- name: Install deps
143-
run: pnpm install
114+
run: pnpm install --node-linker=hoisted
144115

145116
- name: Install deps on Desktop
146117
run: npm run install-isolated --prefix=./apps/desktop
147118

148119
# 设置 package.json 的版本号
149120
- name: Set package version
150-
run: npm run workflow:set-desktop-version ${{ needs.version.outputs.version }}
121+
run: npm run workflow:set-desktop-version ${{ needs.version.outputs.version }} nightly
151122

152123
# macOS 构建处理
153124
- name: Build artifact on macOS
154125
if: runner.os == 'macOS'
155126
run: npm run desktop:build
156127
env:
157-
APP_URL: http://localhost:3010
128+
# 设置更新通道,PR构建为nightly,否则为stable
129+
UPDATE_CHANNEL: 'nightly'
130+
APP_URL: http://localhost:3015
158131
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
159132
# 默认添加一个加密 SECRET
160133
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
161-
# 公证部分将来再加回
162-
# CSC_LINK: ./build/developer-id-app-certs.p12
163-
# CSC_KEY_PASSWORD: ${{ secrets.APPLE_APP_CERTS_PASSWORD }}
164-
# APPLE_ID: ${{ secrets.APPLE_ID }}
165-
# APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
134+
# macOS 签名和公证配置
135+
CSC_LINK: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
136+
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
137+
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
138+
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
139+
140+
# allow provisionally
141+
CSC_FOR_PULL_REQUEST: true
142+
APPLE_ID: ${{ secrets.APPLE_ID }}
143+
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
144+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
166145

167146
# 非 macOS 平台构建处理
168147
- name: Build artifact on other platforms
169148
if: runner.os != 'macOS'
170149
run: npm run desktop:build
171150
env:
172-
APP_URL: http://localhost:3010
151+
# 设置更新通道,PR构建为nightly,否则为stable
152+
UPDATE_CHANNEL: 'nightly'
153+
APP_URL: http://localhost:3015
173154
DATABASE_URL: 'postgresql://postgres@localhost:5432/postgres'
174155
KEY_VAULTS_SECRET: 'oLXWIiR/AKF+rWaqy9lHkrYgzpATbW3CtJp3UfkVgpE='
156+
NEXT_PUBLIC_DESKTOP_PROJECT_ID: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_PROJECT_ID }}
157+
NEXT_PUBLIC_DESKTOP_UMAMI_BASE_URL: ${{ secrets.UMAMI_NIGHTLY_DESKTOP_BASE_URL }}
158+
175159

176-
# 上传构建产物,移除了 zip 相关部分
160+
# 上传构建产物
177161
- name: Upload artifact
178162
uses: actions/upload-artifact@v4
179163
with:
@@ -186,18 +170,21 @@ jobs:
186170
apps/desktop/release/*.AppImage
187171
retention-days: 5
188172

189-
- name: Log build info
190-
run: |
191-
echo "🔄 Is PR Build: ${{ needs.version.outputs.is_pr_build }}"
192-
193-
# 将原本的 merge job 调整,作为所有构建产物的准备步骤
194-
prepare-artifacts:
173+
publish-pr:
195174
needs: [build, version]
196-
name: Prepare Artifacts
175+
name: Publish PR Build
197176
runs-on: ubuntu-latest
177+
# Grant write permissions for creating release and commenting on PR
178+
permissions:
179+
contents: write
180+
pull-requests: write
198181
outputs:
199182
artifact_path: ${{ steps.set_path.outputs.path }}
200183
steps:
184+
- uses: actions/checkout@v4
185+
with:
186+
fetch-depth: 0
187+
201188
# 下载所有平台的构建产物
202189
- name: Download artifacts
203190
uses: actions/download-artifact@v4
@@ -210,66 +197,6 @@ jobs:
210197
- name: List artifacts
211198
run: ls -R release
212199

213-
# 设置构建产物路径,供后续 job 使用
214-
- name: Set artifact path
215-
id: set_path
216-
run: echo "path=release" >> $GITHUB_OUTPUT
217-
218-
# 正式版发布 job - 只处理 release 触发的场景
219-
publish-release:
220-
# 只在 release 事件触发且不是 PR 构建时执行
221-
if: |
222-
github.event_name == 'release' &&
223-
needs.version.outputs.is_pr_build != 'true'
224-
needs: [prepare-artifacts, version]
225-
name: Publish Release
226-
runs-on: ubuntu-latest
227-
steps:
228-
- uses: actions/checkout@v4
229-
with:
230-
fetch-depth: 0
231-
232-
# 下载构建产物
233-
- name: Download artifacts
234-
uses: actions/download-artifact@v4
235-
with:
236-
path: ${{ needs.prepare-artifacts.outputs.artifact_path }}
237-
pattern: release-*
238-
merge-multiple: true
239-
240-
# 将构建产物上传到现有 release
241-
- name: Upload to Release
242-
uses: softprops/action-gh-release@v1
243-
with:
244-
tag_name: ${{ github.event.release.tag_name }}
245-
files: |
246-
${{ needs.prepare-artifacts.outputs.artifact_path }}/latest*
247-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.dmg*
248-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.zip*
249-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.exe*
250-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.AppImage
251-
env:
252-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
253-
254-
# PR 构建的处理步骤
255-
publish-pr:
256-
if: needs.version.outputs.is_pr_build == 'true'
257-
needs: [prepare-artifacts, version]
258-
name: Publish PR Build
259-
runs-on: ubuntu-latest
260-
steps:
261-
- uses: actions/checkout@v4
262-
with:
263-
fetch-depth: 0
264-
265-
# 下载构建产物
266-
- name: Download artifacts
267-
uses: actions/download-artifact@v4
268-
with:
269-
path: ${{ needs.prepare-artifacts.outputs.artifact_path }}
270-
pattern: release-*
271-
merge-multiple: true
272-
273200
# 生成PR发布描述
274201
- name: Generate PR Release Body
275202
id: pr_release_body
@@ -287,22 +214,22 @@ jobs:
287214
288215
return body;
289216
290-
# 为构建产物创建一个临时发布
291217
- name: Create Temporary Release for PR
292218
id: create_release
293219
uses: softprops/action-gh-release@v1
294220
with:
295221
name: PR Build v${{ needs.version.outputs.version }}
296-
tag_name: pr-build-${{ github.event.pull_request.number }}-${{ github.sha }}
222+
tag_name: v${{ needs.version.outputs.version }}
223+
# tag_name: pr-build-${{ github.event.pull_request.number }}-${{ github.sha }}
297224
body: ${{ steps.pr_release_body.outputs.result }}
298225
draft: false
299226
prerelease: true
300227
files: |
301-
${{ needs.prepare-artifacts.outputs.artifact_path }}/latest*
302-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.dmg*
303-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.zip*
304-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.exe*
305-
${{ needs.prepare-artifacts.outputs.artifact_path }}/*.AppImage
228+
release/latest*
229+
release/*.dmg*
230+
release/*.zip*
231+
release/*.exe*
232+
release/*.AppImage
306233
env:
307234
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
308235

@@ -315,17 +242,12 @@ jobs:
315242
const releaseUrl = "${{ steps.create_release.outputs.url }}";
316243
const prCommentGenerator = require('${{ github.workspace }}/.github/scripts/pr-comment.js');
317244
318-
const body = await prCommentGenerator({
245+
const result = await prCommentGenerator({
319246
github,
320247
context,
321248
releaseUrl,
322249
version: "${{ needs.version.outputs.version }}",
323-
tag: "pr-build-${{ github.event.pull_request.number }}-${{ github.sha }}"
250+
tag: "v${{ needs.version.outputs.version }}"
324251
});
325252
326-
github.rest.issues.createComment({
327-
issue_number: context.issue.number,
328-
owner: context.repo.owner,
329-
repo: context.repo.repo,
330-
body: body
331-
});
253+
console.log(`评论状态: ${result.updated ? '已更新' : '已创建'}, ID: ${result.id}`);

0 commit comments

Comments
 (0)