Skip to content

Commit 0a72543

Browse files
committed
feat(launcher): add the Electron launcher as a preview
Add launcher/, a desktop launcher for LocalAI written with Electron, TypeScript and React. It installs and updates the LocalAI server (the download is checked against the release checksum file and a download without a valid checksum is not installed), starts and stops it, shows its log, and shows the server's WebUI in the same window under a small status bar. It uses the shared @localai/ui-kit package. It updates itself from GitHub Releases and can offer release candidates and the development channel. It ships as a preview beside the Go launcher, with its own file names, until the older launcher is retired. The main process keeps its logic in modules that do not import Electron (supervisor, config store, checksum, atomic install, IPC validation, the WebUI view policy and others) so vitest tests them under plain Node. The IPC contract is one file, and a test fails when the preload or the handler table disagrees with it. The window has context isolation and a sandboxed preload; on systems that forbid unprivileged user namespaces the sandbox is off and the status bar says so. CI: - launcher-electron-build.yaml is a reusable workflow. It builds the AppImage for amd64 and arm64 and the macOS DMG, runs the unit tests, the type check and a smoke test of the packaged app, and keeps the packages as artifacts. It never writes to a release. macOS signing and notarization run only when the secrets exist; otherwise the build is unsigned and says so. - launcher-electron-dev.yaml builds on pull requests (amd64 AppImage, no secrets, read-only token) and on master pushes that change the launcher, the ui-kit package or these workflows. Artifacts are kept for 7 and 14 days. Nothing is published. - launcher-electron-release.yaml is called from release.yaml after GoReleaser, on version tags only. Build jobs have contents: read. Only the upload job has contents: write; it downloads the tested files, checks out no code and only attaches files to the release that GoReleaser made. It never publishes: the release stays a draft until a maintainer publishes it. A last job checks that the update feeds (latest-linux.yml, latest-linux-arm64.yml, latest-mac.yml) name only files that are attached, with matching sizes. The docs describe the preview launcher, the development builds and the Linux sandbox note on the install pages, and the release guide gets the rule to publish a release only after the feed check is green. Verified: npm ci, the type check and the vitest suite of launcher/ (1102 tests), the web UI lint, unit tests and build with the ui-kit package, and yamllint and a YAML parse of the workflows. The packaged app, the macOS signing and the release upload run only on hosted runners and are not exercised by these checks. Assisted-by: Claude Code:claude-sonnet-5-5
1 parent 1361012 commit 0a72543

162 files changed

Lines changed: 36056 additions & 3 deletions

File tree

Some content is hidden

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

‎.agents/preparing-a-release.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ What happens, and what to check:
2626

2727
The development entries in `gallery/addons/index.yaml` are regenerated with `sh scripts/addons/catalog.sh --channel development --repository quay.io/go-skynet/local-ai-addons --out gallery/addons/index.yaml`; they do not need a change per release.
2828

29+
## The desktop launcher and the draft release
30+
31+
Every release carries the Electron launcher and its update feed (`latest-linux.yml`, `latest-linux-arm64.yml`, `latest-mac.yml`). Installed launchers read the feed from the newest published release, so a published release without it makes every launcher report an update error. `.github/workflows/launcher-electron-release.yaml` attaches the files and then checks the feed; it never publishes the release.
32+
33+
1. Push the tag while the release is still a draft.
34+
2. Wait until the `launcher-electron` jobs of the tag's release run are green: the upload and `Check the attached feed`.
35+
3. Publish the release. Do not publish while those jobs are red or still running. A re-run of the tag workflow replaces the launcher files and keeps the version.
36+
2937
## Clip conventions
3038

