Skip to content

Commit bbf307c

Browse files
committed
chore(build): remove deprecated tauri build script and update publish workflow for Linux compatibility
1 parent 0ff491c commit bbf307c

4 files changed

Lines changed: 59 additions & 36 deletions

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,12 @@ jobs:
145145
rust_target: x86_64-unknown-linux-gnu
146146
args: ''
147147
cache_key: ubuntu-x86_64
148-
tauri_script: 'npm run tauri:build:linux --'
149148
- label: linux-arm64
150149
platform: 'ubuntu-22.04-arm'
151150
arch: aarch64
152151
rust_target: aarch64-unknown-linux-gnu
153152
args: ''
154153
cache_key: ubuntu-aarch64
155-
tauri_script: 'npm run tauri:build:linux --'
156154
- label: windows-x64
157155
platform: 'windows-latest'
158156
arch: x86_64
@@ -297,11 +295,21 @@ jobs:
297295
releaseId: ${{ needs.prepare-release.outputs.release_id }}
298296
tagName: ${{ github.ref_name }}
299297
args: ${{ matrix.args }}
300-
tauriScript: ${{ matrix.tauri_script || 'npm run tauri --' }}
301298
releaseDraft: true
302299
prerelease: false
303300
includeUpdaterJson: true
304301

302+
# Tauri's bundler hardcodes Ubuntu 22.04 deb dependency names. Rewrite them
303+
# to also accept Debian / Ubuntu 24.04+ names, then overwrite the uploaded asset.
304+
- name: Patch Linux .deb dependencies (ubuntu only)
305+
if: contains(matrix.platform, 'ubuntu')
306+
shell: bash
307+
env:
308+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
309+
GITHUB_REPOSITORY: ${{ github.repository }}
310+
RELEASE_ID: ${{ needs.prepare-release.outputs.release_id }}
311+
run: node scripts/patch-linux-deb.js
312+
305313
# Uses repository secrets: ANDROID_KEY_BASE64, ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD
306314
# (same names as https://v2.tauri.app/distribute/sign/android/).
307315
# Builds universal (F-Droid) + per-ABI APKs (arm64, armv7, x86, x86_64); see scripts/android-release-build.js.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"build": "tsc -b && vite build",
99
"preview": "vite preview",
1010
"tauri": "tauri",
11-
"tauri:build:linux": "node ./scripts/tauri-build-linux.js",
1211
"android:dev": "tauri android dev",
1312
"android:build": "tauri android build",
1413
"release": "node ./scripts/release.js",
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!/usr/bin/env node
22

33
/**
4-
* Linux release build: run `tauri build`, then rewrite the .deb dependency
5-
* metadata so installs work on Debian and Ubuntu.
4+
* Rewrites .deb dependency metadata so installs work on Debian and Ubuntu, then
5+
* re-uploads the patched package to the GitHub release (overwriting the asset
6+
* that tauri-action just uploaded).
67
*
78
* Tauri's bundler emits Ubuntu 22.04 package names (libappindicator3-1,
89
* libgtk-3-0). Debian and newer Ubuntu releases use libayatana-appindicator3-1
910
* and libgtk-3-0t64 instead, so we declare both alternatives.
11+
*
12+
* Runs as a post-build step in CI. Re-upload is skipped when RELEASE_ID is not
13+
* set, so the script can also be run locally to patch a build.
1014
*/
1115

1216
import fs from 'node:fs'
@@ -20,19 +24,6 @@ const repoRoot = path.join(__dirname, '..')
2024
const COMPATIBLE_DEPENDS =
2125
'libayatana-appindicator3-1 | libappindicator3-1, libwebkit2gtk-4.1-0, libgtk-3-0t64 | libgtk-3-0'
2226

