Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat: add auto-update support via tauri-plugin-updater

esengine208ace909faf
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 94099fe5c..47f7d7256 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -60,9 +60,12 @@ jobs:
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
+ TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
projectPath: desktop
tagName: v__VERSION__
releaseName: ESEngine Editor v__VERSION__
releaseDraft: false
+ updaterJsonKeepUniversal: true
args: ${{ matrix.args }}
diff --git a/desktop/package.json b/desktop/package.json
index 0444baed7..179349301 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -15,7 +15,9 @@
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-dialog": "^2.0.0",
"@tauri-apps/plugin-fs": "^2.0.0",
- "@tauri-apps/plugin-shell": "^2.0.0"
+ "@tauri-apps/plugin-shell": "^2.0.0",
+ "@tauri-apps/plugin-process": "^2.0.0",
+ "@tauri-apps/plugin-updater": "^2.0.0"
},
"devDependencies": {
"@tauri-apps/cli": "^2.0.0",
diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml
index a76d14fba..dd4379a96 100644
--- a/desktop/src-tauri/Cargo.toml
+++ b/desktop/src-tauri/Cargo.toml
@@ -17,6 +17,8 @@ tauri = { version = "2", features = ["protocol-asset"] }
tauri-plugin-dialog = "2"
tauri-plugin-fs = { version = "2", features = ["watch"] }
tauri-plugin-shell = "2"
+tauri-plugin-process = "2"
+tauri-plugin-updater = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["process", "io-util", "macros"] }
diff --git a/desktop/src-tauri/capabilities/default.json b/desktop/src-tauri/capabilities/default.json
index ef0d2ed43..d99639e47 100644
--- a/desktop/src-tauri/capabilities/default.json
+++ b/desktop/src-tauri/capabilities/default.json
@@ -60,6 +60,8 @@
},
{
"identifier": "fs:allow-unwatch"
- }
+ },
+ "updater:default",
+ "process:allow-restart"
]
}
diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs
index de3e6f64c..9ed167cd3 100644
--- a/desktop/src-tauri/src/lib.rs
+++ b/desktop/src-tauri/src/lib.rs
@@ -201,6 +201,8 @@ pub fn run() {
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_fs::init())
.plugin(tauri_plugin_shell::init())
+ .plugin(tauri_plugin_process::init())
+ .plugin(tauri_plugin_updater::Builder::new().build())
.manage(AppState {
preview_server: Mutex::new(None),
})
diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json
index 82a840575..e13e58176 100644
--- a/desktop/src-tauri/tauri.conf.json
+++ b/desktop/src-tauri/tauri.conf.json
@@ -36,6 +36,12 @@
},
"shell": {
"open": true
+ },
+ "updater": {
+ "endpoints": [
+ "https://github.com/esengine/microes/releases/latest/download/latest.json"
+ ],
+ "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDg3NzU1MENDQjkzRDhGQzcKUldUSGp6MjV6RkIxaDduNXIyOStLaW5MVlVKNWZaR3ZFMFYzT25qUW1hMHJTcVVpbEhnS0tKeGkK"
}
},
"bundle": {
diff --git a/desktop/src/main.ts b/desktop/src/main.ts
index 365b101c4..107a42c0a 100644
--- a/desktop/src/main.ts
+++ b/desktop/src/main.ts
@@ -8,6 +8,9 @@ import { createEditor, ProjectLauncher, setPlatformAdapter, setEditorContext, ty
import { TauriPlatformAdapter } from './TauriPlatformAdapter';
import { nativeFS, nativeShell } from './native-fs';
import { invoke } from '@tauri-apps/api/core';
+import { check } from '@tauri-apps/plugin-updater';
+import { relaunch } from '@tauri-apps/plugin-process';
+import { ask } from '@tauri-apps/plugin-dialog';
import type { App, ESEngineModule } from 'esengine';
let currentLauncher: ProjectLauncher | null = null;
@@ -73,6 +76,24 @@ async function openEditor(container: HTMLElement, projectPath: string): Promise<
}
}
+async function checkForUpdate(): Promise<void> {
+ try {
+ const update = await check();
+ if (!update) return;
+
+ const yes = await ask(
+ `New version ${update.version} is available. Update now?`,
+ { title: 'Update Available', kind: 'info', okLabel: 'Update', cancelLabel: 'Later' }
+ );
+ if (!yes) return;
+
+ await update.downloadAndInstall();
+ await relaunch();
+ } catch (e) {
+ console.warn('Update check failed:', e);
+ }
+}
+
async function init(): Promise<void> {
setPlatformAdapter(new TauriPlatformAdapter());
setEditorContext({
@@ -89,6 +110,7 @@ async function init(): Promise<void> {
}
showLauncher(container);
+ checkForUpdate();
}
init().catch(console.error);
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 22897ec5d..7a70e5f0d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -35,9 +35,15 @@ importers:
'@tauri-apps/plugin-fs':
specifier: ^2.0.0
version: 2.4.5
+ '@tauri-apps/plugin-process':
+ specifier: ^2.0.0
+ version: 2.3.1
'@tauri-apps/plugin-shell':
specifier: ^2.0.0
version: 2.3.5
+ '@tauri-apps/plugin-updater':
+ specifier: ^2.0.0
+ version: 2.10.0
esengine:
specifier: workspace:*
version: link:../sdk
@@ -560,9 +566,15 @@ packages:
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-dVxWWGE6VrOxC7/jlhyE+ON/Cc2REJlM35R3PJX3UvFw2XwYhLGQVAIyrehenDdKjotipjYEVc4YjOl3qq90fA==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-nCa4fGVaDL/B9ai03VyPOjfAHRHSBz5v6F/ObsB73r/dA3MHHhZtldaDMIc0V/pnUw9ehzr2iEG+XkSEyC0JJA==}
+
'@tauri-apps/[email protected]':
resolution: {integrity: sha512-jewtULhiQ7lI7+owCKAjc8tYLJr92U16bPOeAa472LHJdgaibLP83NcfAF2e+wkEcA53FxKQAZ7byDzs2eeizg==}
+ '@tauri-apps/[email protected]':
+ resolution: {integrity: sha512-ljN8jPlnT0aSn8ecYhuBib84alxfMx6Hc8vJSKMJyzGbTPFZAC44T2I1QNFZssgWKrAlofvJqCC6Rr472JWfkQ==}
+
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
@@ -1265,10 +1277,18 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.10.1
+ '@tauri-apps/[email protected]':
+ dependencies:
+ '@tauri-apps/api': 2.10.1
+
'@tauri-apps/[email protected]':
dependencies:
'@tauri-apps/api': 2.10.1
+ '@tauri-apps/[email protected]':
+ dependencies:
+ '@tauri-apps/api': 2.10.1
+
'@types/[email protected]': {}
'@types/[email protected]': {}