CI/CD & auto-updates first try pls
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user