23-
function runTauriBuild(args) {
24-
if (args.length === 0) {
25-
console.error('Usage: node scripts/tauri-build-linux.js <tauri args...>')
26-
process.exit(1)
27-
}
28-
29-
execSync(`npx tauri ${args.map((arg) => JSON.stringify(arg)).join(' ')}`, {
30-
cwd: repoRoot,
31-
stdio: 'inherit',
32-
shell: true,
33-
})
34-
}
35-
3627
function findDebArtifacts() {
3728
const debDir = path.join(repoRoot, 'src-tauri/target/release/bundle/deb')
3829
if (!fs.existsSync(debDir)) {
@@ -48,12 +39,9 @@ function findDebArtifacts() {
4839
function patchDeb(debPath) {
4940
const tmpDir = fs.mkdtempSync(path.join('/tmp', 'altsendme-deb-'))
5041
try {
51-
execSync(
52-
`dpkg-deb -R ${JSON.stringify(debPath)} ${JSON.stringify(tmpDir)}`,
53-
{
54-
stdio: 'pipe',
55-
}
56-
)
42+
execSync(`dpkg-deb -R ${JSON.stringify(debPath)} ${JSON.stringify(tmpDir)}`, {
43+
stdio: 'pipe',
44+
})
5745

5846
const controlPath = path.join(tmpDir, 'DEBIAN', 'control')
5947
const original = fs.readFileSync(controlPath, 'utf8')
@@ -67,31 +55,58 @@ function patchDeb(debPath) {
6755
)
6856
if (patched === original) {
6957
console.log(`Already compatible: ${debPath}`)
70-
return
58+
return false
7159
}
7260

7361
fs.writeFileSync(controlPath, patched)
74-
execSync(
75-
`dpkg-deb -b ${JSON.stringify(tmpDir)} ${JSON.stringify(debPath)}`,
76-
{
77-
stdio: 'pipe',
78-
}
79-
)
62+
execSync(`dpkg-deb -b ${JSON.stringify(tmpDir)} ${JSON.stringify(debPath)}`, {
63+
stdio: 'pipe',
64+
})
8065

8166
console.log(`Patched ${debPath}`)
8267
console.log(` Depends: ${COMPATIBLE_DEPENDS}`)
68+
return true
8369
} finally {
8470
fs.rmSync(tmpDir, { recursive: true, force: true })
8571
}
8672
}
8773

88-
runTauriBuild(process.argv.slice(2))
74+
function reuploadAsset(debPath) {
75+
const releaseId = process.env.RELEASE_ID
76+
const repo = process.env.GITHUB_REPOSITORY
77+
if (!releaseId || !repo) {
78+
console.log('RELEASE_ID/GITHUB_REPOSITORY not set; skipping re-upload.')
79+
return
80+
}
81+
82+
const name = path.basename(debPath)
83+
const assetId = execSync(
84+
`gh api "repos/${repo}/releases/${releaseId}/assets" --jq ".[] | select(.name == \\"${name}\\") | .id // empty"`
85+
)
86+
.toString()
87+
.trim()
88+
89+
if (assetId) {
90+
execSync(`gh api --method DELETE "repos/${repo}/releases/assets/${assetId}"`, {
91+
stdio: 'pipe',
92+
})
93+
}
94+
95+
execSync(
96+
`gh api --method POST -H "Content-Type: application/vnd.debian.binary-package" --input ${JSON.stringify(debPath)} "https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${name}"`,
97+
{ stdio: 'pipe' }
98+
)
99+
console.log(`Re-uploaded ${name} to release ${releaseId}`)
100+
}
89101

90102
const debPaths = findDebArtifacts()
91103
if (debPaths.length === 0) {
92104
console.log('No .deb artifacts found; skipping dependency patch.')
93105
} else {
94106
for (const debPath of debPaths) {
95-
patchDeb(debPath)
107+
const changed = patchDeb(debPath)
108+
if (changed) {
109+
reuploadAsset(debPath)
110+
}
96111
}
97112
}

src-tauri/src/tray.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
use std::sync::atomic::{AtomicBool, Ordering};
2-
31
use tauri::{AppHandle, Manager};
42

3+
#[cfg(not(target_os = "macos"))]
4+
use std::sync::atomic::{AtomicBool, Ordering};
5+
56
#[cfg(not(target_os = "macos"))]
67
use tauri::{
78
menu::{Menu, MenuItem},

0 commit comments

Comments
 (0)