From 46df2c9b917096388695f72ca4c56791fe652ef6 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 5 Jul 2023 23:17:31 +0300 Subject: [PATCH] fix(bundler): sort package types before bundling, closes #7349 (#7360) fix(bundler): sort package types before bundling, closes #7349 --- .changes/bundler-bundle-order.md | 5 +++++ tooling/bundler/src/bundle.rs | 4 +++- tooling/bundler/src/bundle/settings.rs | 20 ++++++++++++++++++++ tooling/cli/src/build.rs | 2 +- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 .changes/bundler-bundle-order.md diff --git a/.changes/bundler-bundle-order.md b/.changes/bundler-bundle-order.md new file mode 100644 index 000000000000..35f5443f0c29 --- /dev/null +++ b/.changes/bundler-bundle-order.md @@ -0,0 +1,5 @@ +--- +'tauri-bundler': 'patch:bug' +--- + +Fix bundler skipping updater artifacts if `updater` target shows before other updater-enabled targets in the list, see [#7349](https://github.com/tauri-apps/tauri/issues/7349). diff --git a/tooling/bundler/src/bundle.rs b/tooling/bundler/src/bundle.rs index 04966bac6629..375ad212c664 100644 --- a/tooling/bundler/src/bundle.rs +++ b/tooling/bundler/src/bundle.rs @@ -43,11 +43,13 @@ pub struct Bundle { /// Bundles the project. /// Returns the list of paths where the bundles can be found. pub fn bundle_project(settings: Settings) -> crate::Result> { - let package_types = settings.package_types()?; + let mut package_types = settings.package_types()?; if package_types.is_empty() { return Ok(Vec::new()); } + package_types.sort_by_key(|a| a.priority()); + let mut bundles: Vec = Vec::new(); let target_os = settings diff --git a/tooling/bundler/src/bundle/settings.rs b/tooling/bundler/src/bundle/settings.rs index ed09964c650e..613e12931fc7 100644 --- a/tooling/bundler/src/bundle/settings.rs +++ b/tooling/bundler/src/bundle/settings.rs @@ -93,6 +93,26 @@ impl PackageType { pub fn all() -> &'static [PackageType] { ALL_PACKAGE_TYPES } + + /// Gets a number representing priority which used to sort package types + /// in an order that guarantees that if a certain package type + /// depends on another (like Dmg depending on MacOsBundle), the dependency + /// will be built first + /// + /// The lower the number, the higher the priority + pub fn priority(&self) -> u32 { + match self { + PackageType::MacOsBundle => 0, + PackageType::IosBundle => 0, + PackageType::WindowsMsi => 0, + PackageType::Nsis => 0, + PackageType::Deb => 0, + PackageType::Rpm => 0, + PackageType::AppImage => 0, + PackageType::Dmg => 1, + PackageType::Updater => 2, + } + } } const ALL_PACKAGE_TYPES: &[PackageType] = &[ diff --git a/tooling/cli/src/build.rs b/tooling/cli/src/build.rs index 6b668b91c46c..cd51e802d451 100644 --- a/tooling/cli/src/build.rs +++ b/tooling/cli/src/build.rs @@ -324,7 +324,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> { "The updater secret key from `TAURI_PRIVATE_KEY` does not match the public key defined in `tauri.conf.json > tauri > updater > pubkey`." )); } - signed_paths.append(&mut vec![signature_path]); + signed_paths.push(signature_path); } }