Skip to content

Commit f15f127

Browse files
BOTOOMCopilot
andcommitted
fix: stabilize local linux tauri builds
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 197f7bc commit f15f127

6 files changed

Lines changed: 114 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ npm run tauri build
5454
npm run clean
5555
```
5656

57+
On local Linux builds, `npm run tauri build` now auto-enables the AppImage fallback used by `linuxdeploy`, skips the problematic `strip` pass, and disables updater artifacts when no signing key is configured. That makes unsigned local builds work more reliably on distros like Arch/Manjaro.
58+
5759
## Installing from Releases
5860

5961
### Linux

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"preview": "vite preview",
1010
"clean": "bash scripts/clean-artifacts.sh",
1111
"clean:full": "bash scripts/clean-artifacts.sh --full",
12-
"tauri": "tauri"
12+
"tauri": "node scripts/run-tauri.mjs"
1313
},
1414
"dependencies": {
1515
"@tauri-apps/api": "^2",

scripts/run-tauri.mjs

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/usr/bin/env node
2+
3+
import { spawn } from "node:child_process";
4+
import fs from "node:fs";
5+
import path from "node:path";
6+
import process from "node:process";
7+
import { fileURLToPath } from "node:url";
8+
9+
const scriptDir = path.dirname(fileURLToPath(import.meta.url));
10+
const repoRoot = path.resolve(scriptDir, "..");
11+
const packageJsonPath = path.join(repoRoot, "package.json");
12+
const cargoTomlPath = path.join(repoRoot, "src-tauri", "Cargo.toml");
13+
const tauriConfigPath = path.join(repoRoot, "src-tauri", "tauri.conf.json");
14+
15+
function syncCargoVersion(version) {
16+
const current = fs.readFileSync(cargoTomlPath, "utf8");
17+
const next = current.replace(/^version = "[^"]+"/m, `version = "${version}"`);
18+
19+
if (next !== current) {
20+
fs.writeFileSync(cargoTomlPath, next);
21+
return true;
22+
}
23+
24+
return false;
25+
}
26+
27+
function syncTauriConfigVersion(version) {
28+
const current = JSON.parse(fs.readFileSync(tauriConfigPath, "utf8"));
29+
30+
if (current.version === version) {
31+
return false;
32+
}
33+
34+
current.version = version;
35+
fs.writeFileSync(tauriConfigPath, `${JSON.stringify(current, null, 2)}\n`);
36+
return true;
37+
}
38+
39+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
40+
const version = packageJson.version;
41+
const args = process.argv.slice(2);
42+
43+
const cargoSynced = syncCargoVersion(version);
44+
const tauriConfigSynced = syncTauriConfigVersion(version);
45+
const versionSynced = cargoSynced || tauriConfigSynced;
46+
47+
if (versionSynced) {
48+
console.log(`[tauri] Synced src-tauri version files to ${version}`);
49+
}
50+
51+
const env = { ...process.env };
52+
const command = args[0];
53+
const tauriArgs = [...args];
54+
55+
if (
56+
process.platform === "linux" &&
57+
(command === "build" || command === "bundle") &&
58+
!env.APPIMAGE_EXTRACT_AND_RUN
59+
) {
60+
env.APPIMAGE_EXTRACT_AND_RUN = "1";
61+
console.log("[tauri] Enabled APPIMAGE_EXTRACT_AND_RUN=1 for local Linux bundling");
62+
}
63+
64+
if (process.platform === "linux" && (command === "build" || command === "bundle") && !env.NO_STRIP) {
65+
env.NO_STRIP = "1";
66+
console.log("[tauri] Enabled NO_STRIP=1 to avoid linuxdeploy strip failures");
67+
}
68+
69+
if (
70+
(command === "build" || command === "bundle") &&
71+
!env.TAURI_SIGNING_PRIVATE_KEY &&
72+
!env.TAURI_SIGNING_PRIVATE_KEY_PATH
73+
) {
74+
tauriArgs.push(
75+
"--config",
76+
JSON.stringify({
77+
bundle: {
78+
createUpdaterArtifacts: false,
79+
},
80+
})
81+
);
82+
console.log("[tauri] Disabled updater artifacts for this local unsigned build");
83+
}
84+
85+
const tauriBin =
86+
process.platform === "win32"
87+
? path.join(repoRoot, "node_modules", ".bin", "tauri.cmd")
88+
: path.join(repoRoot, "node_modules", ".bin", "tauri");
89+
90+
const child = spawn(tauriBin, tauriArgs, {
91+
cwd: repoRoot,
92+
env,
93+
stdio: "inherit",
94+
});
95+
96+
child.on("exit", (code, signal) => {
97+
if (signal) {
98+
process.kill(process.pid, signal);
99+
return;
100+
}
101+
102+
process.exit(code ?? 0);
103+
});
104+
105+
child.on("error", (error) => {
106+
console.error("[tauri] Failed to start Tauri CLI:", error);
107+
process.exit(1);
108+
});

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cliprithm"
3-
version = "1.0.0"
3+
version = "1.1.0"
44
description = "Cliprithm — Smart video silence remover"
55
authors = ["Edwar Diaz <edwardiaz.dev>"]
66
edition = "2021"
@@ -29,4 +29,3 @@ tokio = { version = "1", features = ["full"] }
2929
regex = "1"
3030
tempfile = "3"
3131
chrono = { version = "0.4", features = ["serde"] }
32-

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "Cliprithm",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"identifier": "com.botom.cliprithm",
66
"build": {
77
"beforeDevCommand": "npm run dev",

0 commit comments

Comments
 (0)