CI/CD & auto-updates first try pls
This commit is contained in:
@@ -61,3 +61,6 @@ windows = { version = "0.58", features = [
|
||||
objc2 = "0.6.3"
|
||||
objc2-app-kit = "0.3.2"
|
||||
objc2-foundation = "0.3.2"
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-updater = "2"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"identifier": "desktop-capability",
|
||||
"platforms": ["macOS", "windows"],
|
||||
"windows": ["main"],
|
||||
"permissions": ["updater:default"]
|
||||
}
|
||||
@@ -13,12 +13,14 @@ mod scene_configuration;
|
||||
mod skins;
|
||||
mod ufa;
|
||||
mod ui;
|
||||
mod updater;
|
||||
mod user;
|
||||
|
||||
use tauri::Manager;
|
||||
|
||||
async fn launch_app(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let handle = app.handle();
|
||||
updater::init(handle).await;
|
||||
db::init(handle).await?;
|
||||
scene_configuration::init(handle).await?;
|
||||
keypair::init(handle).await?;
|
||||
@@ -47,6 +49,7 @@ pub fn run() {
|
||||
.expect("Failed to export TypeScript bindings");
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(specta_builder.invoke_handler())
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_updater::UpdaterExt;
|
||||
|
||||
pub async fn init(app: &AppHandle) {
|
||||
update_app(app).await
|
||||
}
|
||||
|
||||
async fn update_app(app: &AppHandle) {
|
||||
if let Some(update) = match match app.updater() {
|
||||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
println!("failed to get updater: {err:?}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
.check()
|
||||
.await
|
||||
{
|
||||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
println!("failed to check for update: {err:?}");
|
||||
return;
|
||||
}
|
||||
} {
|
||||
let mut downloaded = 0;
|
||||
|
||||
match update
|
||||
.download_and_install(
|
||||
|chunk_length, content_length| {
|
||||
downloaded += chunk_length;
|
||||
println!("downloaded {downloaded} from {content_length:?}");
|
||||
},
|
||||
|| {
|
||||
println!("download finished");
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
println!("failed to install update: {err:?}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
println!("update installed");
|
||||
app.restart();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"createUpdaterArtifacts": true,
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
@@ -25,5 +26,13 @@
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUzNTFBOTEwMDZBNTExOEQKUldTTkVhVUdFS2xSNHgyK0NiYmZXTy82RlhIYzVxNzNvdHZ5eitiSkozSzU0bm13R0t3QUtnd0oK",
|
||||
"endpoints": [
|
||||
"https://github.com/wind-explorer/friendolls/releases/latest/download/latest.json"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user