3139
- MP4, H.264, no audio track unless the feature is about audio. Keep them short (10 to 30 seconds) and loopable.
@@ -36,6 +44,6 @@ The development entries in `gallery/addons/index.yaml` are regenerated with `sh
3644

3745
## Order of work
3846

39-
Label the PRs, generate and edit the release notes, cut the draft release, record the clips while the branch is still fresh in your head, then write the post against the notes and the clips. Publishing the release and merging the post should happen on the same day.
47+
Label the PRs, generate and edit the release notes, cut the draft release (push the tag while it is a draft, and publish only after the launcher feed check is green), record the clips while the branch is still fresh in your head, then write the post against the notes and the clips. Publishing the release and merging the post should happen on the same day.
4048

4149
The `creating-localai-releases` skill drives steps 1 to 3 and captures the React UI screenshots that go into the notes.
Lines changed: 309 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
# Builds, checks and smoke-tests the Electron launcher (launcher/), then keeps
2+
# the packages as workflow artifacts. Called by launcher-electron-release.yaml
3+
# (tags) and launcher-electron-dev.yaml (master, pull requests, manual runs).
4+
# It never writes to a release: the release workflow has a separate upload job.
5+
# See launcher/README.md, "Packaging and CI".
6+
name: Launcher (Electron) build
7+
8+
on:
9+
workflow_call:
10+
inputs:
11+
version:
12+
description: Launcher version (semver), from launcher/scripts/version.mjs
13+
type: string
14+
required: true
15+
artifact-prefix:
16+
description: Prefix of the artifact names (<prefix>-linux-amd64, -linux-arm64, -macos-arm64)
17+
type: string
18+
required: true
19+
linux-arm64:
20+
type: boolean
21+
default: true
22+
macos:
23+
type: boolean
24+
default: true
25+
sign-macos:
26+
description: Sign and notarize the macOS app. Without the secrets, the build is unsigned and says so.
27+
type: boolean
28+
default: false
29+
feed:
30+
description: Keep the update feed files (latest-*.yml), blockmaps and the macOS zip. Releases only.
31+
type: boolean
32+
default: false
33+
preview-names:
34+
description: Give the files the preview names, so they do not replace the files of the older launcher on the same release
35+
type: boolean
36+
default: false
37+
upload:
38+
description: Keep the packages as workflow artifacts
39+
type: boolean
40+
default: true
41+
retention-days:
42+
type: number
43+
default: 7
44+
secrets:
45+
MACOS_CERTIFICATE:
46+
required: false
47+
MACOS_CERTIFICATE_PWD:
48+
required: false
49+
MACOS_NOTARY_KEY:
50+
required: false
51+
MACOS_NOTARY_KEY_ID:
52+
required: false
53+
MACOS_NOTARY_ISSUER_ID:
54+
required: false
55+
56+
permissions:
57+
contents: read
58+
59+
env:
60+
# Electron is downloaded by electron-builder (checked against its SHASUMS256);
61+
# the unit tests do not need the binary.
62+
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
63+
LAUNCHER_VERSION: ${{ inputs.version }}
64+
65+
jobs:
66+
plan:
67+
name: Plan the Linux builds
68+
runs-on: ubuntu-latest
69+
permissions: {}
70+
outputs:
71+
linux: ${{ steps.plan.outputs.linux }}
72+
steps:
73+
- id: plan
74+
env:
75+
ARM64: ${{ inputs.linux-arm64 }}
76+
# amd64 on Ubuntu 22.04, the oldest glibc of the hosted runners. The
77+
# app has no native code of its own, so the runner does not change the
78+
# package; it is where the smoke runs. arm64 on the repository's native
79+
# arm64 runner, so the smoke runs the arm64 image itself.
80+
run: |
81+
amd64='{"arch":"amd64","builder-arch":"x64","runner":"ubuntu-22.04","feed-file":"latest-linux.yml"}'
82+
arm64='{"arch":"arm64","builder-arch":"arm64","runner":"ubuntu-24.04-arm","feed-file":"latest-linux-arm64.yml"}'
83+
if [ "$ARM64" = true ]; then m="[$amd64,$arm64]"; else m="[$amd64]"; fi
84+
echo "linux=$m" >> "$GITHUB_OUTPUT"
85+
echo "$m"
86+
87+
linux:
88+
name: AppImage ${{ matrix.arch }}
89+
needs: plan
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
include: ${{ fromJSON(needs.plan.outputs.linux) }}
94+
runs-on: ${{ matrix.runner }}
95+
permissions:
96+
contents: read
97+
steps:
98+
- uses: actions/checkout@v7
99+
with:
100+
persist-credentials: false
101+
- uses: actions/setup-node@v7
102+
with:
103+
node-version: '22'
104+
cache: npm
105+
cache-dependency-path: launcher/package-lock.json
106+
- name: Install the smoke test tools
107+
run: |
108+
sudo apt-get update
109+
sudo apt-get install -y xvfb xauth
110+
- name: Install, type-check and unit-test
111+
working-directory: launcher
112+
run: |
113+
npm ci
114+
npm run typecheck
115+
npm test
116+
- name: Build the AppImage
117+
working-directory: launcher
118+
env:
119+
PREVIEW: ${{ inputs.preview-names }}
120+
BUILDER_ARCH: ${{ matrix.builder-arch }}
121+
run: |
122+
args=()
123+
if [ "$PREVIEW" = true ]; then
124+
args+=("-c.linux.artifactName=LocalAI-Launcher-Preview-\${arch}.AppImage")
125+
fi
126+
npm run build
127+
npx electron-builder --linux AppImage "--$BUILDER_ARCH" --publish never \
128+
"-c.extraMetadata.version=$LAUNCHER_VERSION" "${args[@]}"
129+
ls -l release
130+
- name: Write the checksum
131+
working-directory: launcher/release
132+
env:
133+
FEED_FILE: ${{ matrix.feed-file }}
134+
run: |
135+
f=$(ls ./*.AppImage)
136+
[ "$(echo "$f" | wc -l)" = 1 ] || { echo "expected one AppImage, got: $f"; exit 1; }
137+
f=$(basename "$f")
138+
sha256sum "$f" > "$f.sha256"
139+
cat "$f.sha256"
140+
grep -q "^version: $LAUNCHER_VERSION$" "$FEED_FILE"
141+
echo "APPIMAGE=$f" >> "$GITHUB_ENV"
142+
# The same smoke for every build. No artifact is kept when it fails.
143+
# FUSE is not installed on the runner: the smoke uses the documented
144+
# fallback --appimage-extract-and-run.
145+
- name: Smoke-test the packaged AppImage
146+
working-directory: launcher
147+
env:
148+
SMOKE_DIR: ${{ runner.temp }}/smoke
149+
SMOKE_SELF_UPDATE: ${{ contains(inputs.version, '-dev.') && 'off' || 'check' }}
150+
run: bash scripts/smoke-packaged.sh "release/$APPIMAGE" --appimage-extract-and-run
151+
- name: Choose the files to keep
152+
if: inputs.upload
153+
working-directory: launcher/release
154+
env:
155+
FEED: ${{ inputs.feed }}
156+
run: |
157+
mkdir -p ../keep
158+
cp "$APPIMAGE" "$APPIMAGE.sha256" ../keep/
159+
if [ "$FEED" = true ]; then
160+
cp ./latest-linux*.yml ../keep/
161+
cp ./*.blockmap ../keep/ 2>/dev/null || true
162+
fi
163+
ls -l ../keep
164+
- uses: actions/upload-artifact@v7
165+
if: inputs.upload
166+
with:
167+
name: ${{ inputs.artifact-prefix }}-linux-${{ matrix.arch }}
168+
path: launcher/keep/
169+
if-no-files-found: error
170+
retention-days: ${{ inputs.retention-days }}
171+
172+
macos:
173+
name: DMG and zip arm64
174+
if: inputs.macos
175+
# GitHub-hosted Apple Silicon runner. It is not shared with other
176+
# repositories, so the build needs no signing lock: the keychain that
177+
# electron-builder makes is gone with the runner.
178+
runs-on: macos-14
179+
permissions:
180+
contents: read
181+
steps:
182+
- uses: actions/checkout@v7
183+
with:
184+
persist-credentials: false
185+
- uses: actions/setup-node@v7
186+
with:
187+
node-version: '22'
188+
cache: npm
189+
cache-dependency-path: launcher/package-lock.json
190+
- name: Install, type-check and unit-test
191+
working-directory: launcher
192+
run: |
193+
npm ci
194+
npm run typecheck
195+
npm test
196+
- name: Prepare signing
197+
id: signing
198+
env:
199+
SIGN: ${{ inputs.sign-macos }}
200+
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
201+
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
202+
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
203+
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
204+
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
205+
run: |
206+
if [ "$SIGN" != true ]; then
207+
echo "Signing is off for this run: the app is not signed or notarized."
208+
echo "signed=false" >> "$GITHUB_OUTPUT"
209+
exit 0
210+
fi
211+
if [ -z "$MACOS_CERTIFICATE" ] || [ -z "$MACOS_NOTARY_KEY" ]; then
212+
# Fallback (forks, or secrets not available): an unsigned build.
213+
echo "::warning::Signing was asked for, but the signing secrets are not available. The DMG is not signed or notarized."
214+
echo "signed=false" >> "$GITHUB_OUTPUT"
215+
exit 0
216+
fi
217+
# electron-builder notarizes with an App Store Connect API key file.
218+
umask 077
219+
echo "$MACOS_NOTARY_KEY" | base64 --decode > "$RUNNER_TEMP/notary-key.p8"
220+
echo "signed=true" >> "$GITHUB_OUTPUT"
221+
- name: Build the DMG and the zip
222+
working-directory: launcher
223+
env:
224+
SIGNED: ${{ steps.signing.outputs.signed }}
225+
PREVIEW: ${{ inputs.preview-names }}
226+
# electron-builder imports the certificate (base64 .p12) into a
227+
# temporary keychain of its own.
228+
CSC_LINK: ${{ steps.signing.outputs.signed == 'true' && secrets.MACOS_CERTIFICATE || '' }}
229+
CSC_KEY_PASSWORD: ${{ steps.signing.outputs.signed == 'true' && secrets.MACOS_CERTIFICATE_PWD || '' }}
230+
APPLE_API_KEY_ID: ${{ steps.signing.outputs.signed == 'true' && secrets.MACOS_NOTARY_KEY_ID || '' }}
231+
APPLE_API_ISSUER: ${{ steps.signing.outputs.signed == 'true' && secrets.MACOS_NOTARY_ISSUER_ID || '' }}
232+
run: |
233+
args=()
234+
if [ "$SIGNED" = true ]; then
235+
export APPLE_API_KEY="$RUNNER_TEMP/notary-key.p8"
236+
else
237+
export CSC_IDENTITY_AUTO_DISCOVERY=false
238+
unset CSC_LINK CSC_KEY_PASSWORD APPLE_API_KEY_ID APPLE_API_ISSUER
239+
fi
240+
if [ "$PREVIEW" = true ]; then
241+
args+=("-c.dmg.artifactName=LocalAI-Launcher-Preview.dmg")
242+
fi
243+
npm run build
244+
npx electron-builder --mac dmg zip --arm64 --publish never \
245+
"-c.extraMetadata.version=$LAUNCHER_VERSION" "${args[@]}"
246+
ls -l release
247+
- name: Remove the notary key
248+
if: always()
249+
run: rm -f "$RUNNER_TEMP/notary-key.p8"
250+
- name: Write the checksums
251+
working-directory: launcher/release
252+
run: |
253+
dmg=$(ls ./*.dmg); zip=$(ls ./*-mac.zip)
254+
dmg=$(basename "$dmg"); zip=$(basename "$zip")
255+
shasum -a 256 "$dmg" > "$dmg.sha256"
256+
shasum -a 256 "$zip" > "$zip.sha256"
257+
cat ./*.sha256
258+
grep -q "^version: $LAUNCHER_VERSION$" latest-mac.yml
259+
{ echo "DMG=$dmg"; echo "ZIP=$zip"; } >> "$GITHUB_ENV"
260+
# Mount the DMG as a user gets it, check the signature and the stapled
261+
# ticket of the app inside it, then run the smoke on that app.
262+
- name: Mount the DMG
263+
working-directory: launcher/release
264+
run: |
265+
mnt="$RUNNER_TEMP/dmg"
266+
mkdir -p "$mnt"
267+
hdiutil attach "$DMG" -nobrowse -readonly -mountpoint "$mnt"
268+
app=$(find "$mnt" -maxdepth 1 -name '*.app' | head -n 1)
269+
[ -n "$app" ] || { echo "no .app in the DMG"; exit 1; }
270+
echo "APP=$app" >> "$GITHUB_ENV"
271+
echo "MNT=$mnt" >> "$GITHUB_ENV"
272+
- name: Check the signature, the entitlements and the stapled ticket
273+
if: steps.signing.outputs.signed == 'true'
274+
run: |
275+
codesign --verify --deep --strict --verbose=2 "$APP"
276+
codesign --display --entitlements - "$APP"
277+
spctl --assess --type execute --verbose=4 "$APP"
278+
xcrun stapler validate "$APP"
279+
- name: Smoke-test the app from the DMG
280+
working-directory: launcher
281+
env:
282+
SMOKE_DIR: ${{ runner.temp }}/smoke
283+
SMOKE_FEED_FILE: release/latest-mac.yml
284+
SMOKE_SELF_UPDATE: ${{ contains(inputs.version, '-dev.') && 'off' || 'check' }}
285+
run: bash scripts/smoke-packaged.sh "$APP"
286+
- name: Unmount the DMG
287+
if: always() && env.MNT != ''
288+
run: hdiutil detach "$MNT" || true
289+
- name: Choose the files to keep
290+
if: inputs.upload
291+
working-directory: launcher/release
292+
env:
293+
FEED: ${{ inputs.feed }}
294+
run: |
295+
mkdir -p ../keep
296+
cp "$DMG" "$DMG.sha256" ../keep/
297+
if [ "$FEED" = true ]; then
298+
# The updater applies the zip; latest-mac.yml names it.
299+
cp "$ZIP" "$ZIP.sha256" latest-mac.yml ../keep/
300+
cp ./*.blockmap ../keep/ 2>/dev/null || true
301+
fi
302+
ls -l ../keep
303+
- uses: actions/upload-artifact@v7
304+
if: inputs.upload
305+
with:
306+
name: ${{ inputs.artifact-prefix }}-macos-arm64
307+
path: launcher/keep/
308+
if-no-files-found: error
309+
retention-days: ${{ inputs.retention-days }}

0 commit comments

Comments
 (0)