Skip to content

Commit

Permalink
fix: Add support for new linux bundle naming scheme in cli@v2-beta.19 (
Browse files Browse the repository at this point in the history
…#810)

* fix: Add support for new linux bundle format added in cli@v2-beta.19

* typo

* fix -> patch

* don't search for same artifacts twice if productName is not set
  • Loading branch information
FabianLars committed Jun 3, 2024
1 parent 87ad908 commit 10eca12
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .changes/v2-bundle-compat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
action: patch
---

The action can now detects Linux bundles with the new naming convention added in tauri cli 2.0.0-beta.19
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

88 changes: 62 additions & 26 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,13 @@ export async function buildProject(

await runner.execTauriCommand(['build'], [...tauriArgs], root);

let fileAppName = app.name;
// on Linux, the app product name is converted to kebab-case
if (targetInfo.platform === 'linux') {
fileAppName = fileAppName
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
.replace(/[ _.]/g, '-')
.toLowerCase();
}
// with tauri-cli 2.0.0-beta.19 deb and appimage will now use the product name as on the other platforms.
const linuxFileAppName = app.name
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
.replace(/[ _.]/g, '-')
.toLowerCase();

const workspacePath = getWorkspaceDir(app.tauriPath) ?? app.tauriPath;

Expand All @@ -95,13 +93,10 @@ export async function buildProject(
}

artifacts = [
join(
artifactsPath,
`bundle/dmg/${fileAppName}_${app.version}_${arch}.dmg`,
),
join(artifactsPath, `bundle/macos/${fileAppName}.app`),
join(artifactsPath, `bundle/macos/${fileAppName}.app.tar.gz`),
join(artifactsPath, `bundle/macos/${fileAppName}.app.tar.gz.sig`),
join(artifactsPath, `bundle/dmg/${app.name}_${app.version}_${arch}.dmg`),
join(artifactsPath, `bundle/macos/${app.name}.app`),
join(artifactsPath, `bundle/macos/${app.name}.app.tar.gz`),
join(artifactsPath, `bundle/macos/${app.name}.app.tar.gz.sig`),
].map((path) => ({ path, arch }));
} else if (targetInfo.platform === 'windows') {
if (arch.startsWith('i')) {
Expand Down Expand Up @@ -129,39 +124,39 @@ export async function buildProject(
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.wixAppVersion}_${arch}_${lang}.msi`,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.wixAppVersion}_${arch}_${lang}.msi.zip`,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi.zip`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/msi/${fileAppName}_${app.wixAppVersion}_${arch}_${lang}.msi.zip.sig`,
`bundle/msi/${app.name}_${app.wixAppVersion}_${arch}_${lang}.msi.zip.sig`,
),
);
});

winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.exe`,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.exe`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip`,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.nsis.zip`,
),
);
winArtifacts.push(
join(
artifactsPath,
`bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip.sig`,
`bundle/nsis/${app.name}_${app.version}_${arch}-setup.nsis.zip.sig`,
),
);

Expand Down Expand Up @@ -200,39 +195,80 @@ export async function buildProject(
{
path: join(
artifactsPath,
`bundle/deb/${fileAppName}_${app.version}_${debianArch}.deb`,
`bundle/deb/${app.name}_${app.version}_${debianArch}.deb`,
),
arch: debianArch,
},
{
path: join(
artifactsPath,
`bundle/rpm/${fileAppName}-${app.version}-${app.rpmRelease}.${rpmArch}.rpm`,
// TODO: Upstream bug?
`bundle/rpm/${linuxFileAppName}-${app.version}-${app.rpmRelease}.${rpmArch}.rpm`,
),
arch: rpmArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${fileAppName}_${app.version}_${appImageArch}.AppImage`,
`bundle/appimage/${app.name}_${app.version}_${appImageArch}.AppImage`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${fileAppName}_${app.version}_${appImageArch}.AppImage.tar.gz`,
`bundle/appimage/${app.name}_${app.version}_${appImageArch}.AppImage.tar.gz`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${fileAppName}_${app.version}_${appImageArch}.AppImage.tar.gz.sig`,
`bundle/appimage/${app.name}_${app.version}_${appImageArch}.AppImage.tar.gz.sig`,
),
arch: appImageArch,
},
];

if (app.name != linuxFileAppName) {
artifacts.push(
{
path: join(
artifactsPath,
`bundle/deb/${linuxFileAppName}_${app.version}_${debianArch}.deb`,
),
arch: debianArch,
},
/* {
path: join(
artifactsPath,
`bundle/rpm/${linuxFileAppName}-${app.version}-${app.rpmRelease}.${rpmArch}.rpm`,
),
arch: rpmArch,
}, */
{
path: join(
artifactsPath,
`bundle/appimage/${linuxFileAppName}_${app.version}_${appImageArch}.AppImage`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${linuxFileAppName}_${app.version}_${appImageArch}.AppImage.tar.gz`,
),
arch: appImageArch,
},
{
path: join(
artifactsPath,
`bundle/appimage/${linuxFileAppName}_${app.version}_${appImageArch}.AppImage.tar.gz.sig`,
),
arch: appImageArch,
},
);
}
}

console.log(
Expand Down

0 comments on commit 10eca12

Please sign in to comment.