Skip to content

Commit 46df2c9

Browse files
authored
fix(bundler): sort package types before bundling, closes #7349 (#7360)
fix(bundler): sort package types before bundling, closes #7349
1 parent f4aedce commit 46df2c9

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

.changes/bundler-bundle-order.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-bundler': 'patch:bug'
3+
---
4+
5+
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).

tooling/bundler/src/bundle.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ pub struct Bundle {
4343
/// Bundles the project.
4444
/// Returns the list of paths where the bundles can be found.
4545
pub fn bundle_project(settings: Settings) -> crate::Result<Vec<Bundle>> {
46-
let package_types = settings.package_types()?;
46+
let mut package_types = settings.package_types()?;
4747
if package_types.is_empty() {
4848
return Ok(Vec::new());
4949
}
5050

51+
package_types.sort_by_key(|a| a.priority());
52+
5153
let mut bundles: Vec<Bundle> = Vec::new();
5254

5355
let target_os = settings

tooling/bundler/src/bundle/settings.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ impl PackageType {
9393
pub fn all() -> &'static [PackageType] {
9494
ALL_PACKAGE_TYPES
9595
}
96+
97+
/// Gets a number representing priority which used to sort package types
98+
/// in an order that guarantees that if a certain package type
99+
/// depends on another (like Dmg depending on MacOsBundle), the dependency
100+
/// will be built first
101+
///
102+
/// The lower the number, the higher the priority
103+
pub fn priority(&self) -> u32 {
104+
match self {
105+
PackageType::MacOsBundle => 0,
106+
PackageType::IosBundle => 0,
107+
PackageType::WindowsMsi => 0,
108+
PackageType::Nsis => 0,
109+
PackageType::Deb => 0,
110+
PackageType::Rpm => 0,
111+
PackageType::AppImage => 0,
112+
PackageType::Dmg => 1,
113+
PackageType::Updater => 2,
114+
}
115+
}
96116
}
97117

98118
const ALL_PACKAGE_TYPES: &[PackageType] = &[

tooling/cli/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ pub fn command(mut options: Options, verbosity: u8) -> Result<()> {
324324
"The updater secret key from `TAURI_PRIVATE_KEY` does not match the public key defined in `tauri.conf.json > tauri > updater > pubkey`."
325325
));
326326
}
327-
signed_paths.append(&mut vec![signature_path]);
327+
signed_paths.push(signature_path);
328328
}
329329
}
330330

0 commit comments

Comments
 (0)