|
| 1 | +# Automated updates |
| 2 | + |
| 3 | +This document describes how Cmdr checks for and installs updates automatically. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Cmdr uses Tauri's built-in updater plugin to deliver updates: |
| 8 | + |
| 9 | +1. App checks for updates on startup and every 60 minutes |
| 10 | +2. If an update is available, it downloads silently in the background |
| 11 | +3. User sees a "Restart to update" notification when ready |
| 12 | +4. Clicking restart applies the update and relaunches the app |
| 13 | + |
| 14 | +Updates are signed with Ed25519 to ensure authenticity. The app won't install anything that doesn't match the embedded public key. |
| 15 | + |
| 16 | +## Architecture |
| 17 | + |
| 18 | +``` |
| 19 | +┌─────────────────────────────────────────────────────────────────────┐ |
| 20 | +│ Update flow │ |
| 21 | +├─────────────────────────────────────────────────────────────────────┤ |
| 22 | +│ │ |
| 23 | +│ ┌─────────────────┐ ┌─────────────────┐ ┌───────────────┐ │ |
| 24 | +│ │ GitHub Actions │────▶│ GitHub │────▶│ getcmdr.com │ │ |
| 25 | +│ │ (build+sign) │ │ Releases │ │ /latest.json │ │ |
| 26 | +│ └─────────────────┘ └─────────────────┘ └───────┬───────┘ │ |
| 27 | +│ │ │ |
| 28 | +│ ▼ │ |
| 29 | +│ ┌───────────────────────────────────────────────────────────────┐ │ |
| 30 | +│ │ Cmdr app │ │ |
| 31 | +│ │ 1. Fetches latest.json │ │ |
| 32 | +│ │ 2. Compares versions │ │ |
| 33 | +│ │ 3. Downloads .tar.gz from GitHub Releases │ │ |
| 34 | +│ │ 4. Verifies Ed25519 signature │ │ |
| 35 | +│ │ 5. Shows "Restart to update" notification │ │ |
| 36 | +│ └───────────────────────────────────────────────────────────────┘ │ |
| 37 | +│ │ |
| 38 | +└─────────────────────────────────────────────────────────────────────┘ |
| 39 | +``` |
| 40 | + |
| 41 | +## Update manifest |
| 42 | + |
| 43 | +The app fetches `https://getcmdr.com/latest.json` to check for updates: |
| 44 | + |
| 45 | +```json |
| 46 | +{ |
| 47 | + "version": "0.3.1", |
| 48 | + "notes": "### Added\n- New feature...", |
| 49 | + "pub_date": "2026-01-14T00:54:48Z", |
| 50 | + "platforms": { |
| 51 | + "darwin-universal": { |
| 52 | + "signature": "base64-encoded-ed25519-signature", |
| 53 | + "url": "https://github.com/vdavid/cmdr/releases/download/v0.3.1/Cmdr_universal.app.tar.gz" |
| 54 | + }, |
| 55 | + "darwin-aarch64": { ... }, |
| 56 | + "darwin-x86_64": { ... } |
| 57 | + } |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +All three macOS platforms point to the same universal binary. This ensures both Apple Silicon and Intel Macs find a matching update. |
| 62 | + |
| 63 | +## Implementation |
| 64 | + |
| 65 | +### Frontend (`apps/desktop/src/lib/updater.svelte.ts`) |
| 66 | + |
| 67 | +The updater service manages the update lifecycle: |
| 68 | + |
| 69 | +| Export | Description | |
| 70 | +|------------------------|-----------------------------------------------------------------------| |
| 71 | +| `startUpdateChecker()` | Starts checking on launch and every 60 min. Returns cleanup function. | |
| 72 | +| `checkForUpdates()` | Manually triggers an update check | |
| 73 | +| `getUpdateState()` | Returns current state: `idle`, `checking`, `downloading`, or `ready` | |
| 74 | +| `restartToUpdate()` | Relaunches the app to apply the downloaded update | |
| 75 | + |
| 76 | +### UI (`apps/desktop/src/lib/UpdateNotification.svelte`) |
| 77 | + |
| 78 | +A toast notification that appears in the bottom-right corner when an update is ready. Shows "Restart to update" with a button to trigger the restart. |
| 79 | + |
| 80 | +### Configuration |
| 81 | + |
| 82 | +**Production** (`tauri.conf.json`): |
| 83 | +```json |
| 84 | +"plugins": { |
| 85 | + "updater": { |
| 86 | + "endpoints": ["https://getcmdr.com/latest.json"], |
| 87 | + "pubkey": "base64-encoded-public-key" |
| 88 | + } |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +**Development** (`tauri.dev.json`): |
| 93 | +```json |
| 94 | +"plugins": { |
| 95 | + "updater": { |
| 96 | + "endpoints": ["http://localhost:4321/latest.json"] |
| 97 | + } |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +### Capabilities |
| 102 | + |
| 103 | +The updater requires these permissions in `capabilities/default.json`: |
| 104 | +- `updater:default` — allows checking and downloading updates |
| 105 | +- `process:allow-restart` — allows relaunching the app |
| 106 | + |
| 107 | +## Release workflow |
| 108 | + |
| 109 | +When you push a version tag (for example, `v0.3.2`), the GitHub Actions release workflow: |
| 110 | + |
| 111 | +1. Builds a universal macOS binary (aarch64 + x86_64) |
| 112 | +2. Signs the `.app.tar.gz` with Ed25519 using `TAURI_SIGNING_PRIVATE_KEY` |
| 113 | +3. Uploads artifacts to GitHub Releases |
| 114 | +4. Updates `apps/website/public/latest.json` with the new version and signature |
| 115 | +5. Triggers a website deploy so the manifest is live |
| 116 | + |
| 117 | +See [Releasing guide](../guides/releasing.md) for step-by-step instructions. |
| 118 | + |
| 119 | +## Logging |
| 120 | + |
| 121 | +The updater logs to the backend via `feLog()`. Example output: |
| 122 | + |
| 123 | +``` |
| 124 | +[updater] Started (endpoint: getcmdr.com) |
| 125 | +[updater] Checking for updates (current: v0.3.0)... |
| 126 | +[updater] Update available: v0.3.0 → v0.3.1 |
| 127 | +[updater] v0.3.1 downloaded, restart to apply |
| 128 | +``` |
| 129 | + |
| 130 | +On error: |
| 131 | +``` |
| 132 | +[updater] Check failed: Download request failed with status: 404 Not Found |
| 133 | +``` |
| 134 | + |
| 135 | +## Local testing |
| 136 | + |
| 137 | +To test updates locally without deploying: |
| 138 | + |
| 139 | +1. Start the website dev server (serves `latest.json`): |
| 140 | + ```bash |
| 141 | + cd apps/website && pnpm dev |
| 142 | + ``` |
| 143 | + |
| 144 | +2. Edit `apps/website/public/latest.json` — set a version higher than your local build |
| 145 | + |
| 146 | +3. Run the app in dev mode: |
| 147 | + ```bash |
| 148 | + cd apps/desktop && pnpm tauri dev |
| 149 | + ``` |
| 150 | + |
| 151 | +4. The app checks `localhost:4321/latest.json` and shows the update notification |
| 152 | + |
| 153 | +Note: The actual download will fail locally since there's no signed artifact. This flow is useful for testing the detection and UI. |
| 154 | + |
| 155 | +## Security |
| 156 | + |
| 157 | +- **Signature verification**: Every update is verified against the embedded Ed25519 public key before installation |
| 158 | +- **HTTPS**: Production endpoint uses HTTPS |
| 159 | +- **No downgrade**: Tauri won't install older versions by default |
| 160 | +- **Signed releases**: Only CI can sign releases (private key is a GitHub secret) |
0 commit comments