diff --git a/.github/scripts/build-updater-manifest.mjs b/.github/scripts/build-updater-manifest.mjs new file mode 100644 index 000000000..e94aaf641 --- /dev/null +++ b/.github/scripts/build-updater-manifest.mjs @@ -0,0 +1,64 @@ +// Composes the Tauri updater manifest (latest.json) from the per-platform .sig +// assets already attached to the release. +// Required env: TAG, REPO, GH_TOKEN. + +import { execSync } from 'node:child_process'; +import { readFileSync, readdirSync, writeFileSync, mkdtempSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; + +const TAG = process.env.TAG; +const REPO = process.env.REPO; +if (!TAG || !REPO) { + console.error('TAG and REPO env vars are required'); + process.exit(1); +} +const version = TAG.replace(/^v/, ''); + +const dir = mkdtempSync(join(tmpdir(), 'sable-sigs-')); +execSync(`gh release download "${TAG}" --repo "${REPO}" --pattern '*.sig' --dir "${dir}"`, { + stdio: 'inherit', +}); + +const urlFor = (name) => + `https://github.com/${REPO}/releases/download/${TAG}/${encodeURIComponent(name)}`; + +const platforms = {}; +let windowsIsNsis = false; + +for (const sig of readdirSync(dir).filter((f) => f.endsWith('.sig'))) { + const artifact = sig.replace(/\.sig$/, ''); + const entry = { signature: readFileSync(join(dir, sig), 'utf8').trim(), url: urlFor(artifact) }; + const name = artifact.toLowerCase(); + + if (name.endsWith('.app.tar.gz')) { + platforms['darwin-aarch64'] = entry; + platforms['darwin-x86_64'] = entry; + } else if (name.endsWith('.appimage')) { + platforms['linux-x86_64'] = entry; + } else if (name.endsWith('-setup.exe') || name.endsWith('.nsis.zip')) { + platforms['windows-x86_64'] = entry; + windowsIsNsis = true; + } else if (name.endsWith('.msi') && !windowsIsNsis) { + platforms['windows-x86_64'] = entry; + } +} + +if (Object.keys(platforms).length === 0) { + console.error('No .sig assets found on the release; nothing to publish.'); + process.exit(1); +} + +let notes = `Sable ${version}`; +try { + notes = + execSync(`gh release view "${TAG}" --repo "${REPO}" --json body -q .body`, { + encoding: 'utf8', + }).trim() || notes; +} catch { + // keep the default note +} + +const manifest = { version, notes, pub_date: new Date().toISOString(), platforms }; +writeFileSync('latest.json', JSON.stringify(manifest, null, 2)); +console.log(JSON.stringify(manifest, null, 2)); diff --git a/.github/workflows/tauri-build.yml b/.github/workflows/tauri-build.yml index e965caaea..7077cdbe4 100644 --- a/.github/workflows/tauri-build.yml +++ b/.github/workflows/tauri-build.yml @@ -41,6 +41,8 @@ jobs: env: TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} NODE_OPTIONS: --max-old-space-size=8192 + TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} + TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }} steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -223,14 +225,47 @@ jobs: APPIMAGE_EXTRACT_AND_RUN=1 ARCH=x86_64 \ ./appimagetool "$APPDIR" "Sable_${VERSION}_amd64.AppImage" + - name: Sign the AppImage for the updater + if: ${{ matrix.cef && env.TAURI_SIGNING_PRIVATE_KEY != '' }} + shell: bash + run: | + for f in Sable_*_amd64.AppImage; do + [ -e "$f" ] || continue + pnpm tauri signer sign "$f" + done + - name: Attach native packages to release if: matrix.cef shell: bash env: GH_TOKEN: ${{ github.token }} run: | - for f in sable_*.deb sable-*.rpm Sable_*_amd64.AppImage; do + for f in sable_*.deb sable-*.rpm Sable_*_amd64.AppImage Sable_*_amd64.AppImage.sig; do [ -e "$f" ] || continue echo "Uploading $f" gh release upload "$TAG" "$f" --clobber done + + updater-manifest: + name: Publish updater manifest + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + env: + TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} + REPO: ${{ github.repository }} + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }} + persist-credentials: false + + - name: Build and upload latest.json + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + node .github/scripts/build-updater-manifest.mjs + gh release upload "$TAG" latest.json --clobber diff --git a/package.json b/package.json index 84a43d8ae..342b04f88 100644 --- a/package.json +++ b/package.json @@ -36,10 +36,10 @@ "@atlaskit/pragmatic-drag-and-drop": "^2.0.1", "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^3.0.0", "@atlaskit/pragmatic-drag-and-drop-hitbox": "^2.0.0", + "@choochmeque/tauri-plugin-notifications-api": "0.5.0-rc.11", "@fontsource-variable/nunito": "5.2.7", "@fontsource/space-mono": "5.2.9", "@phosphor-icons/react": "^2.1.10", - "@choochmeque/tauri-plugin-notifications-api": "0.5.0-rc.11", "@sableclient/twemoji-font": "^1.0.4", "@sentry/react": "^10.63.0", "@tanstack/react-query": "^5.101.2", @@ -48,10 +48,13 @@ "@tauri-apps/api": "2.11.1", "@tauri-apps/plugin-clipboard-manager": "2.3.2", "@tauri-apps/plugin-deep-link": "2.4.9", + "@tauri-apps/plugin-dialog": "~2.7.1", "@tauri-apps/plugin-http": "2.5.9", "@tauri-apps/plugin-opener": "2.5.4", "@tauri-apps/plugin-os": "2.3.2", + "@tauri-apps/plugin-process": "~2.3.1", "@tauri-apps/plugin-store": "^2.4.3", + "@tauri-apps/plugin-updater": "~2.10.1", "@use-gesture/react": "10.3.1", "@vanilla-extract/css": "^1.21.1", "@vanilla-extract/recipes": "^0.5.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 41990ace8..285692137 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,6 +59,9 @@ importers: '@tauri-apps/plugin-deep-link': specifier: 2.4.9 version: 2.4.9 + '@tauri-apps/plugin-dialog': + specifier: ~2.7.1 + version: 2.7.1 '@tauri-apps/plugin-http': specifier: 2.5.9 version: 2.5.9 @@ -68,9 +71,15 @@ importers: '@tauri-apps/plugin-os': specifier: 2.3.2 version: 2.3.2 + '@tauri-apps/plugin-process': + specifier: ~2.3.1 + version: 2.3.1 '@tauri-apps/plugin-store': specifier: ^2.4.3 version: 2.4.3 + '@tauri-apps/plugin-updater': + specifier: ~2.10.1 + version: 2.10.1 '@use-gesture/react': specifier: 10.3.1 version: 10.3.1(react@18.3.1) @@ -2902,6 +2911,9 @@ packages: '@tauri-apps/plugin-deep-link@2.4.9': resolution: {integrity: sha512-u0SKOUHnJ1wqeqXsDFq2+kASCBj9xxbG0g9XZWPy9SOmU4wXtp6b/wiYpm6oH6/5fBTQsLqnLhIvqLBRpgHJlA==} + '@tauri-apps/plugin-dialog@2.7.1': + resolution: {integrity: sha512-OK1UBXYt+ojcmxMktzzuyonYIFta8CmAASpX+CA+DTGK24KlHjhYI6x2iOJ/TjZF4N7/ACK1oFmEOjIY9IhzOQ==} + '@tauri-apps/plugin-http@2.5.9': resolution: {integrity: sha512-lCiY0+vs4HvIUSvZrBs8TC3TiCB0MOPRmiUjTq4prW7SlcJE2jdLeT6KBsJrT9Tlplufl7W1pY6SFAO3gCWxDA==} @@ -2911,9 +2923,15 @@ packages: '@tauri-apps/plugin-os@2.3.2': resolution: {integrity: sha512-n+nXWeuSeF9wcEsSPmRnBEGrRgOy6jjkSU+UVCOV8YUGKb2erhDOxis7IqRXiRVHhY8XMKks00BJ0OAdkpf6+A==} + '@tauri-apps/plugin-process@2.3.1': + resolution: {integrity: sha512-nCa4fGVaDL/B9ai03VyPOjfAHRHSBz5v6F/ObsB73r/dA3MHHhZtldaDMIc0V/pnUw9ehzr2iEG+XkSEyC0JJA==} + '@tauri-apps/plugin-store@2.4.3': resolution: {integrity: sha512-9LWPj9yMphRi9czEtUv87XHbl1b6xgd9EXpPrUnq6nG7+nbtoF84d4Kwz9xhAv/Hf30sr58pq7EOlyI936y8qw==} + '@tauri-apps/plugin-updater@2.10.1': + resolution: {integrity: sha512-NFYMg+tWOZPJdzE/PpFj2qfqwAWwNS3kXrb1tm1gnBJ9mYzZ4WDRrwy8udzWoAnfGCHLuePNLY1WVCNHnh3eRA==} + '@testing-library/dom@10.4.1': resolution: {integrity: sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==} engines: {node: '>=18'} @@ -7468,6 +7486,10 @@ snapshots: dependencies: '@tauri-apps/api': 2.11.1 + '@tauri-apps/plugin-dialog@2.7.1': + dependencies: + '@tauri-apps/api': 2.11.1 + '@tauri-apps/plugin-http@2.5.9': dependencies: '@tauri-apps/api': 2.11.1 @@ -7480,10 +7502,18 @@ snapshots: dependencies: '@tauri-apps/api': 2.11.1 + '@tauri-apps/plugin-process@2.3.1': + dependencies: + '@tauri-apps/api': 2.11.1 + '@tauri-apps/plugin-store@2.4.3': dependencies: '@tauri-apps/api': 2.11.1 + '@tauri-apps/plugin-updater@2.10.1': + dependencies: + '@tauri-apps/api': 2.11.1 + '@testing-library/dom@10.4.1': dependencies: '@babel/code-frame': 7.29.7 diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 0f06b64ef..a9082d4c7 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -168,6 +168,15 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +[[package]] +name = "arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "arboard" version = "3.6.1" @@ -1220,6 +1229,17 @@ dependencies = [ "serde_core", ] +[[package]] +name = "derive_arbitrary" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "derive_more" version = "0.99.20" @@ -1326,7 +1346,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" dependencies = [ - "libloading 0.7.4", + "libloading 0.8.9", ] [[package]] @@ -3131,6 +3151,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minisign-verify" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22f9645cb765ea72b8111f36c522475d2daa0d22c957a9826437e97534bc4e9e" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -3488,6 +3514,18 @@ dependencies = [ "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.11.1", + "objc2", + "objc2-app-kit", + "objc2-foundation", +] + [[package]] name = "objc2-quartz-core" version = "0.3.2" @@ -3570,6 +3608,12 @@ dependencies = [ "pathdiff", ] +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + [[package]] name = "option-ext" version = "0.2.0" @@ -3632,6 +3676,20 @@ dependencies = [ "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.18", +] + [[package]] name = "owned_ttf_parser" version = "0.25.1" @@ -4558,15 +4616,20 @@ dependencies = [ "http-body", "http-body-util", "hyper", + "hyper-rustls", "hyper-util", "js-sys", "log", "percent-encoding", "pin-project-lite", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", "serde", "serde_json", "sync_wrapper", "tokio", + "tokio-rustls", "tokio-util", "tower", "tower-http", @@ -4578,6 +4641,30 @@ dependencies = [ "web-sys", ] +[[package]] +name = "rfd" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a15ad77d9e70a92437d8f74c35d99b4e4691128df018833e99f90bcd36152672" +dependencies = [ + "block2", + "dispatch2", + "glib-sys", + "gobject-sys", + "gtk-sys", + "js-sys", + "log", + "objc2", + "objc2-app-kit", + "objc2-core-foundation", + "objc2-foundation", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.60.2", +] + [[package]] name = "ring" version = "0.17.14" @@ -4645,6 +4732,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" +dependencies = [ + "openssl-probe", + "rustls-pki-types", + "schannel", + "security-framework", +] + [[package]] name = "rustls-pki-types" version = "1.14.1" @@ -4655,6 +4754,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d1e2536ce4f35f4846aa13bff16bd0ff40157cdb14cc056c7b14ba41233ba0" +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.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.103.13" @@ -4697,15 +4823,18 @@ dependencies = [ "tauri-plugin-android-fs", "tauri-plugin-clipboard-manager", "tauri-plugin-deep-link", + "tauri-plugin-dialog", "tauri-plugin-edge-to-edge", "tauri-plugin-http", "tauri-plugin-log", "tauri-plugin-notifications", "tauri-plugin-opener", "tauri-plugin-os", + "tauri-plugin-process", "tauri-plugin-single-instance", "tauri-plugin-store", "tauri-plugin-unifiedpush", + "tauri-plugin-updater", "tauri-plugin-window-state", "tauri-runtime-cef", "tauri-typegen", @@ -4724,6 +4853,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schannel" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" +dependencies = [ + "windows-sys 0.61.2", +] + [[package]] name = "schemars" version = "0.8.22" @@ -4800,6 +4938,29 @@ dependencies = [ "tiny-skia", ] +[[package]] +name = "security-framework" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" +dependencies = [ + "bitflags 2.11.1", + "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]] name = "selectors" version = "0.24.0" @@ -5707,6 +5868,24 @@ dependencies = [ "windows-result 0.3.4", ] +[[package]] +name = "tauri-plugin-dialog" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2d3c1dbe38037e7f590cdf2492594d5ceebe031e7bc7e827509b22a999d2940" +dependencies = [ + "log", + "raw-window-handle", + "rfd", + "serde", + "serde_json", + "tauri", + "tauri-plugin", + "tauri-plugin-fs", + "thiserror 2.0.18", + "url", +] + [[package]] name = "tauri-plugin-edge-to-edge" version = "0.3.3" @@ -5853,6 +6032,16 @@ dependencies = [ "thiserror 2.0.18", ] +[[package]] +name = "tauri-plugin-process" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55511a7bf6cd70c8767b02c97bf8134fa434daf3926cfc1be0a0f94132d165a" +dependencies = [ + "tauri", + "tauri-plugin", +] + [[package]] name = "tauri-plugin-single-instance" version = "2.4.3" @@ -5898,6 +6087,39 @@ dependencies = [ "thiserror 2.0.18", ] +[[package]] +name = "tauri-plugin-updater" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806d9dac662c2e4594ff03c647a552f2c9bd544e7d0f683ec58f872f952ce4af" +dependencies = [ + "base64 0.22.1", + "dirs", + "flate2", + "futures-util", + "http", + "infer", + "log", + "minisign-verify", + "osakit", + "percent-encoding", + "reqwest 0.13.3", + "rustls", + "semver", + "serde", + "serde_json", + "tar", + "tauri", + "tauri-plugin", + "tempfile", + "thiserror 2.0.18", + "time", + "tokio", + "url", + "windows-sys 0.60.2", + "zip", +] + [[package]] name = "tauri-plugin-window-state" version = "2.4.1" @@ -7203,6 +7425,15 @@ dependencies = [ "system-deps", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webpki-roots" version = "1.0.7" @@ -8385,6 +8616,18 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "zip" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa8cd6af31c3b31c6631b8f483848b91589021b28fffe50adada48d4f4d2ed1" +dependencies = [ + "arbitrary", + "crc32fast", + "indexmap 2.14.0", + "memchr", +] + [[package]] name = "zmij" version = "1.0.21" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 843f758b5..1a69226f9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -59,6 +59,9 @@ tauri-plugin-single-instance = { version = "2.4.3", features = ["deep-link"] } tauri-plugin-notifications = { git = "https://github.com/Choochmeque/tauri-plugin-notifications.git", rev = "2ff1373d218ff02a93f71f589c56e4e8b588ea7d" } [target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies] +tauri-plugin-updater = "2" +tauri-plugin-process = "2" +tauri-plugin-dialog = "2" tauri-plugin-window-state = "2.4.1" [target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] diff --git a/src-tauri/capabilities/desktop.json b/src-tauri/capabilities/desktop.json index 6c37a6ca2..f85e1b78f 100644 --- a/src-tauri/capabilities/desktop.json +++ b/src-tauri/capabilities/desktop.json @@ -12,6 +12,9 @@ "permissions": [ "window-state:default", "store:default", - "notifications:default" + "notifications:default", + "updater:default", + "process:default", + "dialog:default" ] } \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 9e71fd7bb..9b0205c09 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -228,6 +228,12 @@ pub fn run() { #[cfg(any(mobile, desktop))] let builder = builder.plugin(tauri_plugin_notifications::init()); + #[cfg(desktop)] + let builder = builder + .plugin(tauri_plugin_updater::Builder::new().build()) + .plugin(tauri_plugin_process::init()) + .plugin(tauri_plugin_dialog::init()); + #[cfg(mobile)] let builder = builder.plugin(tauri_plugin_edge_to_edge::init()); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 5051bb9d3..c53727dad 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -18,6 +18,7 @@ "bundle": { "active": true, "targets": "all", + "createUpdaterArtifacts": true, "macOS": { "infoPlist": "Info.plist" }, @@ -52,6 +53,12 @@ ] }, "plugins": { + "updater": { + "endpoints": [ + "https://github.com/SableClient/Sable/releases/latest/download/latest.json" + ], + "pubkey": "REPLACE_WITH_SABLECLIENT_UPDATER_PUBLIC_KEY" + }, "typegen": { "projectPath": ".", "outputPath": "../src/app/generated/tauri", diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index bd108f3b8..7a82bba57 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -65,6 +65,7 @@ import { isIncomingCallSuppressed } from '$features/call/callIncomingIngress'; import { incomingCallAtom, mutedCallRoomIdAtom } from '$state/callEmbed'; import { getInboxInvitesPath } from '../pathUtils'; import { BackgroundNotifications } from './BackgroundNotifications'; +import { DesktopUpdater } from './DesktopUpdater'; import { NotificationTransportRuntimeFeature } from '$features/settings/notifications/NotificationTransportRuntimeFeature'; import { UnverifiedNoticeBanner } from '$components/unverified-notice'; import { getRenderableMediaUrlStats } from '$hooks/useRenderableMediaUrl'; @@ -931,6 +932,7 @@ export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) { + diff --git a/src/app/pages/client/DesktopUpdater.tsx b/src/app/pages/client/DesktopUpdater.tsx new file mode 100644 index 000000000..fcaa17adb --- /dev/null +++ b/src/app/pages/client/DesktopUpdater.tsx @@ -0,0 +1,46 @@ +import { useEffect } from 'react'; +import { isTauri } from '@tauri-apps/api/core'; +import { type as osType } from '@tauri-apps/plugin-os'; +import { createLogger } from '$utils/debug'; + +const log = createLogger('DesktopUpdater'); + +const DESKTOP_TAURI_OS = new Set(['linux', 'macos', 'windows']); +const isDesktopTauri = (): boolean => isTauri() && DESKTOP_TAURI_OS.has(osType()); + +async function checkForDesktopUpdate(): Promise { + const { check } = await import('@tauri-apps/plugin-updater'); + const update = await check(); + if (!update) return; + + log.log(`update ${update.version} available`); + const { ask } = await import('@tauri-apps/plugin-dialog'); + + const shouldInstall = await ask(`Sable ${update.version} is available. Install it now?`, { + title: 'Update available', + kind: 'info', + okLabel: 'Install', + cancelLabel: 'Later', + }); + if (!shouldInstall) return; + + await update.downloadAndInstall(); + + const { relaunch } = await import('@tauri-apps/plugin-process'); + const shouldRestart = await ask('Update installed. Restart Sable to finish?', { + title: 'Restart required', + kind: 'info', + okLabel: 'Restart', + cancelLabel: 'Later', + }); + if (shouldRestart) await relaunch(); +} + +export function DesktopUpdater() { + useEffect(() => { + if (!isDesktopTauri()) return; + checkForDesktopUpdate().catch((err) => log.error('update check failed', err)); + }, []); + + return null; +}