Skip to content

Commit 5cf6cf7

Browse files
authored
feat: Support Windows building (#98)
* feat: Support Windows building * opt: use prebuilt lynx-trace on windows * chore: revert test pipeline * chore: fix pipeline * chore: fix pipeline * chore: fix pipeline * chore: fix pipeline * chore: fix pipeline * chore: fix pipeline * chore: fix pipeline
1 parent 5cffb30 commit 5cf6cf7

File tree

24 files changed

+3722
-2666
lines changed

24 files changed

+3722
-2666
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v3
21+
with:
22+
submodules: recursive
23+
24+
- name: Install system dependencies
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y lbzip2
2128
2229
- name: Python Setup
2330
uses: actions/setup-python@v5

.github/workflows/release.yaml

Lines changed: 142 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
permissions:
99
contents: write
10+
pull_requests: write
1011

1112
jobs:
1213
create-release:
@@ -66,7 +67,7 @@ jobs:
6667
- Only used for DevTool developers to verify branch code
6768
- May contain unstable or incomplete features' || github.ref }}
6869
69-
build-and-upload:
70+
build-and-upload-macos:
7071
needs: create-release
7172
runs-on: lynx-darwin-14-medium
7273
strategy:
@@ -75,6 +76,11 @@ jobs:
7576

7677
steps:
7778
- uses: actions/checkout@v3
79+
with:
80+
submodules: recursive
81+
82+
- name: ln Python
83+
run: ln -s `which python3` /usr/local/bin/python
7884

7985
# Node and pnpm setup steps
8086
- name: Setup Node.js
@@ -106,9 +112,6 @@ jobs:
106112
- name: Fetch depot_tools
107113
run: pnpm run fetch:depot_tools
108114

109-
- name: ln Python
110-
run: ln -s `which python3` /usr/local/bin/python
111-
112115
- name: Sync devtools-gn
113116
run: |
114117
export PATH=$(pwd)/packages/devtools-frontend-lynx/buildtools/depot_tools:$PATH
@@ -196,3 +199,138 @@ jobs:
196199
asset_path: ${{ steps.find_dmg.outputs.dmg_path }}
197200
asset_name: ${{ steps.find_dmg.outputs.dmg_filename }}
198201
asset_content_type: application/x-apple-diskimage
202+
203+
build-and-upload-windows:
204+
needs: create-release
205+
runs-on: lynx-windows-2022-large
206+
207+
steps:
208+
- uses: actions/checkout@v3
209+
with:
210+
submodules: recursive
211+
212+
# Node and pnpm setup steps
213+
- name: Setup Node.js
214+
uses: actions/setup-node@v3
215+
with:
216+
node-version: 18.20.2
217+
218+
- name: Install pnpm
219+
uses: pnpm/action-setup@v2
220+
with:
221+
version: 7.33.6
222+
223+
- name: Get pnpm store directory
224+
shell: pwsh
225+
run: |
226+
echo "STORE_PATH=$(pnpm store path --silent)" >> $env:GITHUB_ENV
227+
228+
- name: Setup pnpm cache
229+
uses: actions/cache@v3
230+
with:
231+
path: ${{ env.STORE_PATH }}
232+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
233+
restore-keys: |
234+
${{ runner.os }}-pnpm-store-
235+
236+
- name: Install dependencies
237+
run: pnpm install
238+
239+
- name: Fetch depot_tools
240+
run: pnpm run fetch:depot_tools
241+
242+
- name: Sync devtools-gn
243+
shell: pwsh
244+
run: |
245+
$env:PATH = "$(Get-Location)\packages\devtools-frontend-lynx\buildtools\depot_tools;$env:PATH"
246+
pnpm run sync:devtools-gn
247+
248+
- name: Build devtools-gn
249+
run: pnpm run build:devtools
250+
251+
- name: Sync devtools-dist
252+
run: pnpm run sync:devtools-dist
253+
254+
- name: Skip lynx-trace build on Windows
255+
run: pnpm run build:lynx-trace
256+
257+
- name: Download lynx-trace prebuilt artifact
258+
uses: robinraju/release-downloader@v1
259+
with:
260+
repository: KananSu/lynx-trace
261+
latest: true
262+
fileName: "perfetto-ui-release-*.tar.gz"
263+
out-file-path: temp-lynx-trace
264+
token: ${{ secrets.GITHUB_TOKEN }}
265+
266+
- name: Copy lynx-trace to resources
267+
shell: pwsh
268+
run: |
269+
Write-Host "Copying prebuilt lynx-trace artifact..." -ForegroundColor Cyan
270+
$sourceFile = Get-ChildItem -Path "temp-lynx-trace" -Filter "perfetto-ui-release-*.tar.gz" | Select-Object -First 1
271+
$destPath = "packages\lynx-devtool-cli\resources\lynx-trace.tar.gz"
272+
273+
if ($sourceFile) {
274+
Copy-Item $sourceFile.FullName $destPath -Force
275+
Write-Host "✓ lynx-trace artifact copied: $($sourceFile.Name) -> lynx-trace.tar.gz" -ForegroundColor Green
276+
} else {
277+
Write-Warning "lynx-trace artifact not found, trace feature will be unavailable"
278+
Get-ChildItem -Path "temp-lynx-trace" -ErrorAction SilentlyContinue
279+
}
280+
281+
- name: Build all packages
282+
run: pnpm run build:all
283+
284+
# Upload frontend (only once)
285+
- name: Find and Upload Frontend
286+
shell: pwsh
287+
run: |
288+
$archivePath = Get-ChildItem -Path ".\packages\devtools-frontend-lynx\output" -Filter "devtool.frontend.lynx_1.0.*.tar.gz" | Select-Object -First 1 -ExpandProperty FullName
289+
if (-not $archivePath) {
290+
Write-Error "Error: Frontend archive not found"
291+
exit 1
292+
}
293+
Write-Host "Found archive at: $archivePath"
294+
295+
curl.exe `
296+
-X POST `
297+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" `
298+
-H "Content-Type: application/gzip" `
299+
--data-binary "@$archivePath" `
300+
"${{ needs.create-release.outputs.upload_url }}?name=devtool.frontend.lynx-${{ needs.create-release.outputs.asset_suffix }}.tar.gz"
301+
302+
# Build Windows green package (ZIP - no installer)
303+
- name: Build Windows version
304+
shell: pwsh
305+
env:
306+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
307+
run: |
308+
Write-Host "Starting Windows build..." -ForegroundColor Cyan
309+
powershell -ExecutionPolicy Bypass -File scripts\build-win.ps1
310+
311+
- name: Find Windows ZIP file
312+
id: find_zip
313+
shell: pwsh
314+
run: |
315+
$zip = Get-ChildItem -Path ".\dist" -Filter "Lynx-DevTool-*-x64.zip" | Select-Object -First 1
316+
317+
if ($zip) {
318+
Write-Host "Found ZIP package: $($zip.Name)" -ForegroundColor Green
319+
Write-Host "Size: $([math]::Round($zip.Length/1MB, 2)) MB" -ForegroundColor Green
320+
echo "zip_path=$($zip.FullName)" >> $env:GITHUB_OUTPUT
321+
echo "zip_filename=$($zip.Name)" >> $env:GITHUB_OUTPUT
322+
} else {
323+
Write-Error "No ZIP file found in dist directory"
324+
Get-ChildItem -Path ".\dist" | Format-Table Name
325+
exit 1
326+
}
327+
328+
- name: Upload Windows ZIP Package
329+
uses: actions/upload-release-asset@v1
330+
env:
331+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
332+
with:
333+
upload_url: ${{ needs.create-release.outputs.upload_url }}
334+
asset_path: ${{ steps.find_zip.outputs.zip_path }}
335+
asset_name: ${{ steps.find_zip.outputs.zip_filename }}
336+
asset_content_type: application/zip

package.json

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@
55
"description": "Lynx DevTool",
66
"main": "dist/index.js",
77
"scripts": {
8-
"build": "rsbuild build --config rsbuild.main.config.ts && cp preload.js dist/",
8+
"build": "rsbuild build --config rsbuild.main.config.ts && node -e \"const fs=require('fs'); const path=require('path'); fs.copyFileSync('preload.js', path.join('dist', 'preload.js'))\"",
99
"dev": "pnpm run build:all && concurrently \"wait-on dist/index.js && electron .\"",
10-
"modern:renderer": "BUILD_ELECTRON_RENDERER=true LDT_BUILD_TYPE=offline MODERN_ENV=offline modern build --config modern.renderer.config.ts",
10+
"modern:renderer": "cross-env BUILD_ELECTRON_RENDERER=true LDT_BUILD_TYPE=offline MODERN_ENV=offline modern build --config modern.renderer.config.ts",
1111
"rsbuild:main": "rsbuild build --config rsbuild.config.ts",
1212
"build:all": "pnpm --filter @lynx-js/* run build && pnpm run build && pnpm run modern:renderer",
13-
"clean": "rm -rf dist && pnpm -r exec rm -rf dist && rm -rf packages/devtools-frontend-lynx/out packages/devtools-frontend-lynx/output",
13+
"clean": "node -e \"const fs=require('fs'); ['dist', 'packages/devtools-frontend-lynx/out', 'packages/devtools-frontend-lynx/output'].forEach(p => fs.existsSync(p) && fs.rmSync(p, {recursive: true, force: true}))\" && pnpm -r exec node -e \"const fs=require('fs'); fs.existsSync('dist') && fs.rmSync('dist', {recursive: true, force: true})\"",
1414
"build:devtools-frontend-lynx": "pnpm run fetch:depot_tools && export PATH=$(pwd)/packages/devtools-frontend-lynx/buildtools/depot_tools:$PATH && pnpm run sync:devtools-gn && pnpm run build:devtools && pnpm run sync:devtools-dist",
15-
"fetch:depot_tools": "cd packages/devtools-frontend-lynx && scripts/fetch-depot-tools.sh",
15+
"fetch:depot_tools": "node scripts/fetch-depot-tools.js",
1616
"sync:devtools-gn": "gclient sync --gclientfile=.gclient --deps=all",
17-
"build:devtools": "cd packages/devtools-frontend-lynx && scripts/build-lynx-devtools.sh",
18-
"build:lynx-trace": "bash scripts/build-lynx-trace-output.sh",
19-
"sync:devtools-dist": "scripts/sync-devtools-output.sh",
17+
"build:devtools": "node scripts/build-lynx-devtools.js",
18+
"build:lynx-trace": "node scripts/build-lynx-trace-check-platform.js",
19+
"sync:devtools-dist": "node scripts/sync-devtools-output.js",
2020
"production:mac-arm64": "pnpm run clean && pnpm run build:all && cross-env NODE_ENV=production electron-builder --arm64",
21-
"production:mac-x64": "pnpm run clean && pnpm run build:all && cross-env NODE_ENV=production electron-builder --x64"
21+
"production:mac-x64": "pnpm run clean && pnpm run build:all && cross-env NODE_ENV=production electron-builder --x64",
22+
"production:win": "pnpm run clean && pnpm run build:all && powershell -ExecutionPolicy Bypass -File scripts\\build-win.ps1"
2223
},
2324
"author": "lynx",
2425
"license": "Apache-2.0",
@@ -110,13 +111,16 @@
110111
],
111112
"extraResources": [
112113
{
113-
"from": "src/res/icons",
114+
"from": "res/icons",
114115
"to": "icons",
115116
"filter": [
116117
"**/*"
117118
]
118119
}
119120
],
121+
"asarUnpack": [
122+
"node_modules/sharp/**/*"
123+
],
120124
"appId": "com.lynx.devtool",
121125
"productName": "LynxDevTool",
122126
"extraMetadata": {
@@ -131,7 +135,16 @@
131135
"icon": "res/icons/lynx-devtool.icns"
132136
},
133137
"win": {
134-
"target": "nsis"
138+
"target": [
139+
{
140+
"target": "zip",
141+
"arch": [
142+
"x64"
143+
]
144+
}
145+
],
146+
"artifactName": "Lynx-DevTool-${version}-${arch}.${ext}",
147+
"icon": "res/icons/lynx-devtool_256x256.png"
135148
},
136149
"linux": {
137150
"target": "AppImage"

0 commit comments

Comments
 (0)