Skip to content

Commit

Permalink
fix(bundler): sort package types before bundling, closes #7349 (#7360)
Browse files Browse the repository at this point in the history
fix(bundler): sort package types before bundling, closes #7349
  • Loading branch information
amrbashir committed Jul 5, 2023
1 parent f4aedce commit 46df2c9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changes/bundler-bundle-order.md
Original file line number Diff line number Diff line change
@@ -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).
4 changes: 3 additions & 1 deletion tooling/bundler/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Bundle>> {
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<Bundle> = Vec::new();

let target_os = settings
Expand Down
20 changes: 20 additions & 0 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = &[
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 46df2c9

Please sign in to comment.