Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 80 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
# KIVI_GITHUB_CLIENT_ID the GitHub App's Client ID (Iv23…)
# KIVI_GITHUB_APP_SLUG its URL name (github.com/apps/<slug>)
# KIVI_GITLAB_CLIENT_ID the gitlab.com OAuth application's ID (device flow)
# KIVI_UPDATER_PUBKEY the public half of the update signing key (the .pub file
# from `cargo tauri signer generate`); without it the build
# has in-app updates off
# KIVI_UPDATE_REPO owner/repo whose releases the app follows (default XyleMora/KiVi)
# and these repository secrets, to sign the update files (without them the release
# has no latest.json, so no updates):
# TAURI_SIGNING_PRIVATE_KEY, TAURI_SIGNING_PRIVATE_KEY_PASSWORD

name: CI

Expand Down Expand Up @@ -57,6 +64,8 @@ jobs:
gjs -m tests/gitlab.js
gjs -m tests/diff.js
gjs -m tests/nets.js
gjs -m tests/updates.js
python3 -m unittest tests/test_update_manifest.py

- name: Parse and render all KiCad demos
run: gjs -m tests/run.js
Expand Down Expand Up @@ -135,8 +144,20 @@ jobs:
KIVI_GITHUB_CLIENT_ID: ${{ vars.KIVI_GITHUB_CLIENT_ID }}
KIVI_GITHUB_APP_SLUG: ${{ vars.KIVI_GITHUB_APP_SLUG }}
KIVI_GITLAB_CLIENT_ID: ${{ vars.KIVI_GITLAB_CLIENT_ID }}
KIVI_UPDATE_REPO: ${{ vars.KIVI_UPDATE_REPO }}
KIVI_UPDATER_PUBKEY: ${{ vars.KIVI_UPDATER_PUBKEY }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
APPIMAGE_EXTRACT_AND_RUN: "1" # the AppImage tooling runs without FUSE
run: cargo tauri build
run: |
# Update files (.sig next to each) only when the signing key is set, so
# builds without it (forks, local) still work. The tauri CLI reads the public
# key from the config, so it's handed over here instead of kept in the file.
args=()
if [ -n "$TAURI_SIGNING_PRIVATE_KEY" ] && [ -n "$KIVI_UPDATER_PUBKEY" ]; then
args+=(--config "$(python3 tools/updater_config.py)")
fi
cargo tauri build ${args[@]+"${args[@]}"}

# The AppImage carries this runner's GTK/WebKitGTK libraries; their
# licences and sources are published next to it.
Expand All @@ -148,6 +169,7 @@ jobs:
name: kivi-linux
path: |
src-tauri/target/release/bundle/appimage/*.AppImage
src-tauri/target/release/bundle/appimage/*.AppImage.sig
src-tauri/target/release/bundle/appimage/appimage-libraries.md
if-no-files-found: error

Expand Down Expand Up @@ -185,6 +207,8 @@ jobs:
KIVI_GITHUB_CLIENT_ID: ${{ vars.KIVI_GITHUB_CLIENT_ID }}
KIVI_GITHUB_APP_SLUG: ${{ vars.KIVI_GITHUB_APP_SLUG }}
KIVI_GITLAB_CLIENT_ID: ${{ vars.KIVI_GITLAB_CLIENT_ID }}
KIVI_UPDATE_REPO: ${{ vars.KIVI_UPDATE_REPO }}
KIVI_UPDATER_PUBKEY: ${{ vars.KIVI_UPDATER_PUBKEY }}
run: cargo tauri build --no-bundle

- name: Name the .exe after the version
Expand All @@ -193,13 +217,29 @@ jobs:
$version = (Get-Content src-tauri/tauri.conf.json -Raw | ConvertFrom-Json).version
Copy-Item src-tauri/target/release/kivi-desktop.exe "KiVi_${version}_x64.exe"

# The in-app updater downloads this very file and checks its signature, so it
# is signed here (no installer: Tauri's updater artifacts are for those).
# --app-version binds the signature to the version, which the app requires.
# Skipped without the key (key and password come from the environment).
- name: Sign the .exe for in-app updates
shell: pwsh
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: |
if (-not $env:TAURI_SIGNING_PRIVATE_KEY) { Write-Host "No signing key: not signing for updates"; exit 0 }
$version = (Get-Content src-tauri/tauri.conf.json -Raw | ConvertFrom-Json).version
cargo tauri signer sign --app-version $version "KiVi_${version}_x64.exe"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

# The licences go next to the .exe (and so into the release): the
# AppImage carries them inside, a bare .exe can't.
- uses: actions/upload-artifact@v4
with:
name: kivi-windows
path: |
KiVi_*_x64.exe
KiVi_*_x64.exe.sig
LICENSE
THIRD-PARTY-NOTICES.md
if-no-files-found: error
Expand Down Expand Up @@ -241,12 +281,38 @@ jobs:
KIVI_GITHUB_CLIENT_ID: ${{ vars.KIVI_GITHUB_CLIENT_ID }}
KIVI_GITHUB_APP_SLUG: ${{ vars.KIVI_GITHUB_APP_SLUG }}
KIVI_GITLAB_CLIENT_ID: ${{ vars.KIVI_GITLAB_CLIENT_ID }}
run: cargo tauri build --target universal-apple-darwin
KIVI_UPDATE_REPO: ${{ vars.KIVI_UPDATE_REPO }}
KIVI_UPDATER_PUBKEY: ${{ vars.KIVI_UPDATER_PUBKEY }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
run: |
# With the signing key set, also build the .app and its signed
# KiVi.app.tar.gz, which the in-app updater downloads (a .dmg alone
# makes no updater file). Without it: the .dmg only, as before.
args=()
if [ -n "$TAURI_SIGNING_PRIVATE_KEY" ] && [ -n "$KIVI_UPDATER_PUBKEY" ]; then
args+=(--bundles app,dmg --config "$(python3 tools/updater_config.py)")
fi
cargo tauri build --target universal-apple-darwin ${args[@]+"${args[@]}"}

# The updater file is named like the .dmg (version and arch) so it can sit
# in the release next to it.
- name: Name the updater files after the version
run: |
macos=src-tauri/target/universal-apple-darwin/release/bundle/macos
if [ -f "$macos/KiVi.app.tar.gz.sig" ]; then
version=$(python3 -c 'import json; print(json.load(open("src-tauri/tauri.conf.json"))["version"])')
cp "$macos/KiVi.app.tar.gz" "$macos/KiVi_${version}_universal.app.tar.gz"
cp "$macos/KiVi.app.tar.gz.sig" "$macos/KiVi_${version}_universal.app.tar.gz.sig"
fi

- uses: actions/upload-artifact@v4
with:
name: kivi-macos
path: src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
path: |
src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg
src-tauri/target/universal-apple-darwin/release/bundle/macos/KiVi_*_universal.app.tar.gz
src-tauri/target/universal-apple-darwin/release/bundle/macos/KiVi_*_universal.app.tar.gz.sig
if-no-files-found: error

release:
Expand Down Expand Up @@ -282,7 +348,18 @@ jobs:
git -C src archive --format=tar.gz --prefix="KiVi-${version}/" \
-o "$PWD/bundles/source/KiVi_${version}_source.tar.gz" "${tree:-HEAD}"

# The updater's feed (latest.json) from the signed files; nothing is written
# (and the release has no updates) when no signing key was set. The
# signatures are only read here, not published.
- name: Updater feed
run: |
python3 src/tools/update_manifest.py bundles "$GITHUB_REF_NAME" "$GITHUB_REPOSITORY"
find bundles -name '*.sig' -delete

- uses: softprops/action-gh-release@v2
with:
files: bundles/**/*
generate_release_notes: true
# A tag with a suffix (v0.2.1-macos1) is a pre-release, which
# releases/latest, and so the in-app updater, skips.
prerelease: ${{ contains(github.ref_name, '-') }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ src-tauri/target/
src-tauri/gen/
tests/kicad-demos/
*.tmp.png

# macOS
.DS_Store
75 changes: 72 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,71 @@ cargo tauri build # release + AppImage: src-tauri/target/release/b
colours in the file or extend the mapping. `python3 tools/make_icons.py`
renders `src-tauri/icons/*.png` from it; rerun that after editing the logo.

## Updates

In-app updates (user guide: `docs/README.md` → Updates). The app follows the
latest GitHub release of one repository and replaces itself.

- **Build-time settings** (CI sets them from repository variables/secrets):
`KIVI_UPDATE_REPO` (`owner/repo`, default `XyleMora/KiVi`; the fork
`budenga/KiVi` sets it), `KIVI_UPDATER_PUBKEY` (the `.pub` file's contents).
**No public key at build time ⇒ the updater plugin isn't registered** and
every command says updates are off (local builds, `cargo tauri dev` without
the variable). Each repository has its own minisign key
(`cargo tauri signer generate`); the private key and password are the Actions
secrets `TAURI_SIGNING_PRIVATE_KEY`(`_PASSWORD`). Never print or commit the
private key. Losing it = users must update by hand once.
- **Feed**: `https://github.com/<repo>/releases/latest/download/latest.json`
(no REST API, so no 60/h limit), read from Rust, so the CSP is untouched.
`releases/latest` skips pre-releases, and CI publishes tags containing `-` as
pre-releases. `tools/update_manifest.py bundles/ <tag> <repo>` writes the feed
in the release job: all four platform entries or nothing (no `.sig` files = no
file, exit 0; some missing = failure, since the plugin rejects a feed with an
incomplete entry). `tests/test_update_manifest.py` covers it.
- **Rust** (`src-tauri/src/update.rs`, `tauri-plugin-updater` 2.14): commands
`update_info`, `update_check` (keeps the `Update` in `Pending`), `update_install`
(downloads, emits `update-progress`, installs, restarts); `tauri.conf.json` holds an
empty `plugins.updater` only because the plugin fails to start without that
section (its `pubkey` has no default); the real key is passed from Rust, and
`requireSignedVersion` is on (a signature must carry the version the feed announces,
which stops a doctored feed from pairing a new version with an old file;
`tauri build` records it, and CI passes `--app-version` when signing the .exe).
The restart is core `AppHandle::restart`, so there's no process plugin.
- Linux: only from an AppImage (`$APPIMAGE`, which is also given to the plugin
as the file to replace: `current_exe()` is inside the temporary mount) in a
writable folder; the plugin swaps the plain AppImage (no tar.gz).
- macOS: the plugin swaps the `.app` from a signed `KiVi.app.tar.gz`; needs a
`.app` in a writable folder. A `dmg`-only build makes no updater file, so CI
adds `--bundles app,dmg` when signing; the file is renamed
`KiVi_<v>_universal.app.tar.gz`, one entry for both architectures.
- Windows: the plugin's `install()` would run the file as an installer, so only
`download()` (which verifies) is used and `replace_exe` renames the running
exe to `.exe.old`, moves `.exe.new` in (rolled back if that fails) and starts
the new file by its real path (after the rename the process's own path may read
as `.old`, which is what `restart()` would launch); `.old` is deleted at the
next start (`update::cleanup`). The exe is signed in CI by `cargo tauri signer sign`.
- A debug build (`cargo tauri dev`) never installs ("Development build"): the
dialog offers the release page.
- **JS**: `src/desktop/updates.js` (timers, requests, dialog `#update-dialog`) and
`update-check.js` (pure: `shouldCheck`, `visibleUpdate`, `isNewer`; separate
because `tauri.js` needs `window` and `tests/updates.js` runs under gjs). Checks
10 s after load, every 6 h, and on focus when due; the last successful result is
shared by the pages in localStorage `kivi.updateCheck` (a failure is never
stored, only `console.warn`ed, retried after 5 min). Settings `checkUpdates`
(default on; off = no automatic requests) and `updateSkip`. The dot and the
first menu item live in `account.js`. Updating re-runs `update_check` first,
since the Rust side forgets the found update on restart.
- **Tested here (macOS, no gjs)**: `cargo test` (`replace_exe` incl. rollback, bundle
and reason helpers), `tests/test_update_manifest.py`, `tests/updates.js` (also run
under Node with `print` shimmed), the plugin's behaviour read from its source
, a local macOS build with a throwaway key for the file names.
- **Tested on the fork `budenga/KiVi`** (2026-11-18): CI with its key built and signed
all three platforms and published `v0.2.90` with a complete `latest.json`; on macOS
(Apple Silicon) a local 0.1.0 `.app` in `~/Applications`, built with the fork's
`KIVI_UPDATE_REPO`/`KIVI_UPDATER_PUBKEY`, showed the dot, updated itself and restarted
as 0.2.90. **Not run yet**: a real update on Linux (AppImage), Windows (`replace_exe`
has never run outside `cargo test`) and Intel macOS.

## Licence

GPL-3.0-or-later (`LICENSE`; `license` in `Cargo.toml` and `tauri.conf.json`).
Expand All @@ -544,6 +609,8 @@ gjs -m tests/nets.js
gjs -m tests/review.js # GitHub adapter and forge interface, mocked
gjs -m tests/gitlab.js # GitLab adapter, mocked
gjs -m tests/models.js # 3D model path resolution order
gjs -m tests/updates.js # update check throttle, skip, switched off
python3 -m unittest tests/test_update_manifest.py # the updater's latest.json writer
cargo test --manifest-path src-tauri/Cargo.toml --lib # Rust: model folders, git (needs dist/web)
tests/smoke.sh # pages load cleanly, viewer opens pic_programmer (~15 s)
```
Expand Down Expand Up @@ -670,8 +737,8 @@ requests: `tools/screenshots-prelude.js` (after `tests/tauri-mock.js`) mocks
click a change, then zoom with `kiviDiff.after.zoomTo(c.after, mm)` or
`(c.boxesAfter[0], mm)`.

The real `XyleMora/KiVi` and `cm5_minima_test_repo` aren't publicly readable
(API 404 signed out, checked 2026-10-30), so the README's quick start uses
`XyleMora/KiVi` is publicly readable (checked 2026-11-16); `cm5_minima_test_repo`
isn't (API 404 signed out, checked 2026-10-30). The README's quick start uses
`greatscottgadgets/hackrf` (public, `hardware/hackrf-one/hackrf-one.kicad_pro`).

## Test data
Expand All @@ -695,4 +762,6 @@ The real `XyleMora/KiVi` and `cm5_minima_test_repo` aren't publicly readable
- Tokens are in localStorage, not the OS keychain.
- No text merge of a file changed on both sides (on purpose: KiCad files
don't merge reliably); Pull offers moving the commits to a new branch instead.
- No auto-update, code signing or file associations.
- No code signing, notarisation or file associations.
- In-app updates: a real update has only run on Apple Silicon macOS; Linux,
Windows and Intel macOS are untested (see Updates).
Loading
Loading