-
Notifications
You must be signed in to change notification settings - Fork 0
367 lines (299 loc) · 12.7 KB
/
build.yml
File metadata and controls
367 lines (299 loc) · 12.7 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
name: Build & Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version override (e.g. 3.0.0) — leave blank to use package.json'
required: false
# One Build & Release at a time; new runs queue (do not cancel an in-flight release).
concurrency:
group: build-release-${{ github.repository }}
cancel-in-progress: false
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
release_tag: ${{ steps.version.outputs.release_tag }}
release_name: ${{ steps.version.outputs.release_name }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- id: version
shell: bash
run: |
set -euo pipefail
PACKAGE_VERSION=$(node -p "require('./package.json').version")
INPUT_VERSION='${{ github.event.inputs.version }}'
if [ -n "$INPUT_VERSION" ]; then
VERSION="$INPUT_VERSION"
elif [[ '${{ github.ref }}' == refs/tags/v* ]]; then
VERSION='${{ github.ref_name }}'
VERSION="${VERSION#v}"
else
VERSION="$PACKAGE_VERSION"
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "release_tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "release_name=guIDE v$VERSION" >> "$GITHUB_OUTPUT"
# ─── Windows CPU ────────────────────────────────────────────
build-windows-cpu:
needs: prepare
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set build version
shell: bash
run: |
node -e "const fs=require('fs'); const version='${{ needs.prepare.outputs.version }}'; const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=version; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
- name: Install setuptools (provides distutils for node-gyp)
run: pip install setuptools
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Build renderer
run: npm run build:renderer
- name: Build Windows CPU installer
run: npx electron-builder --win --x64 --config electron-builder.nosign.json --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- name: Upload artifact
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: windows-cpu
path: dist-electron/guIDE-*-cpu-x64-setup.exe
retention-days: 30
# ─── Windows CUDA ───────────────────────────────────────────
build-windows-cuda:
needs: prepare
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set build version
shell: bash
run: |
node -e "const fs=require('fs'); const version='${{ needs.prepare.outputs.version }}'; const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=version; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
- name: Install setuptools (provides distutils for node-gyp)
run: pip install setuptools
- uses: Jimver/cuda-toolkit@v0.2.15
with:
cuda: '12.4.0'
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Build renderer
run: npm run build:renderer
- name: Build Windows CUDA installer
run: npx electron-builder --win --x64 --config electron-builder.nosign.cuda.json --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- name: Upload artifact
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: windows-cuda
path: dist-electron/guIDE-*-cuda-x64-setup.exe
retention-days: 30
# ─── Linux CPU ──────────────────────────────────────────────
build-linux-cpu:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set build version
run: |
node -e "const fs=require('fs'); const version='${{ needs.prepare.outputs.version }}'; const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=version; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y build-essential
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Build renderer
run: npm run build:renderer
- name: Convert icon to PNG
run: |
mkdir -p build
if command -v convert &> /dev/null; then
convert build/icon.ico[0] build/icon.png
else
sudo apt-get install -y imagemagick && convert build/icon.ico[0] build/icon.png
fi
- name: Verify node-llama-cpp Linux CPU backends
run: |
test -d node_modules/@node-llama-cpp/linux-x64 || (echo "Missing @node-llama-cpp/linux-x64" && exit 1)
test -d node_modules/@node-llama-cpp/linux-x64-vulkan || echo "warn: linux-x64-vulkan not installed (CPU fallback may be limited)"
- name: Build Linux CPU AppImage
run: npx electron-builder --linux --x64 --config electron-builder.nosign.linux.json --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: linux-cpu
path: dist-electron/guIDE-*-cpu-linux-x64.AppImage
retention-days: 30
# ─── Linux CUDA ─────────────────────────────────────────────
build-linux-cuda:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set build version
run: |
node -e "const fs=require('fs'); const version='${{ needs.prepare.outputs.version }}'; const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=version; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y build-essential
- uses: Jimver/cuda-toolkit@v0.2.15
with:
cuda: '12.4.0'
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Build renderer
run: npm run build:renderer
- name: Convert icon to PNG
run: |
mkdir -p build
if command -v convert &> /dev/null; then
convert build/icon.ico[0] build/icon.png
else
sudo apt-get install -y imagemagick && convert build/icon.ico[0] build/icon.png
fi
- name: Verify node-llama-cpp Linux CUDA backends
run: |
test -d node_modules/@node-llama-cpp/linux-x64-cuda || (echo "Missing @node-llama-cpp/linux-x64-cuda" && exit 1)
test -d node_modules/@node-llama-cpp/linux-x64 || echo "warn: linux-x64 CPU fallback not installed"
- name: Build Linux CUDA AppImage
run: npx electron-builder --linux --x64 --config electron-builder.nosign.cuda.linux.json --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: linux-cuda
path: dist-electron/guIDE-*-cuda-linux-x64.AppImage
retention-days: 30
# ─── macOS ──────────────────────────────────────────────────
build-mac:
needs: prepare
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set build version
run: |
node -e "const fs=require('fs'); const version='${{ needs.prepare.outputs.version }}'; const pkg=JSON.parse(fs.readFileSync('package.json','utf8')); pkg.version=version; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');"
- name: Install setuptools (provides distutils for node-gyp)
run: pip install setuptools
- name: Install cmake
run: brew install cmake
- name: Install root dependencies
run: npm ci --ignore-scripts
- name: Install frontend dependencies
run: npm ci
working-directory: frontend
- name: Build renderer
run: npm run build:renderer
- name: Convert icon for macOS
run: |
mkdir -p build
sips -s format png build/icon.ico --out build/icon_src.png 2>/dev/null || cp build/icon.ico build/icon_src.png
sips -z 512 512 build/icon_src.png --out build/icon_512.png
mkdir -p build/icon.iconset
sips -z 16 16 build/icon_512.png --out build/icon.iconset/icon_16x16.png
sips -z 32 32 build/icon_512.png --out build/icon.iconset/icon_16x16@2x.png
sips -z 32 32 build/icon_512.png --out build/icon.iconset/icon_32x32.png
sips -z 64 64 build/icon_512.png --out build/icon.iconset/icon_32x32@2x.png
sips -z 128 128 build/icon_512.png --out build/icon.iconset/icon_128x128.png
sips -z 256 256 build/icon_512.png --out build/icon.iconset/icon_128x128@2x.png
sips -z 256 256 build/icon_512.png --out build/icon.iconset/icon_256x256.png
sips -z 512 512 build/icon_512.png --out build/icon.iconset/icon_256x256@2x.png
cp build/icon_512.png build/icon.iconset/icon_512x512.png
iconutil -c icns build/icon.iconset -o build/icon.icns
- name: Build macOS DMG (CPU, x64 + arm64)
run: npx electron-builder --mac --x64 --arm64 --config electron-builder.nosign.json --publish never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- name: Upload artifact
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: mac-cpu
path: dist-electron/guIDE-*-cpu-mac-*.dmg
retention-days: 30
# ─── GitHub Release ─────────────────────────────────────────
release:
needs: [prepare, build-windows-cpu, build-windows-cuda, build-linux-cpu, build-linux-cuda, build-mac]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts
run: find artifacts -type f | sort
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare.outputs.release_tag }}
files: |
artifacts/windows-cpu/*
artifacts/windows-cuda/*
artifacts/linux-cpu/*
artifacts/linux-cuda/*
artifacts/mac-cpu/*
fail_on_unmatched_files: false
draft: false
prerelease: false
make_latest: true
generate_release_notes: true
name: ${{ needs.prepare.outputs.release_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}