forked from block/goose
-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (138 loc) · 5.55 KB
/
bundle-desktop-windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: "Bundle Desktop (Windows)"
on:
# push:
# branches: [ "main" ]
# pull_request:
# branches: [ "main" ]
workflow_call:
inputs:
signing:
description: 'Whether to sign the Windows executable'
required: false
type: boolean
default: false
secrets:
WINDOWS_CERTIFICATE:
required: false
WINDOWS_CERTIFICATE_PASSWORD:
required: false
jobs:
build-desktop-windows:
name: Build Desktop (Windows)
runs-on: windows-latest
steps:
# 1) Check out source
- name: Checkout repository
uses: actions/checkout@v3
# 2) Set up Rust
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# If you need a specific version, you could do:
# or uses: actions/setup-rust@v1
# with:
# rust-version: 1.73.0
# 3) Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
# 4) Cache dependencies (optional, can add more paths if needed)
- name: Cache node_modules
uses: actions/cache@v3
with:
path: |
node_modules
ui/desktop/node_modules
key: ${{ runner.os }}-build-desktop-windows-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-desktop-windows-
# 5) Install top-level dependencies if a package.json is in root
- name: Install top-level deps
run: |
if (Test-Path package.json) {
npm install
}
# 6) Build rust for x86_64-pc-windows-gnu
- name: Install MinGW dependencies
run: |
choco install mingw --version=8.1.0
# Debug - check installation paths
Write-Host "Checking MinGW installation..."
Get-ChildItem -Path "C:\ProgramData\chocolatey\lib\mingw" -Recurse -Filter "*.dll" | ForEach-Object {
Write-Host $_.FullName
}
Get-ChildItem -Path "C:\tools" -Recurse -Filter "*.dll" | ForEach-Object {
Write-Host $_.FullName
}
- name: Cargo build for Windows
run: |
cargo build --release --target x86_64-pc-windows-gnu
# 7) Check that the compiled goosed.exe exists and copy exe/dll to ui/desktop/src/bin
- name: Prepare Windows binary and DLLs
run: |
if (!(Test-Path .\target\x86_64-pc-windows-gnu\release\goosed.exe)) {
Write-Error "Windows binary not found."; exit 1;
}
Write-Host "Copying Windows binary and DLLs to ui/desktop/src/bin..."
if (!(Test-Path ui\desktop\src\bin)) {
New-Item -ItemType Directory -Path ui\desktop\src\bin | Out-Null
}
Copy-Item .\target\x86_64-pc-windows-gnu\release\goosed.exe ui\desktop\src\bin\
# Copy MinGW DLLs - try both possible locations
$mingwPaths = @(
"C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin",
"C:\tools\mingw64\bin"
)
foreach ($path in $mingwPaths) {
if (Test-Path "$path\libstdc++-6.dll") {
Write-Host "Found MinGW DLLs in $path"
Copy-Item "$path\libstdc++-6.dll" ui\desktop\src\bin\
Copy-Item "$path\libgcc_s_seh-1.dll" ui\desktop\src\bin\
Copy-Item "$path\libwinpthread-1.dll" ui\desktop\src\bin\
break
}
}
# Copy any other DLLs from the release directory
ls .\target\x86_64-pc-windows-gnu\release\*.dll | ForEach-Object {
Copy-Item $_ ui\desktop\src\bin\
}
# 8) Install & build UI desktop
- name: Build desktop UI with npm
run: |
cd ui\desktop
npm install
npm run bundle:windows
# 9) Copy exe/dll to final out/Goose-win32-x64/resources/bin
- name: Copy exe/dll to out folder
run: |
cd ui\desktop
if (!(Test-Path .\out\Goose-win32-x64\resources\bin)) {
New-Item -ItemType Directory -Path .\out\Goose-win32-x64\resources\bin | Out-Null
}
Copy-Item .\src\bin\goosed.exe .\out\Goose-win32-x64\resources\bin\
ls .\src\bin\*.dll | ForEach-Object {
Copy-Item $_ .\out\Goose-win32-x64\resources\bin\
}
# 10) Code signing (if enabled)
- name: Sign Windows executable
# Skip this step by default - enable when we have a certificate
if: inputs.signing && inputs.signing == true
env:
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
run: |
# Create a temporary certificate file
$certBytes = [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE)
$certPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "certificate.pfx"
[IO.File]::WriteAllBytes($certPath, $certBytes)
# Sign the main executable
$signtool = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\signtool.exe"
& $signtool sign /f $certPath /p $env:WINDOWS_CERTIFICATE_PASSWORD /tr http://timestamp.digicert.com /td sha256 /fd sha256 "ui\desktop\out\Goose-win32-x64\Goose.exe"
# Clean up the certificate
Remove-Item -Path $certPath
# 11) Upload the final Windows build
- name: Upload Windows build artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-windows-dist
path: ui/desktop/out/Goose-win32-x64/