feat #14740: updater and release scripts

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hauke
2026-11-06 11:37:57 +01:00
co-authored by Claude Opus 5.5
parent 345dd01147
commit 74511d791a
15 changed files with 1157 additions and 10 deletions
+3
View File
@@ -1,6 +1,9 @@
# Rust # Rust
/target/ /target/
# Release builds (scripts/build-release.sh)
/dist-release/
# UI (Vite/pnpm) # UI (Vite/pnpm)
/ui/node_modules/ /ui/node_modules/
/ui/dist/ /ui/dist/
Generated
+298 -8
View File
@@ -459,6 +459,7 @@ dependencies = [
"tauri-plugin-log", "tauri-plugin-log",
"tauri-plugin-notification", "tauri-plugin-notification",
"tauri-plugin-single-instance", "tauri-plugin-single-instance",
"tauri-plugin-updater",
"tempfile", "tempfile",
] ]
@@ -627,6 +628,16 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "core-foundation"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.10.1" version = "0.10.1"
@@ -650,7 +661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97" checksum = "064badf302c3194842cf2c5d61f56cc88e54a759313879cdf03abdd27d0c3b97"
dependencies = [ dependencies = [
"bitflags 2.13.2", "bitflags 2.13.2",
"core-foundation", "core-foundation 0.10.1",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
"libc", "libc",
@@ -663,7 +674,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb"
dependencies = [ dependencies = [
"bitflags 2.13.2", "bitflags 2.13.2",
"core-foundation", "core-foundation 0.10.1",
"libc", "libc",
] ]
@@ -1175,6 +1186,16 @@ dependencies = [
"rustc_version", "rustc_version",
] ]
[[package]]
name = "filetime"
version = "0.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759"
dependencies = [
"cfg-if",
"libc",
]
[[package]] [[package]]
name = "find-msvc-tools" name = "find-msvc-tools"
version = "0.1.15" version = "0.1.15"
@@ -1839,9 +1860,11 @@ dependencies = [
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"socket2", "socket2",
"system-configuration",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing", "tracing",
"windows-registry",
] ]
[[package]] [[package]]
@@ -2135,6 +2158,36 @@ dependencies = [
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
[[package]]
name = "jni"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"
dependencies = [
"cfg-if",
"combine",
"jni-macros",
"jni-sys 0.4.1",
"log",
"simd_cesu8",
"thiserror 2.0.21",
"walkdir",
"windows-link",
]
[[package]]
name = "jni-macros"
version = "0.22.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3"
dependencies = [
"proc-macro2",
"quote",
"rustc_version",
"simd_cesu8",
"syn 2.0.119",
]
[[package]] [[package]]
name = "jni-sys" name = "jni-sys"
version = "0.3.1" version = "0.3.1"
@@ -2436,6 +2489,12 @@ dependencies = [
"unicase", "unicase",
] ]
[[package]]
name = "minisign-verify"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "871285dc19d8d0ebe0eef3d0e99a205f2a71363b122632cbbfa4a6c370a960ce"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
version = "0.8.9" version = "0.8.9"
@@ -2823,6 +2882,18 @@ dependencies = [
"objc2-core-foundation", "objc2-core-foundation",
] ]
[[package]]
name = "objc2-osa-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f112d1746737b0da274ef79a23aac283376f335f4095a083a267a082f21db0c0"
dependencies = [
"bitflags 2.13.2",
"objc2",
"objc2-app-kit",
"objc2-foundation",
]
[[package]] [[package]]
name = "objc2-quartz-core" name = "objc2-quartz-core"
version = "0.3.2" version = "0.3.2"
@@ -2910,6 +2981,12 @@ version = "1.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "openssl-probe"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1"
[[package]] [[package]]
name = "option-ext" name = "option-ext"
version = "0.2.0" version = "0.2.0"
@@ -2941,6 +3018,20 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "osakit"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "732c71caeaa72c065bb69d7ea08717bd3f4863a4f451402fc9513e29dbd5261b"
dependencies = [
"objc2",
"objc2-foundation",
"objc2-osa-kit",
"serde",
"serde_json",
"thiserror 2.0.21",
]
[[package]] [[package]]
name = "pango" name = "pango"
version = "0.18.3" version = "0.18.3"
@@ -3546,15 +3637,20 @@ dependencies = [
"http-body", "http-body",
"http-body-util", "http-body-util",
"hyper", "hyper",
"hyper-rustls",
"hyper-util", "hyper-util",
"js-sys", "js-sys",
"log", "log",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"rustls",
"rustls-pki-types",
"rustls-platform-verifier",
"serde", "serde",
"serde_json", "serde_json",
"sync_wrapper", "sync_wrapper",
"tokio", "tokio",
"tokio-rustls",
"tokio-util", "tokio-util",
"tower", "tower",
"tower-http", "tower-http",
@@ -3662,6 +3758,18 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "rustls-native-certs"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a073f5dc7469f984c52ad2752b63b0807745133b6de880b7b64c1ac4c48aec4"
dependencies = [
"openssl-probe",
"rustls-pki-types",
"schannel",
"security-framework",
]
[[package]] [[package]]
name = "rustls-pki-types" name = "rustls-pki-types"
version = "1.15.1" version = "1.15.1"
@@ -3672,6 +3780,33 @@ dependencies = [
"zeroize", "zeroize",
] ]
[[package]]
name = "rustls-platform-verifier"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98"
dependencies = [
"core-foundation 0.10.1",
"core-foundation-sys",
"jni 0.22.4",
"log",
"once_cell",
"rustls",
"rustls-native-certs",
"rustls-platform-verifier-android",
"rustls-webpki",
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.61.2",
]
[[package]]
name = "rustls-platform-verifier-android"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f"
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
version = "0.103.16" version = "0.103.16"
@@ -3704,6 +3839,15 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "schannel"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cb23c424d8ee841bb4d813677ca237e2a610067d594fec130f87d6093495ab5"
dependencies = [
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "schemars" name = "schemars"
version = "0.8.22" version = "0.8.22"
@@ -3780,6 +3924,29 @@ dependencies = [
"zbus 4.4.0", "zbus 4.4.0",
] ]
[[package]]
name = "security-framework"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
dependencies = [
"bitflags 2.13.2",
"core-foundation 0.10.1",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "selectors" name = "selectors"
version = "0.38.0" version = "0.38.0"
@@ -4030,6 +4197,22 @@ version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
[[package]]
name = "simd_cesu8"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520"
dependencies = [
"rustc_version",
"simdutf8",
]
[[package]]
name = "simdutf8"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
[[package]] [[package]]
name = "siphasher" name = "siphasher"
version = "1.0.4" version = "1.0.4"
@@ -4241,6 +4424,27 @@ dependencies = [
"syn 3.0.9", "syn 3.0.9",
] ]
[[package]]
name = "system-configuration"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"
dependencies = [
"bitflags 2.13.2",
"core-foundation 0.9.4",
"system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]] [[package]]
name = "system-deps" name = "system-deps"
version = "6.2.2" version = "6.2.2"
@@ -4262,7 +4466,7 @@ checksum = "d5777b06fe6435126ae8d816eba269e050e1e10d302cf5461e9c49eccabc3548"
dependencies = [ dependencies = [
"bitflags 2.13.2", "bitflags 2.13.2",
"block2", "block2",
"core-foundation", "core-foundation 0.10.1",
"core-graphics", "core-graphics",
"crossbeam-channel", "crossbeam-channel",
"dbus", "dbus",
@@ -4272,7 +4476,7 @@ dependencies = [
"gdkwayland-sys", "gdkwayland-sys",
"gdkx11-sys", "gdkx11-sys",
"gtk", "gtk",
"jni", "jni 0.21.1",
"libc", "libc",
"log", "log",
"ndk", "ndk",
@@ -4305,6 +4509,17 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "tar"
version = "0.4.46"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840"
dependencies = [
"filetime",
"libc",
"xattr",
]
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.12.16" version = "0.12.16"
@@ -4328,7 +4543,7 @@ dependencies = [
"gtk", "gtk",
"heck 0.5.0", "heck 0.5.0",
"http", "http",
"jni", "jni 0.21.1",
"libc", "libc",
"log", "log",
"mime", "mime",
@@ -4513,6 +4728,40 @@ dependencies = [
"zbus 5.19.0", "zbus 5.19.0",
] ]
[[package]]
name = "tauri-plugin-updater"
version = "2.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d957abbcb3f9f6c76d22a3a0f012f30880640d0bccb5634d2b12a9937e4c872b"
dependencies = [
"base64 0.23.1",
"dirs 7.0.0",
"flate2",
"futures-util",
"http",
"infer",
"libc",
"log",
"minisign-verify",
"osakit",
"percent-encoding",
"reqwest 0.13.5",
"rustls",
"semver",
"serde",
"serde_json",
"tar",
"tauri",
"tauri-plugin",
"tempfile",
"thiserror 2.0.21",
"time",
"tokio",
"url",
"windows-sys 0.61.2",
"zip",
]
[[package]] [[package]]
name = "tauri-runtime" name = "tauri-runtime"
version = "2.12.2" version = "2.12.2"
@@ -4523,7 +4772,7 @@ dependencies = [
"dpi", "dpi",
"gtk", "gtk",
"http", "http",
"jni", "jni 0.21.1",
"objc2", "objc2",
"objc2-ui-kit", "objc2-ui-kit",
"objc2-web-kit", "objc2-web-kit",
@@ -4546,7 +4795,7 @@ checksum = "e1aa9d8b7a120f879f44fdc1053f7b7dbf416bf0bbc6a72b714dec46b782b52f"
dependencies = [ dependencies = [
"gtk", "gtk",
"http", "http",
"jni", "jni 0.21.1",
"log", "log",
"objc2", "objc2",
"objc2-app-kit", "objc2-app-kit",
@@ -4992,6 +5241,12 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "typed-path"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ce898823d8cd0f028662d2f349694b1af0a5cc9be83f1d213a00d3147445e1e"
[[package]] [[package]]
name = "typeid" name = "typeid"
version = "1.0.3" version = "1.0.3"
@@ -5333,6 +5588,15 @@ dependencies = [
"system-deps", "system-deps",
] ]
[[package]]
name = "webpki-root-certs"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e49d0e65abc00c142e8f9428da991da9f1a250c39be97459901eb12b9b49f62a"
dependencies = [
"rustls-pki-types",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "1.0.11" version = "1.0.11"
@@ -5842,7 +6106,7 @@ dependencies = [
"gtk", "gtk",
"http", "http",
"javascriptcore-rs", "javascriptcore-rs",
"jni", "jni 0.21.1",
"libc", "libc",
"ndk", "ndk",
"objc2", "objc2",
@@ -5888,6 +6152,16 @@ dependencies = [
"pkg-config", "pkg-config",
] ]
[[package]]
name = "xattr"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "963d6fab92d5504b971dc8bd90ca743c2575e590bc8071ea5bc571598667ae08"
dependencies = [
"libc",
"rustix",
]
[[package]] [[package]]
name = "xdg-home" name = "xdg-home"
version = "1.3.0" version = "1.3.0"
@@ -6141,6 +6415,22 @@ dependencies = [
"syn 3.0.9", "syn 3.0.9",
] ]
[[package]]
name = "zip"
version = "9.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23f17fbc870bfac28c6228aed7d6e6df352e26bf7015c4313727e16a7a01ce5e"
dependencies = [
"crc32fast",
"getrandom 0.4.3",
"indexmap 2.14.2",
"libc",
"memchr",
"nix 0.31.3",
"typed-path",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "zlib-rs" name = "zlib-rs"
version = "0.6.8" version = "0.6.8"
+192
View File
@@ -0,0 +1,192 @@
# Releasing Gesprächsrekorder
A release consists of:
- the Windows NSIS installer (per-user, no admin rights), cross-built on Debian,
- the Debian `.deb` and `.AppImage`,
- an updater signature (`.sig`) for each of them,
- `latest.json`, the update feed the installed Windows apps read.
`scripts/build-release.sh` builds all of this locally into `dist-release/<version>/`
(gitignored). It never tags, pushes or publishes anything: tagging and creating the
Gitea release are manual steps (below).
Installed Windows apps check the feed at startup and every 6 hours. If a newer
version exists, the main window shows "Update verfügbar (vX.Y.Z) → Installieren &
neu starten". Installing is only possible while no recording runs and no call is
being processed. The installer then runs in passive mode (progress bar only) and
restarts the app. Debian builds do not update themselves.
## One-time setup
1. **Generate the updater key pair** (once, never again):
```sh
cargo tauri signer generate -w ~/.tauri/call-recorder.key
```
Pick a password. Keep `~/.tauri/call-recorder.key` and its password safe (e.g. in
the password manager) and **never commit it** (the repository is public). If the key
is lost, the installed apps cannot be updated anymore: every user would have to
install a new version by hand.
2. **Public key**: it is already in `src-tauri/tauri.conf.json` under
`plugins.updater.pubkey` (key id `203A35A215098DED`). Change it only if you rotate
the key.
3. **Tools** on the Debian build machine: the rustup toolchain with the
`x86_64-pc-windows-msvc` target, `cargo-xwin`, `makensis` (NSIS), `tauri-cli` 2
(`cargo tauri`), `pnpm`, `jq`.
## Where releases live: `scripts/release.env`
`scripts/release.env` is the single source of truth for the release URLs:
- `RELEASE_BASE_URL`: the Gitea repository,
`https://gitea.euvino.eu/public/call-recorder`. The download URLs in `latest.json`
point to `${RELEASE_BASE_URL}/releases/download/v<version>/<file>`.
- `UPDATE_JSON_URL`: where the app looks for `latest.json`. `build-release.sh` writes
it into `plugins.updater.endpoints` in `src-tauri/tauri.conf.json`.
Do not edit the endpoint in `tauri.conf.json` by hand. Change `release.env`; the next
release build writes the endpoint into `tauri.conf.json`.
The repository and its releases must be readable without logging in: the app
downloads anonymously.
### Hosting the feed: two options
The endpoint is compiled into the app. Changing it only affects versions built after
the change; installed versions keep asking the old URL. So check the URL right after
the first release, before anyone relies on updates.
**A: `latest.json` as a release asset (default)**
```
UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json"
→ https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json
```
Gitea has to redirect `releases/latest/download/<file>` to the newest release (not a
draft, not a pre-release). That cannot be checked before the first release exists.
Check it right after publishing the first release:
```sh
curl -sIL https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json
```
The final status must be `200`. If it is `404`, switch to B and release again.
**B: `latest.json` committed to `master`**
```
UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json"
→ https://gitea.euvino.eu/public/call-recorder/raw/branch/master/latest.json
```
Comment out the A line in `release.env` and uncomment the B line. As the last step of
every release, commit `latest.json` to the repository root (step 8 below).
## Releasing a version
Example: version `0.1.1`. Versions are semantic versions and must be higher than the
installed one.
1. Start from a clean `master` with the tests passing (`cargo test --workspace`).
2. Build (works in fish and bash; without `TAURI_SIGNING_PRIVATE_KEY_PASSWORD` the
script asks for the password):
```sh
env TAURI_SIGNING_PRIVATE_KEY_PATH=$HOME/.tauri/call-recorder.key scripts/build-release.sh 0.1.1
```
The script:
- checks the key and password by signing a probe file, and stops if the key does
not belong to `plugins.updater.pubkey`,
- sets the version in `src-tauri/tauri.conf.json`, `src-tauri/Cargo.toml` and
`ui/package.json` (the build updates `Cargo.lock` too), and writes the endpoint
from `release.env` into `tauri.conf.json`,
- builds the Windows installer (`scripts/build-windows.sh`), the `.deb` and the
`.AppImage`, each with its `.sig`,
- copies them to `dist-release/0.1.1/` under ASCII names (`Gespraechsrekorder_…`)
and writes `latest.json` with `scripts/make-latest-json.sh`.
`TAURI_SIGNING_PRIVATE_KEY` (the key itself or a path) works instead of
`TAURI_SIGNING_PRIVATE_KEY_PATH`.
3. Check `dist-release/0.1.1/`. It should contain:
| File | Purpose |
|------------------------------------------------------|--------------------------------------|
| `Gespraechsrekorder_0.1.1_x64-setup.exe` (+ `.sig`) | Windows installer and update package |
| `Gespraechsrekorder_0.1.1_amd64.deb` (+ `.sig`) | Debian package |
| `Gespraechsrekorder_0.1.1_amd64.AppImage` (+ `.sig`) | Debian AppImage |
| `latest.json` | Update feed |
4. Commit the version bump the script left in the working tree:
```sh
git add src-tauri/tauri.conf.json src-tauri/Cargo.toml Cargo.lock ui/package.json
git commit -m "chore #<wp>: release 0.1.1"
```
5. Tag and push:
```sh
git tag v0.1.1
git push origin master v0.1.1
```
6. Create the release `v0.1.1` for the tag on
<https://gitea.euvino.eu/public/call-recorder/releases/new>. Do not mark it as a
draft or a pre-release, otherwise it is not the "latest" release.
7. Upload **every** file from `dist-release/0.1.1/` as a release asset, including the
`.sig` files and `latest.json`. Keep the file names: `latest.json` points to them.
8. Option B only: once the assets are uploaded, publish the feed:
```sh
cp dist-release/0.1.1/latest.json latest.json
git add latest.json
git commit -m "chore #<wp>: update feed 0.1.1"
git push origin master
```
9. Check the feed:
```sh
curl -sL https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json | jq .
```
(Option B: the `raw/branch/master/latest.json` URL.) It must show the new version,
and the `url` entries must download.
## Checking an update on Windows 11
After publishing 0.1.0 and then 0.1.1:
1. Install 0.1.0 as a normal user and start it.
2. Within a few seconds the main window shows "Update verfügbar (v0.1.1) →
Installieren & neu starten".
3. Start a manual recording: the button is disabled and the banner says "Nach der
laufenden Aufnahme/Verarbeitung möglich". Stop the recording and discard it: the
button is enabled again.
4. Click it: the banner shows the download progress. Then the installer shows only a
progress bar, asks for no admin rights, and the app restarts as 0.1.1. The banner
is gone.
Failed checks (offline, no release yet) are not shown. The log
(`%LOCALAPPDATA%\eu.euvino.callrecorder\logs`) has an Info line `update check failed:
…`.
## Notes
- `scripts/build-windows.sh` alone builds an unsigned test installer without updater
artifacts when no signing key is set.
- `RELEASE_ALLOW_KEY_MISMATCH=1` lets `build-release.sh` build with a key that does
not match `plugins.updater.pubkey`. Use it only to test the pipeline with a throwaway
key. Installed apps reject such a release, so never publish it.
- `latest.json` also lists the AppImage (`linux-x86_64`). The Debian builds do not
check for updates yet.
+147
View File
@@ -0,0 +1,147 @@
#!/usr/bin/env bash
# Builds a signed release of Gesprächsrekorder into dist-release/<version>/:
# the Windows NSIS installer (cross-built via build-windows.sh), the Linux
# deb and AppImage, their updater signatures (.sig) and latest.json.
# Sets <version> in tauri.conf.json, src-tauri/Cargo.toml and
# ui/package.json and leaves those changes for you to commit. Never tags or
# publishes anything; see RELEASING.md.
#
# Usage: scripts/build-release.sh <version> (e.g. 0.1.1)
#
# The updater private key comes from TAURI_SIGNING_PRIVATE_KEY_PATH (a file)
# or TAURI_SIGNING_PRIVATE_KEY (the key or a file), its password from
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD (asked for when unset).
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd -P)"
export PATH="${HOME}/.cargo/bin:${PATH}"
CONF="${REPO_ROOT}/src-tauri/tauri.conf.json"
CARGO_TOML="${REPO_ROOT}/src-tauri/Cargo.toml"
PACKAGE_JSON="${REPO_ROOT}/ui/package.json"
WINDOWS_BUNDLE="${REPO_ROOT}/target/x86_64-pc-windows-msvc/release/bundle/nsis"
LINUX_BUNDLE="${REPO_ROOT}/target/release/bundle"
die() {
echo "build-release: $*" >&2
exit 1
}
[ "$#" -eq 1 ] || die "usage: scripts/build-release.sh <version> (e.g. 0.1.1)"
VERSION="${1#v}"
SEMVER='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
[[ "${VERSION}" =~ ${SEMVER} ]] || die "'$1' is not a semantic version (e.g. 0.1.1)"
command -v jq >/dev/null 2>&1 || die "jq not found on PATH"
# shellcheck source=release.env
source "${SCRIPT_DIR}/release.env"
# --- Updater signing key ---------------------------------------------------
# `cargo tauri build` reads only TAURI_SIGNING_PRIVATE_KEY (key or path).
if [ -n "${TAURI_SIGNING_PRIVATE_KEY_PATH:-}" ]; then
[ -f "${TAURI_SIGNING_PRIVATE_KEY_PATH}" ] ||
die "TAURI_SIGNING_PRIVATE_KEY_PATH points to no file: ${TAURI_SIGNING_PRIVATE_KEY_PATH}"
export TAURI_SIGNING_PRIVATE_KEY="${TAURI_SIGNING_PRIVATE_KEY_PATH}"
elif [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
die "no updater signing key. Set TAURI_SIGNING_PRIVATE_KEY_PATH=~/.tauri/call-recorder.key
(or TAURI_SIGNING_PRIVATE_KEY) and, if the key has one, TAURI_SIGNING_PRIVATE_KEY_PASSWORD.
See RELEASING.md."
fi
if [ -z "${TAURI_SIGNING_PRIVATE_KEY_PASSWORD+set}" ]; then
if [ -t 0 ]; then
read -rsp "Password of the updater signing key (empty if none): " TAURI_SIGNING_PRIVATE_KEY_PASSWORD
echo
else
TAURI_SIGNING_PRIVATE_KEY_PASSWORD=""
fi
fi
export TAURI_SIGNING_PRIVATE_KEY_PASSWORD
WORK_DIR="$(mktemp -d)"
trap 'rm -rf "${WORK_DIR}"' EXIT
# Key id of a minisign public key or signature (base64 of the minisign text;
# its second line holds the algorithm, then the 8-byte little-endian key id),
# as minisign prints it.
keynum() {
base64 -d | sed -n 2p | base64 -d | od -An -tx8 -j2 -N8 | tr -d ' \n' | tr a-f A-F
}
# Sign a probe file before the long build: a wrong key or password fails
# here, and a key that does not belong to plugins.updater.pubkey would make
# every installed app reject the update.
echo "probe" >"${WORK_DIR}/probe"
if [ -f "${TAURI_SIGNING_PRIVATE_KEY}" ]; then
probe_env=(env -u TAURI_SIGNING_PRIVATE_KEY TAURI_SIGNING_PRIVATE_KEY_PATH="${TAURI_SIGNING_PRIVATE_KEY}")
else
probe_env=(env -u TAURI_SIGNING_PRIVATE_KEY_PATH)
fi
"${probe_env[@]}" cargo tauri signer sign "${WORK_DIR}/probe" >/dev/null ||
die "signing with the updater key failed (wrong key or password?)"
key_of_signature="$(keynum <"${WORK_DIR}/probe.sig")"
key_of_config="$(jq -r '.plugins.updater.pubkey' "${CONF}" | keynum)"
if [ "${key_of_signature}" != "${key_of_config}" ]; then
if [ "${RELEASE_ALLOW_KEY_MISMATCH:-}" = "1" ]; then
echo "WARNING: the signing key does not match plugins.updater.pubkey; installed apps will reject this release (RELEASE_ALLOW_KEY_MISMATCH=1, test builds only)." >&2
else
die "the signing key (key id ${key_of_signature}) does not match plugins.updater.pubkey in tauri.conf.json (key id ${key_of_config})"
fi
fi
# --- Version and update feed ------------------------------------------------
echo "Setting version ${VERSION} and update feed ${UPDATE_JSON_URL}"
# Rewrites a JSON file in place, keeping its permissions.
jq_in_place() {
local file="$1"
shift
jq "$@" "${file}" >"${WORK_DIR}/edit.json"
cat "${WORK_DIR}/edit.json" >"${file}"
}
jq_in_place "${CONF}" --arg version "${VERSION}" --arg url "${UPDATE_JSON_URL}" \
'.version = $version | .plugins.updater.endpoints = [$url]'
jq_in_place "${PACKAGE_JSON}" --arg version "${VERSION}" '.version = $version'
# The first `version = …` line is the one of [package].
sed -i -E "0,/^version = \"[^\"]*\"/s//version = \"${VERSION}\"/" "${CARGO_TOML}"
grep -qx "version = \"${VERSION}\"" "${CARGO_TOML}" || die "could not set the version in ${CARGO_TOML}"
# --- Build ------------------------------------------------------------------
"${SCRIPT_DIR}/build-windows.sh"
(cd "${REPO_ROOT}" && cargo tauri build --bundles deb appimage)
# --- Collect ----------------------------------------------------------------
OUT="${REPO_ROOT}/dist-release/${VERSION}"
rm -rf "${OUT}"
mkdir -p "${OUT}"
# Copies the one artifact matching the glob $2 in $1 and its .sig into OUT,
# under an ASCII name (the product name has an umlaut; download URLs and
# release assets stay plain).
collect() {
local matches=()
local file
for file in "$1"/$2; do
[ -f "${file}" ] && matches+=("${file}")
done
[ "${#matches[@]}" -eq 1 ] || die "expected exactly one $2 in $1, found ${#matches[@]}"
[ -s "${matches[0]}.sig" ] || die "missing updater signature ${matches[0]}.sig"
local name
name="$(basename "${matches[0]}" | sed 's/ä/ae/g; s/ö/oe/g; s/ü/ue/g; s/Ä/Ae/g; s/Ö/Oe/g; s/Ü/Ue/g; s/ß/ss/g')"
[[ "${name}" =~ ^[A-Za-z0-9._+-]+$ ]] || die "unexpected characters in artifact name: ${name}"
cp "${matches[0]}" "${OUT}/${name}"
cp "${matches[0]}.sig" "${OUT}/${name}.sig"
}
collect "${WINDOWS_BUNDLE}" "*_${VERSION}_x64-setup.exe"
collect "${LINUX_BUNDLE}/deb" "*_${VERSION}_amd64.deb"
collect "${LINUX_BUNDLE}/appimage" "*_${VERSION}_amd64.AppImage"
"${SCRIPT_DIR}/make-latest-json.sh" "${VERSION}" "${OUT}"
jq -e . "${OUT}/latest.json" >/dev/null || die "latest.json is not valid JSON"
echo
echo "Release ${VERSION} built in ${OUT}:"
ls -1 "${OUT}"
echo
echo "Next (see RELEASING.md): commit the version bump, tag v${VERSION},"
echo "create the Gitea release v${VERSION} and upload every file above."
+12 -1
View File
@@ -3,6 +3,10 @@
# using cargo-xwin (MSVC cross-linking) and makensis for bundling. # using cargo-xwin (MSVC cross-linking) and makensis for bundling.
# #
# Usage: scripts/build-windows.sh # Usage: scripts/build-windows.sh
#
# Without an updater signing key (TAURI_SIGNING_PRIVATE_KEY) the installer is
# built without updater artifacts; scripts/build-release.sh sets the key and
# builds the signed release.
set -euo pipefail set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)" SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
@@ -36,10 +40,17 @@ fi
cd "${REPO_ROOT}" cd "${REPO_ROOT}"
config_args=()
if [ -z "${TAURI_SIGNING_PRIVATE_KEY:-}" ]; then
echo "No TAURI_SIGNING_PRIVATE_KEY set: building without updater artifacts."
config_args=(--config '{"bundle":{"createUpdaterArtifacts":false}}')
fi
cargo tauri build \ cargo tauri build \
--runner cargo-xwin \ --runner cargo-xwin \
--target "${TARGET}" \ --target "${TARGET}" \
--bundles nsis --bundles nsis \
"${config_args[@]}"
BUNDLE_DIR="${REPO_ROOT}/target/${TARGET}/release/bundle/nsis" BUNDLE_DIR="${REPO_ROOT}/target/${TARGET}/release/bundle/nsis"
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# Writes <dir>/latest.json, the update feed the app reads, from the signed
# release artifacts in <dir>:
# windows-x86_64 -> *_<version>_x64-setup.exe (+ .sig)
# linux-x86_64 -> *_<version>_amd64.AppImage (+ .sig)
# The download URLs point at ${RELEASE_BASE_URL}/releases/download/v<version>/
# (scripts/release.env).
#
# Usage: scripts/make-latest-json.sh <version> <dir>
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"
die() {
echo "make-latest-json: $*" >&2
exit 1
}
[ "$#" -eq 2 ] || die "usage: scripts/make-latest-json.sh <version> <dir>"
VERSION="$1"
DIR="$2"
[ -d "${DIR}" ] || die "no such directory: ${DIR}"
command -v jq >/dev/null 2>&1 || die "jq not found on PATH"
# shellcheck source=release.env
source "${SCRIPT_DIR}/release.env"
# The one file in DIR matching the glob $1, with its .sig next to it.
signed_file() {
local matches=()
local file
for file in "${DIR}"/$1; do
[ -f "${file}" ] && matches+=("${file}")
done
[ "${#matches[@]}" -eq 1 ] || die "expected exactly one $1 in ${DIR}, found ${#matches[@]}"
[ -s "${matches[0]}.sig" ] || die "missing signature ${matches[0]}.sig"
echo "${matches[0]}"
}
WINDOWS="$(signed_file "*_${VERSION}_x64-setup.exe")"
LINUX="$(signed_file "*_${VERSION}_amd64.AppImage")"
jq -n \
--arg version "${VERSION}" \
--arg pub_date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg base "${RELEASE_BASE_URL}/releases/download/v${VERSION}" \
--arg windows_file "$(basename "${WINDOWS}")" \
--rawfile windows_sig "${WINDOWS}.sig" \
--arg linux_file "$(basename "${LINUX}")" \
--rawfile linux_sig "${LINUX}.sig" \
'{
version: $version,
pub_date: $pub_date,
platforms: {
"windows-x86_64": {
signature: ($windows_sig | gsub("\\s"; "")),
url: "\($base)/\($windows_file | @uri)"
},
"linux-x86_64": {
signature: ($linux_sig | gsub("\\s"; "")),
url: "\($base)/\($linux_file | @uri)"
}
}
}' >"${DIR}/latest.json"
echo "Wrote ${DIR}/latest.json"
+14
View File
@@ -0,0 +1,14 @@
# Where Gesprächsrekorder releases are published: the one place to change.
# Sourced by build-release.sh, which writes UPDATE_JSON_URL into
# src-tauri/tauri.conf.json (plugins.updater.endpoints), and by
# make-latest-json.sh, which points the download URLs in latest.json at
# ${RELEASE_BASE_URL}/releases/download/v<version>/<file>. See RELEASING.md.
RELEASE_BASE_URL="https://gitea.euvino.eu/public/call-recorder"
# Where the app looks for latest.json.
# A (default): latest.json is an asset of the newest release.
UPDATE_JSON_URL="${RELEASE_BASE_URL}/releases/latest/download/latest.json"
# B: latest.json is committed to the root of master (if Gitea does not
# serve releases/latest/download/…):
# UPDATE_JSON_URL="${RELEASE_BASE_URL}/raw/branch/master/latest.json"
+1
View File
@@ -26,3 +26,4 @@ chrono = { version = "0.4", features = ["serde"] }
tempfile = "3" tempfile = "3"
recorder-core = { path = "../crates/core" } recorder-core = { path = "../crates/core" }
recorder-audio = { path = "../crates/audio" } recorder-audio = { path = "../crates/audio" }
tauri-plugin-updater = "2"
+7
View File
@@ -3,6 +3,7 @@ mod detection;
mod processing; mod processing;
mod state; mod state;
mod tray; mod tray;
mod updater;
use recorder_core::pipeline; use recorder_core::pipeline;
use recorder_core::secrets::KeyringSecrets; use recorder_core::secrets::KeyringSecrets;
@@ -12,6 +13,7 @@ use tauri_plugin_autostart::MacosLauncher;
use tauri_plugin_log::{RotationStrategy, Target, TargetKind, TimezoneStrategy}; use tauri_plugin_log::{RotationStrategy, Target, TargetKind, TimezoneStrategy};
use crate::state::AppState; use crate::state::AppState;
use crate::updater::PendingUpdate;
/// Command-line flag the login item starts the app with; the main window /// Command-line flag the login item starts the app with; the main window
/// then stays hidden in the tray. /// then stays hidden in the tray.
@@ -31,6 +33,7 @@ pub fn run() {
Some(vec![AUTOSTART_ARG]), Some(vec![AUTOSTART_ARG]),
)) ))
.plugin(tauri_plugin_notification::init()) .plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_updater::Builder::new().build())
.setup(|app| { .setup(|app| {
// Release builds log to a file in the app log directory (on // Release builds log to a file in the app log directory (on
// Windows %LOCALAPPDATA%\eu.euvino.callrecorder\logs), debug // Windows %LOCALAPPDATA%\eu.euvino.callrecorder\logs), debug
@@ -72,6 +75,7 @@ pub fn run() {
// Before anything can start a run. // Before anything can start a run.
processing::clear_upload_dir(app.handle()); processing::clear_upload_dir(app.handle());
app.manage(state); app.manage(state);
app.manage(PendingUpdate::default());
// Windows are created here (`create: false` in tauri.conf.json) // Windows are created here (`create: false` in tauri.conf.json)
// instead of by Tauri before `setup` runs: their webviews load // instead of by Tauri before `setup` runs: their webviews load
// immediately and invoke commands (list_calls, get_recording_state, // immediately and invoke commands (list_calls, get_recording_state,
@@ -83,6 +87,7 @@ pub fn run() {
tray::create(app.handle())?; tray::create(app.handle())?;
detection::spawn(app.handle().clone()); detection::spawn(app.handle().clone());
updater::spawn(app.handle().clone());
if !std::env::args().any(|arg| arg == AUTOSTART_ARG) { if !std::env::args().any(|arg| arg == AUTOSTART_ARG) {
commands::show_main(app.handle()); commands::show_main(app.handle());
} }
@@ -120,6 +125,8 @@ pub fn run() {
commands::rename_call, commands::rename_call,
commands::list_accounts, commands::list_accounts,
commands::set_account, commands::set_account,
updater::get_update,
updater::install_update,
]) ])
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while building tauri application"); .expect("error while building tauri application");
+32
View File
@@ -616,6 +616,15 @@ impl AppState {
lock(&self.processing).remove(&id); lock(&self.processing).remove(&id);
} }
/// Whether a recording runs or starts, or a call is being processed (or
/// its remote jobs cleaned up). An update must not be installed then:
/// the installer ends the app.
pub fn recording_or_processing(&self) -> bool {
self.devices_busy.load(Ordering::SeqCst)
|| lock(&self.current).is_some()
|| !lock(&self.processing).is_empty()
}
/// Records both configured devices into a temporary directory for five /// Records both configured devices into a temporary directory for five
/// seconds and returns the peak level of each track. /// seconds and returns the peak level of each track.
pub fn test_devices(&self) -> Result<DeviceLevels, String> { pub fn test_devices(&self) -> Result<DeviceLevels, String> {
@@ -999,6 +1008,29 @@ mod tests {
assert_eq!(f.state.claim_processing(id, false), Ok(())); assert_eq!(f.state.claim_processing(id, false), Ok(()));
} }
#[test]
fn an_update_waits_while_a_call_is_processed() {
let f = fixture();
let (id, _, _) = finished_call(&f, "a");
assert!(!f.state.recording_or_processing());
f.state.claim_processing(id, false).unwrap();
assert!(f.state.recording_or_processing());
f.state.release_processing(id);
assert!(!f.state.recording_or_processing());
}
#[test]
fn an_update_waits_while_a_recording_starts() {
let f = fixture();
let claim = f
.state
.claim_devices("Es läuft bereits eine Aufnahme")
.unwrap();
assert!(f.state.recording_or_processing());
drop(claim);
assert!(!f.state.recording_or_processing());
}
#[test] #[test]
fn done_and_recording_calls_are_not_processed() { fn done_and_recording_calls_are_not_processed() {
let f = fixture(); let f = fixture();
+218
View File
@@ -0,0 +1,218 @@
//! Self-update (Windows only): checks the release feed (`plugins.updater`
//! in `tauri.conf.json`) at startup and every 6 h, tells the main window
//! about a newer version and installs it when the user asks, but never while
//! a recording runs or a call is being processed.
//!
//! On Windows the NSIS installer runs in passive mode for the current user
//! (no admin rights) and restarts the app; installing ends this process.
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::thread;
use std::time::Duration;
use serde::Serialize;
use tauri::{AppHandle, Emitter, Manager};
use tauri_plugin_updater::{Update, UpdaterExt};
use crate::state::AppState;
const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);
/// Progress steps while the download size is unknown.
const MIB: u64 = 1024 * 1024;
/// Why the banner cannot install yet; the banner shows the same hint.
const BUSY: &str = "Nach der laufenden Aufnahme/Verarbeitung möglich";
/// The newest update found, and whether one is being installed.
#[derive(Default)]
pub struct PendingUpdate {
update: Mutex<Option<Update>>,
installing: AtomicBool,
}
/// Payload of `update-available` and answer of `get_update`.
#[derive(Serialize, Clone, Debug, PartialEq)]
pub struct UpdateInfo {
pub version: String,
/// `false` while a recording runs or a call is being processed.
pub can_install: bool,
}
/// Payload of `update-progress`.
#[derive(Serialize, Clone, Debug, PartialEq)]
pub struct Progress {
pub downloaded: u64,
/// `None` if the server sends no size.
pub total: Option<u64>,
}
/// Starts the periodic update check. Only on Windows: Debian builds do not
/// update themselves.
pub fn spawn(app: AppHandle) {
if !cfg!(windows) {
log::info!("update check disabled on this platform");
return;
}
thread::spawn(move || loop {
tauri::async_runtime::block_on(check(&app));
thread::sleep(CHECK_INTERVAL);
});
}
/// Asks the release feed for a newer version. Failures (offline, no release
/// yet) are expected and only logged.
async fn check(app: &AppHandle) {
let result = match app.updater() {
Ok(updater) => updater.check().await,
Err(e) => Err(e),
};
match result {
Ok(Some(update)) => {
log::info!("update available: {}", update.version);
let version = update.version.clone();
*lock(&app.state::<PendingUpdate>().update) = Some(update);
let _ = app.emit("update-available", info(app, version));
}
Ok(None) => log::info!("no update available"),
Err(e) => log::info!("update check failed: {e}"),
}
}
fn info(app: &AppHandle, version: String) -> UpdateInfo {
UpdateInfo {
version,
can_install: !app.state::<AppState>().recording_or_processing(),
}
}
/// The update found by the last check, if any.
#[tauri::command]
pub fn get_update(app: AppHandle) -> Option<UpdateInfo> {
let version = lock(&app.state::<PendingUpdate>().update)
.as_ref()
.map(|update| update.version.clone())?;
Some(info(&app, version))
}
/// Downloads, verifies and installs the update found, then restarts the
/// app. Returns only on failure.
#[tauri::command]
pub async fn install_update(app: AppHandle) -> Result<(), String> {
let pending = app.state::<PendingUpdate>();
if pending.installing.swap(true, Ordering::SeqCst) {
return Err("Das Update wird bereits installiert".to_string());
}
let result = download_and_install(&app).await;
pending.installing.store(false, Ordering::SeqCst);
if let Err(e) = &result {
log::error!("update failed: {e}");
}
result
}
async fn download_and_install(app: &AppHandle) -> Result<(), String> {
let update = lock(&app.state::<PendingUpdate>().update)
.clone()
.ok_or_else(|| "Kein Update verfügbar".to_string())?;
let state = app.state::<AppState>();
if state.recording_or_processing() {
return Err(BUSY.to_string());
}
log::info!("downloading update {}", update.version);
let mut meter = ProgressMeter::default();
let bytes = update
.download(
|chunk, total| {
if let Some(progress) = meter.add(chunk, total) {
let _ = app.emit("update-progress", progress);
}
},
|| {},
)
.await
.map_err(|e| format!("Download fehlgeschlagen: {e}"))?;
// A call may have started during the download.
if state.recording_or_processing() {
return Err(BUSY.to_string());
}
log::info!("installing update {}", update.version);
// On Windows this starts the installer and ends the app.
update
.install(bytes)
.map_err(|e| format!("Installation fehlgeschlagen: {e}"))?;
app.restart()
}
/// Counts downloaded bytes and decides when the banner hears about them:
/// at every whole percent, or every MiB while the size is unknown.
#[derive(Default)]
struct ProgressMeter {
downloaded: u64,
reported_step: Option<u64>,
}
impl ProgressMeter {
fn add(&mut self, chunk: usize, total: Option<u64>) -> Option<Progress> {
self.downloaded += chunk as u64;
let step = match total {
Some(total) if total > 0 => self.downloaded * 100 / total,
_ => self.downloaded / MIB,
};
if self.reported_step == Some(step) {
return None;
}
self.reported_step = Some(step);
Some(Progress {
downloaded: self.downloaded,
total,
})
}
}
/// Locks ignoring poisoning, like the app state does.
fn lock<T>(mutex: &Mutex<T>) -> std::sync::MutexGuard<'_, T> {
mutex
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner())
}
#[cfg(test)]
mod tests {
use super::*;
fn reported(meter: &mut ProgressMeter, chunks: &[usize], total: Option<u64>) -> Vec<u64> {
chunks
.iter()
.filter_map(|&chunk| meter.add(chunk, total))
.map(|progress| progress.downloaded)
.collect()
}
#[test]
fn progress_is_reported_once_per_whole_percent() {
let mut meter = ProgressMeter::default();
// 1000 bytes: 10 bytes are one percent.
let chunks = [4, 4, 4, 4, 4, 980];
assert_eq!(reported(&mut meter, &chunks, Some(1000)), [4, 12, 20, 1000]);
}
#[test]
fn the_first_chunk_is_always_reported() {
let mut meter = ProgressMeter::default();
assert_eq!(
meter.add(1, Some(1_000_000)),
Some(Progress {
downloaded: 1,
total: Some(1_000_000)
})
);
}
#[test]
fn without_a_size_progress_is_reported_every_mib() {
let mut meter = ProgressMeter::default();
let half = (MIB / 2) as usize;
let reports = reported(&mut meter, &[half, half, half, half, half], None);
assert_eq!(reports, [MIB / 2, MIB, 2 * MIB]);
}
}
+17 -1
View File
@@ -49,7 +49,11 @@
}, },
"bundle": { "bundle": {
"active": true, "active": true,
"targets": ["nsis", "deb", "appimage"], "targets": [
"nsis",
"deb",
"appimage"
],
"icon": [ "icon": [
"icons/32x32.png", "icons/32x32.png",
"icons/128x128.png", "icons/128x128.png",
@@ -61,6 +65,18 @@
"nsis": { "nsis": {
"installMode": "currentUser" "installMode": "currentUser"
} }
},
"createUpdaterArtifacts": true
},
"plugins": {
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwM0EzNUEyMTUwOThERUQKUldUdGpRa1ZvalU2SVBtYVZRaWlWMVBCNzFTd1BRbmtmdU9sZXMrVTltckNiYlRSSmZHcWpNMHUK",
"endpoints": [
"https://gitea.euvino.eu/public/call-recorder/releases/latest/download/latest.json"
],
"windows": {
"installMode": "passive"
}
} }
} }
} }
+119
View File
@@ -0,0 +1,119 @@
<script lang="ts">
import { onMount } from 'svelte'
import {
errorText,
getUpdate,
installUpdate,
onCallUpdated,
onRecordingState,
onUpdateAvailable,
onUpdateProgress,
type UpdateInfo,
type UpdateProgress,
} from './api'
/** How often a blocked update re-asks whether it may install now. */
const BUSY_POLL_MS = 5000
let update = $state<UpdateInfo | null>(null)
let installing = $state(false)
let progress = $state<UpdateProgress | null>(null)
let error = $state('')
async function refresh() {
try {
update = await getUpdate()
} catch {
// The banner is optional; the next event or poll tries again.
}
}
onMount(() => {
const unlisten = [
onUpdateAvailable((info) => (update = info)),
onUpdateProgress((next) => (progress = next)),
// Recording and processing end with these events.
onRecordingState(refresh),
onCallUpdated(refresh),
]
refresh()
// Not every end of a cleanup sends an event.
const poll = setInterval(() => {
if (update && !update.can_install && !installing) refresh()
}, BUSY_POLL_MS)
return () => {
clearInterval(poll)
unlisten.forEach((u) => u.then((off) => off()))
}
})
async function install() {
installing = true
progress = null
error = ''
try {
// Returns only on failure: on success the app restarts.
await installUpdate()
} catch (err) {
error = errorText(err)
refresh()
} finally {
installing = false
}
}
function megabytes(bytes: number): string {
return (bytes / 1024 / 1024).toLocaleString('de-DE', { maximumFractionDigits: 1 }) + ' MB'
}
let progressText = $derived.by(() => {
if (!progress) return 'Update wird heruntergeladen…'
if (progress.total === null) return `Update wird heruntergeladen… ${megabytes(progress.downloaded)}`
if (progress.downloaded >= progress.total) return 'Update wird installiert…'
return `Update wird heruntergeladen… ${Math.floor((progress.downloaded * 100) / progress.total)} %`
})
</script>
{#if update}
<div class="banner" role="status">
{#if installing}
<span>{progressText}</span>
{:else}
<span>Update verfügbar (v{update.version}) →</span>
<button class="btn primary small" disabled={!update.can_install} onclick={install}>
Installieren &amp; neu starten
</button>
{#if !update.can_install}
<span class="hint">Nach der laufenden Aufnahme/Verarbeitung möglich</span>
{/if}
{/if}
{#if error}
<span class="error">{error}</span>
{/if}
</div>
{/if}
<style>
.banner {
/* Spans the main window's grid. */
grid-column: 1 / -1;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 6px 10px;
padding: 8px 16px;
background: var(--primary-soft);
border-bottom: 1px solid var(--border);
font-weight: 600;
}
.hint {
color: var(--muted);
font-size: 12px;
font-weight: 400;
}
.error {
font-weight: 400;
}
</style>
+22
View File
@@ -100,6 +100,19 @@ export interface Account {
name: string name: string
} }
/** A newer version the release feed offers. */
export interface UpdateInfo {
version: string
/** `false` while a recording runs or a call is being processed. */
can_install: boolean
}
/** Download progress of an update; `total` is `null` if unknown. */
export interface UpdateProgress {
downloaded: number
total: number | null
}
export interface Levels { export interface Levels {
mic: number mic: number
out: number out: number
@@ -137,6 +150,9 @@ export const renameCall = (id: CallId, title: string | null) =>
export const listAccounts = () => invoke<Account[]>('list_accounts') export const listAccounts = () => invoke<Account[]>('list_accounts')
export const setAccount = (id: CallId, accountId: string | null) => export const setAccount = (id: CallId, accountId: string | null) =>
invoke<void>('set_account', { id, accountId }) invoke<void>('set_account', { id, accountId })
export const getUpdate = () => invoke<UpdateInfo | null>('get_update')
/** Resolves only on failure: on success the app restarts. */
export const installUpdate = () => invoke<void>('install_update')
export const onRecordingState = (handler: (state: RecordingState) => void): Promise<UnlistenFn> => export const onRecordingState = (handler: (state: RecordingState) => void): Promise<UnlistenFn> =>
listen<RecordingState>('recording-state', (event) => handler(event.payload)) listen<RecordingState>('recording-state', (event) => handler(event.payload))
@@ -148,6 +164,12 @@ export const onPromptChanged = (handler: () => void): Promise<UnlistenFn> =>
/** A call's status changed (processing started, done or failed). */ /** A call's status changed (processing started, done or failed). */
export const onCallUpdated = (handler: (id: CallId) => void): Promise<UnlistenFn> => export const onCallUpdated = (handler: (id: CallId) => void): Promise<UnlistenFn> =>
listen<{ id: CallId }>('call-updated', (event) => handler(event.payload.id)) listen<{ id: CallId }>('call-updated', (event) => handler(event.payload.id))
export const onUpdateAvailable = (handler: (info: UpdateInfo) => void): Promise<UnlistenFn> =>
listen<UpdateInfo>('update-available', (event) => handler(event.payload))
export const onUpdateProgress = (
handler: (progress: UpdateProgress) => void,
): Promise<UnlistenFn> =>
listen<UpdateProgress>('update-progress', (event) => handler(event.payload))
export const onLevels = (handler: (levels: Levels) => void): Promise<UnlistenFn> => export const onLevels = (handler: (levels: Levels) => void): Promise<UnlistenFn> =>
listen<Levels>('levels', (event) => handler(event.payload)) listen<Levels>('levels', (event) => handler(event.payload))
+9
View File
@@ -26,6 +26,7 @@
import { formatDetailTime, formatMinutes } from '../lib/format' import { formatDetailTime, formatMinutes } from '../lib/format'
import StatusPill from '../lib/StatusPill.svelte' import StatusPill from '../lib/StatusPill.svelte'
import TranscriptView from '../lib/TranscriptView.svelte' import TranscriptView from '../lib/TranscriptView.svelte'
import UpdateBanner from '../lib/UpdateBanner.svelte'
let calls = $state<CallListItem[]>([]) let calls = $state<CallListItem[]>([])
let loaded = $state(false) let loaded = $state(false)
@@ -230,6 +231,7 @@
</script> </script>
<main class="main"> <main class="main">
<UpdateBanner />
<aside class="sidebar"> <aside class="sidebar">
<header class="sidebar-header"> <header class="sidebar-header">
<h1>Gespräche</h1> <h1>Gespräche</h1>
@@ -367,9 +369,16 @@
.main { .main {
display: grid; display: grid;
grid-template-columns: minmax(260px, 30%) 1fr; grid-template-columns: minmax(260px, 30%) 1fr;
/* The update banner spans the first row; it is empty without one. */
grid-template-rows: auto minmax(0, 1fr);
height: 100vh; height: 100vh;
} }
.sidebar,
.detail {
grid-row: 2;
}
.sidebar { .sidebar {
display: flex; display: flex;
flex-direction: column; flex-direction: column;