|
1 | 1 | # Build and release |
2 | 2 |
|
3 | | -This document covers **production builds**, **Windows installers**, and optional **bundled sidecars** (`sift-backend`, `llama-server`). |
| 3 | +This document covers **production builds**, **Windows installers**, the **Node.js |
| 4 | +backend sidecar**, and the **GitHub Actions release workflow**. |
4 | 5 |
|
5 | 6 | ## Development vs production |
6 | 7 |
|
7 | | -| Mode | UI | Backend | Tauri | |
8 | | -| --------------- | --------------- | -------------------- | ---------------------------------------- | |
9 | | -| `npm run dev` | Vite on :1420 | `ts-node` | `tauri dev` | |
10 | | -| `npm run build` | `frontend/dist` | `backend/dist` (tsc) | `tauri build` release binary + installer | |
| 8 | +| Mode | UI | Backend | Tauri | |
| 9 | +| ---- | -- | ------- | ----- | |
| 10 | +| `node sift.mjs run` | Vite on :1420 | `ts-node` (runs separately) | `tauri dev` — connects to Vite | |
| 11 | +| `tauri build` (release) | `frontend/dist` embedded | `sift-backend-*.exe` sidecar | Full native bundle + NSIS installer | |
11 | 12 |
|
12 | | -## Root production build |
| 13 | +In **development** the backend is a separate process you manage via `npm start`. |
| 14 | +In **production** Tauri spawns the pre-bundled backend sidecar automatically on |
| 15 | +startup and kills it when the app exits. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Step-by-step: build a Windows installer locally |
| 20 | + |
| 21 | +> You need a **Windows machine** (or `windows-latest` CI runner) for the final |
| 22 | +> `tauri build` step. The backend sidecar must be compiled targeting Windows. |
| 23 | +
|
| 24 | +### 1. Install all dependencies |
| 25 | + |
| 26 | +```bash |
| 27 | +node sift.mjs deps |
| 28 | +``` |
| 29 | + |
| 30 | +### 2. Bundle the backend sidecar |
| 31 | + |
| 32 | +```bash |
| 33 | +node sift.mjs package |
| 34 | +# or: cd backend && npm run package |
| 35 | +``` |
| 36 | + |
| 37 | +This runs `tsc` then `pkg` and writes: |
| 38 | + |
| 39 | +```powershell |
| 40 | +src-tauri/binaries/sift-backend-x86_64-pc-windows-msvc.exe |
| 41 | +``` |
| 42 | + |
| 43 | +Tauri requires the binary to end with the Rust target triple. `pkg` bundles |
| 44 | +Node.js 18 + all JS/TS dependencies into a single `.exe`. |
| 45 | + |
| 46 | +> **`better-sqlite3` note:** `pkg` bundles the prebuilt `.node` native addon as |
| 47 | +> an asset (configured in `backend/package.json` under `pkg.assets`). If the |
| 48 | +> build fails on a native module, make sure `npm ci` ran in `backend/` first so |
| 49 | +> the correct Windows prebuilt is present in `node_modules`. |
| 50 | +
|
| 51 | +### 3. Build the frontend |
13 | 52 |
|
14 | 53 | ```bash |
15 | 54 | npm run build --prefix frontend |
16 | | -npm run build --prefix backend |
| 55 | +``` |
| 56 | + |
| 57 | +### 4. Run `tauri build` |
| 58 | + |
| 59 | +```bash |
17 | 60 | cross-env CI=false npx tauri build |
18 | 61 | ``` |
19 | 62 |
|
20 | | -The root `npm run build` runs the same steps. **`CI=false`** avoids a known issue where `CI=1` in some environments makes the Tauri CLI reject `--ci` parsing. |
| 63 | +Or from the root: |
| 64 | + |
| 65 | +```bash |
| 66 | +npm run build |
| 67 | +``` |
| 68 | + |
| 69 | +The NSIS installer is written to: |
| 70 | + |
| 71 | +```powershell |
| 72 | +src-tauri/target/release/bundle/nsis/Sift_<version>_x64-setup.exe |
| 73 | +``` |
21 | 74 |
|
22 | | -Artifacts (paths vary by OS): |
| 75 | +--- |
23 | 76 |
|
24 | | -- **macOS:** `.app`, `.dmg` (if configured) |
25 | | -- **Windows:** `.exe` installer (NSIS per `tauri.conf.json`) |
| 77 | +## GitHub Actions — automated Windows release |
26 | 78 |
|
27 | | -See `src-tauri/tauri.conf.json` → `bundle` for targets (`nsis`, icons, etc.). |
| 79 | +Workflow: [`.github/workflows/release.yml`](../.github/workflows/release.yml) |
28 | 80 |
|
29 | | -## Node sidecar with `pkg` |
| 81 | +### Triggering a release |
30 | 82 |
|
31 | | -The backend can be compiled to a standalone executable for bundling next to the Tauri app: |
| 83 | +Push a version tag: |
32 | 84 |
|
33 | 85 | ```bash |
34 | | -cd backend |
35 | | -npm run build |
36 | | -npm run package |
| 86 | +git tag v0.2.0 |
| 87 | +git push origin v0.2.0 |
37 | 88 | ``` |
38 | 89 |
|
39 | | -This uses **`pkg`** and writes output under `src-tauri/binaries/` (see `backend/package.json`). Targets are Windows-oriented by default; adjust `pkg` `targets` for other platforms if needed. |
| 90 | +The `release.yml` workflow runs on `windows-latest` and: |
| 91 | + |
| 92 | +1. Installs Node 18 + all npm deps |
| 93 | +2. Builds frontend (`vite build`) |
| 94 | +3. Bundles backend sidecar with `pkg` → `src-tauri/binaries/` |
| 95 | +4. Verifies the `.exe` exists and prints its size |
| 96 | +5. Runs `npx tauri build` (with `CI=false`) |
| 97 | +6. Uploads the NSIS `.exe` as a **GitHub Release asset** (auto-generated release notes) |
| 98 | +7. Also saves the installer as a workflow **artifact** (30-day retention) for non-tag builds |
40 | 99 |
|
41 | | -## `llama-server` and `externalBin` |
| 100 | +### Manual test build (no tag needed) |
42 | 101 |
|
43 | | -For a fully offline setup, bundle **llama.cpp** `llama-server` (or your chosen inference binary) and register it in Tauri: |
| 102 | +Go to **Actions → Release — Windows installer → Run workflow** on GitHub and trigger |
| 103 | +it manually. The installer will be available as a downloadable artifact. |
44 | 104 |
|
45 | | -1. Place binaries under `src-tauri/binaries/` with names expected by Tauri (see [Tauri external binaries](https://v2.tauri.app/develop/sidecar/)). |
46 | | -2. Set `bundle.externalBin` in `src-tauri/tauri.conf.json`. |
47 | | -3. Match **capabilities** for `shell` / sidecar spawn if you launch them from Rust. |
| 105 | +### Optional: code-signing |
48 | 106 |
|
49 | | -The repository ships with **`externalBin`: []** so local development does not require those files. Enable them when you are ready to ship Windows installers. |
| 107 | +Set these repository secrets to sign the installer: |
| 108 | + |
| 109 | +| Secret | Value | |
| 110 | +| ------ | ----- | |
| 111 | +| `TAURI_SIGNING_PRIVATE_KEY` | PEM-encoded private key from `tauri signer generate` | |
| 112 | +| `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` | Key password (can be empty) | |
| 113 | + |
| 114 | +Unsigned builds work fine for internal distribution but Windows Defender SmartScreen |
| 115 | +will warn users on first run. |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## Sidecar lifecycle (production) |
| 120 | + |
| 121 | +The Rust code in `src-tauri/src/lib.rs` handles the backend sidecar automatically: |
| 122 | + |
| 123 | +- **Startup** (`setup()`): spawns `sift-backend` and polls `GET /health` for up to |
| 124 | + 15 seconds before the UI loads. |
| 125 | +- **Tray → Quit**: kills the child process before calling `app.exit(0)`. |
| 126 | +- **Dev builds** (`cargo build` / `tauri dev`): sidecar code is compiled out via |
| 127 | + `#[cfg(not(debug_assertions))]` — the backend runs separately as usual. |
| 128 | + |
| 129 | +--- |
50 | 130 |
|
51 | 131 | ## Icons |
52 | 132 |
|
53 | | -Icons are generated from `img/sift-icon.svg`: |
| 133 | +Regenerate all icon sizes from the master SVG: |
54 | 134 |
|
55 | 135 | ```bash |
56 | 136 | cd src-tauri |
57 | 137 | npx @tauri-apps/cli icon ../img/sift-icon.svg |
58 | 138 | ``` |
59 | 139 |
|
| 140 | +--- |
| 141 | + |
60 | 142 | ## Version bumps |
61 | 143 |
|
62 | | -- **`package.json`** (root, frontend, backend) — semantic version for JS packages. |
63 | | -- **`src-tauri/tauri.conf.json`** — `version` for the bundled app. |
64 | | -- **`src-tauri/Cargo.toml`** — `version` for the Rust crate (keep in sync with Tauri config for clarity). |
| 144 | +Update all three in sync before tagging: |
| 145 | + |
| 146 | +| File | Field | |
| 147 | +| ---- | ----- | |
| 148 | +| `src-tauri/tauri.conf.json` | `"version"` | |
| 149 | +| `src-tauri/Cargo.toml` | `version` | |
| 150 | +| Root `package.json` | `"version"` | |
| 151 | + |
| 152 | +--- |
65 | 153 |
|
66 | 154 | ## Related docs |
67 | 155 |
|
68 | 156 | - [Installation](INSTALLATION.md) |
69 | | -- [Transform summary](Transform-Summary.md) |
| 157 | +- [Development](DEVELOPMENT.md) |
| 158 | +- [Configuration](CONFIGURATION.md) |
0 commit comments