From 2e510f9dbbbc3cc3bc7dd3b36aab8237c40ed956 Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 21:29:16 +0800 Subject: [PATCH 1/7] Fix better-sqlite3 for ARM64 Linux - Use ubuntu-24.04-arm for ARM64 Linux builds - Add TARGET_ARCH support to electron-rebuild - Add test workflow for ARM64 fix --- .github/actions/build-electron/action.yml | 1 + .github/workflows/release.yml | 11 ++++++++ .github/workflows/test-arm64-fix.yml | 32 +++++++++++++++++++++++ scripts/electron-rebuild.mts | 4 ++- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test-arm64-fix.yml diff --git a/.github/actions/build-electron/action.yml b/.github/actions/build-electron/action.yml index 26d35b79f..9e4a16620 100644 --- a/.github/actions/build-electron/action.yml +++ b/.github/actions/build-electron/action.yml @@ -86,6 +86,7 @@ runs: APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }} WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }} TRILIUM_ARTIFACT_NAME_HINT: TriliumNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }} + TARGET_ARCH: ${{ inputs.arch }} run: pnpm run --filter desktop electron-forge:make --arch=${{ inputs.arch }} --platform=${{ inputs.forge_platform }} # Add DMG signing step diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 16dec7492..a930984de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,17 @@ jobs: image: win-signing shell: cmd forge_platform: win32 + exclude: + - arch: arm64 + os: + name: linux + include: + - arch: arm64 + os: + name: linux + image: ubuntu-24.04-arm + shell: bash + forge_platform: linux runs-on: ${{ matrix.os.image }} steps: - uses: actions/checkout@v5 diff --git a/.github/workflows/test-arm64-fix.yml b/.github/workflows/test-arm64-fix.yml new file mode 100644 index 000000000..cf69303a7 --- /dev/null +++ b/.github/workflows/test-arm64-fix.yml @@ -0,0 +1,32 @@ +name: Test ARM64 Fix +on: + push: + branches: [ fix-arm64-sqlite ] + workflow_dispatch: + +jobs: + test-arm64-rebuild: + runs-on: ubuntu-24.04-arm + steps: + - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v5 + with: + node-version: 22 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Test rebuild with TARGET_ARCH + env: + TARGET_ARCH: arm64 + run: | + echo "Testing electron-rebuild with TARGET_ARCH=arm64" + pnpm postinstall + echo "Checking better-sqlite3 architecture:" + file apps/desktop/node_modules/better-sqlite3/build/Release/better_sqlite3.node || echo "File not found" + - name: Test desktop build + env: + TARGET_ARCH: arm64 + run: | + echo "Testing desktop build" + pnpm run --filter desktop build \ No newline at end of file diff --git a/scripts/electron-rebuild.mts b/scripts/electron-rebuild.mts index 48ede8cdd..6ed8360e7 100644 --- a/scripts/electron-rebuild.mts +++ b/scripts/electron-rebuild.mts @@ -24,13 +24,15 @@ function rebuildNativeDependencies(projectRoot: string) { process.exit(1); } - console.log(`Rebuilding ${projectRoot} with ${electronVersion}...`); + const targetArch = process.env.TARGET_ARCH || process.arch; + console.log(`Rebuilding ${projectRoot} with ${electronVersion} for ${targetArch}...`); const resolvedPath = resolve(projectRoot); rebuild({ projectRootPath: resolvedPath, buildPath: resolvedPath, electronVersion, + arch: targetArch, force: true }); } From cc51fbe77ef72ed15c9a656b1337ce21d0ff3dc6 Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 21:35:00 +0800 Subject: [PATCH 2/7] Update test workflow to build and check packages --- .github/workflows/test-arm64-fix.yml | 34 +++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-arm64-fix.yml b/.github/workflows/test-arm64-fix.yml index cf69303a7..2ecd092fc 100644 --- a/.github/workflows/test-arm64-fix.yml +++ b/.github/workflows/test-arm64-fix.yml @@ -24,9 +24,37 @@ jobs: pnpm postinstall echo "Checking better-sqlite3 architecture:" file apps/desktop/node_modules/better-sqlite3/build/Release/better_sqlite3.node || echo "File not found" - - name: Test desktop build + - name: Build desktop package env: TARGET_ARCH: arm64 run: | - echo "Testing desktop build" - pnpm run --filter desktop build \ No newline at end of file + echo "Building desktop package for ARM64" + pnpm run --filter desktop electron-forge:make --arch=arm64 --platform=linux + + - name: Check better-sqlite3 in package + run: | + echo "Checking built packages:" + find apps/desktop/out -name "*.deb" -o -name "*.rpm" -o -name "*.tar.gz" -o -name "*.AppImage" | head -5 + + echo "\nExtracting and checking better-sqlite3:" + cd apps/desktop/out + + # Find the built package + PACKAGE=$(find . -name "*.deb" | head -1) + if [ -n "$PACKAGE" ]; then + echo "Found DEB package: $PACKAGE" + dpkg-deb -x "$PACKAGE" extracted/ + echo "Checking for better-sqlite3 files:" + find extracted/ -name "*sqlite*" -type f + echo "\nChecking architecture of better-sqlite3.node:" + find extracted/ -name "better_sqlite3.node" -exec file {} \; + else + echo "No DEB package found, checking other formats..." + ls -la + fi + + - name: Upload built package + uses: actions/upload-artifact@v4 + with: + name: trilium-arm64-linux-test + path: apps/desktop/out/* \ No newline at end of file From c77b7f8c744e2b70f2c5ec90076f2aa87662eefa Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 21:35:50 +0800 Subject: [PATCH 3/7] Add detailed better_sqlite3.node checking - Check exact path: app.asar.unpacked/node_modules/better-sqlite3/build/Release/ - Verify file existence and architecture - Upload artifacts for manual inspection --- .github/workflows/test-arm64-fix.yml | 34 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-arm64-fix.yml b/.github/workflows/test-arm64-fix.yml index 2ecd092fc..f26334b24 100644 --- a/.github/workflows/test-arm64-fix.yml +++ b/.github/workflows/test-arm64-fix.yml @@ -33,10 +33,10 @@ jobs: - name: Check better-sqlite3 in package run: | - echo "Checking built packages:" - find apps/desktop/out -name "*.deb" -o -name "*.rpm" -o -name "*.tar.gz" -o -name "*.AppImage" | head -5 + echo "=== Checking built packages ===" + find apps/desktop/out -type f | head -10 - echo "\nExtracting and checking better-sqlite3:" + echo "\n=== Extracting and checking better-sqlite3 ===" cd apps/desktop/out # Find the built package @@ -44,17 +44,31 @@ jobs: if [ -n "$PACKAGE" ]; then echo "Found DEB package: $PACKAGE" dpkg-deb -x "$PACKAGE" extracted/ - echo "Checking for better-sqlite3 files:" - find extracted/ -name "*sqlite*" -type f - echo "\nChecking architecture of better-sqlite3.node:" - find extracted/ -name "better_sqlite3.node" -exec file {} \; + + echo "\n=== Checking target path ===" + TARGET_PATH="extracted/opt/Trilium Notes/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node" + if [ -f "$TARGET_PATH" ]; then + echo "✅ Found better_sqlite3.node at expected path" + echo "File info:" + file "$TARGET_PATH" + ls -la "$TARGET_PATH" + else + echo "❌ better_sqlite3.node NOT found at expected path" + echo "Searching for better-sqlite3 files:" + find extracted/ -name "*sqlite*" -type f + echo "\nSearching for .node files:" + find extracted/ -name "*.node" -type f + fi else - echo "No DEB package found, checking other formats..." - ls -la + echo "No DEB package found, checking dist directory:" + find ../dist -name "better_sqlite3.node" -exec file {} \; 2>/dev/null || echo "No .node files in dist" fi - name: Upload built package uses: actions/upload-artifact@v4 + if: always() with: name: trilium-arm64-linux-test - path: apps/desktop/out/* \ No newline at end of file + path: | + apps/desktop/out/* + apps/desktop/dist/* \ No newline at end of file From 67c99dea2d1c472ff78e82ec47304d77640f18b4 Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 21:40:34 +0800 Subject: [PATCH 4/7] Fix flatpak dependencies for ARM64 build --- .github/workflows/test-arm64-fix.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test-arm64-fix.yml b/.github/workflows/test-arm64-fix.yml index f26334b24..2ac2bc46e 100644 --- a/.github/workflows/test-arm64-fix.yml +++ b/.github/workflows/test-arm64-fix.yml @@ -14,6 +14,14 @@ jobs: with: node-version: 22 cache: 'pnpm' + - name: Install system dependencies + run: | + sudo apt-get update && sudo apt-get install -y flatpak-builder elfutils + flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + FLATPAK_ARCH="aarch64" + FLATPAK_VERSION="24.08" + flatpak install --user --no-deps --arch $FLATPAK_ARCH --assumeyes runtime/org.freedesktop.Platform/$FLATPAK_ARCH/$FLATPAK_VERSION runtime/org.freedesktop.Sdk/$FLATPAK_ARCH/$FLATPAK_VERSION org.electronjs.Electron2.BaseApp/$FLATPAK_ARCH/$FLATPAK_VERSION + - name: Install dependencies run: pnpm install --frozen-lockfile - name: Test rebuild with TARGET_ARCH From 66c05619df0a7561319d6485c57c3c7c1eda80a3 Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 21:51:27 +0800 Subject: [PATCH 5/7] Fix path checking in test workflow --- .github/workflows/test-arm64-fix.yml | 51 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test-arm64-fix.yml b/.github/workflows/test-arm64-fix.yml index 2ac2bc46e..575b2f9b0 100644 --- a/.github/workflows/test-arm64-fix.yml +++ b/.github/workflows/test-arm64-fix.yml @@ -41,35 +41,33 @@ jobs: - name: Check better-sqlite3 in package run: | - echo "=== Checking built packages ===" - find apps/desktop/out -type f | head -10 + echo "=== Checking build directories ===" + ls -la apps/desktop/ || true + find apps/desktop -name "out" -o -name "dist" -o -name "upload" 2>/dev/null || true - echo "\n=== Extracting and checking better-sqlite3 ===" - cd apps/desktop/out + echo "\n=== Looking for built packages ===" + FOUND_PACKAGES=$(find apps/desktop -name "*.deb" -o -name "*.rpm" -o -name "*.tar.gz" -o -name "*.AppImage" 2>/dev/null || true) - # Find the built package - PACKAGE=$(find . -name "*.deb" | head -1) - if [ -n "$PACKAGE" ]; then - echo "Found DEB package: $PACKAGE" - dpkg-deb -x "$PACKAGE" extracted/ + if [ -n "$FOUND_PACKAGES" ]; then + echo "Found packages:" + echo "$FOUND_PACKAGES" - echo "\n=== Checking target path ===" - TARGET_PATH="extracted/opt/Trilium Notes/resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node" - if [ -f "$TARGET_PATH" ]; then - echo "✅ Found better_sqlite3.node at expected path" - echo "File info:" - file "$TARGET_PATH" - ls -la "$TARGET_PATH" - else - echo "❌ better_sqlite3.node NOT found at expected path" - echo "Searching for better-sqlite3 files:" - find extracted/ -name "*sqlite*" -type f - echo "\nSearching for .node files:" - find extracted/ -name "*.node" -type f + # Use first DEB package + PACKAGE=$(echo "$FOUND_PACKAGES" | grep "\.deb" | head -1) + if [ -n "$PACKAGE" ]; then + echo "\n=== Extracting DEB package: $PACKAGE ===" + mkdir -p /tmp/extracted + dpkg-deb -x "$PACKAGE" /tmp/extracted/ + + echo "\n=== Checking for better_sqlite3.node ===" + find /tmp/extracted -name "better_sqlite3.node" -exec file {} \; || echo "No better_sqlite3.node found" + + echo "\n=== Checking all .node files ===" + find /tmp/extracted -name "*.node" -exec file {} \; || echo "No .node files found" fi else - echo "No DEB package found, checking dist directory:" - find ../dist -name "better_sqlite3.node" -exec file {} \; 2>/dev/null || echo "No .node files in dist" + echo "No packages found, checking dist directory:" + find apps/desktop -name "better_sqlite3.node" -exec file {} \; 2>/dev/null || echo "No .node files found" fi - name: Upload built package @@ -78,5 +76,6 @@ jobs: with: name: trilium-arm64-linux-test path: | - apps/desktop/out/* - apps/desktop/dist/* \ No newline at end of file + apps/desktop/out/ + apps/desktop/dist/ + apps/desktop/upload/ \ No newline at end of file From a274da80b751b9b6bd5a22a4e5f3364277899506 Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 22:02:51 +0800 Subject: [PATCH 6/7] Remove test workflow, prepare for PR Core changes for ARM64 Linux better-sqlite3 fix: - .github/workflows/release.yml: Use ubuntu-24.04-arm for ARM64 Linux - .github/actions/build-electron/action.yml: Add TARGET_ARCH env var - scripts/electron-rebuild.mts: Add arch parameter to rebuild --- .github/workflows/test-arm64-fix.yml | 81 ---------------------------- 1 file changed, 81 deletions(-) delete mode 100644 .github/workflows/test-arm64-fix.yml diff --git a/.github/workflows/test-arm64-fix.yml b/.github/workflows/test-arm64-fix.yml deleted file mode 100644 index 575b2f9b0..000000000 --- a/.github/workflows/test-arm64-fix.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Test ARM64 Fix -on: - push: - branches: [ fix-arm64-sqlite ] - workflow_dispatch: - -jobs: - test-arm64-rebuild: - runs-on: ubuntu-24.04-arm - steps: - - uses: actions/checkout@v5 - - uses: pnpm/action-setup@v4 - - uses: actions/setup-node@v5 - with: - node-version: 22 - cache: 'pnpm' - - name: Install system dependencies - run: | - sudo apt-get update && sudo apt-get install -y flatpak-builder elfutils - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - FLATPAK_ARCH="aarch64" - FLATPAK_VERSION="24.08" - flatpak install --user --no-deps --arch $FLATPAK_ARCH --assumeyes runtime/org.freedesktop.Platform/$FLATPAK_ARCH/$FLATPAK_VERSION runtime/org.freedesktop.Sdk/$FLATPAK_ARCH/$FLATPAK_VERSION org.electronjs.Electron2.BaseApp/$FLATPAK_ARCH/$FLATPAK_VERSION - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - name: Test rebuild with TARGET_ARCH - env: - TARGET_ARCH: arm64 - run: | - echo "Testing electron-rebuild with TARGET_ARCH=arm64" - pnpm postinstall - echo "Checking better-sqlite3 architecture:" - file apps/desktop/node_modules/better-sqlite3/build/Release/better_sqlite3.node || echo "File not found" - - name: Build desktop package - env: - TARGET_ARCH: arm64 - run: | - echo "Building desktop package for ARM64" - pnpm run --filter desktop electron-forge:make --arch=arm64 --platform=linux - - - name: Check better-sqlite3 in package - run: | - echo "=== Checking build directories ===" - ls -la apps/desktop/ || true - find apps/desktop -name "out" -o -name "dist" -o -name "upload" 2>/dev/null || true - - echo "\n=== Looking for built packages ===" - FOUND_PACKAGES=$(find apps/desktop -name "*.deb" -o -name "*.rpm" -o -name "*.tar.gz" -o -name "*.AppImage" 2>/dev/null || true) - - if [ -n "$FOUND_PACKAGES" ]; then - echo "Found packages:" - echo "$FOUND_PACKAGES" - - # Use first DEB package - PACKAGE=$(echo "$FOUND_PACKAGES" | grep "\.deb" | head -1) - if [ -n "$PACKAGE" ]; then - echo "\n=== Extracting DEB package: $PACKAGE ===" - mkdir -p /tmp/extracted - dpkg-deb -x "$PACKAGE" /tmp/extracted/ - - echo "\n=== Checking for better_sqlite3.node ===" - find /tmp/extracted -name "better_sqlite3.node" -exec file {} \; || echo "No better_sqlite3.node found" - - echo "\n=== Checking all .node files ===" - find /tmp/extracted -name "*.node" -exec file {} \; || echo "No .node files found" - fi - else - echo "No packages found, checking dist directory:" - find apps/desktop -name "better_sqlite3.node" -exec file {} \; 2>/dev/null || echo "No .node files found" - fi - - - name: Upload built package - uses: actions/upload-artifact@v4 - if: always() - with: - name: trilium-arm64-linux-test - path: | - apps/desktop/out/ - apps/desktop/dist/ - apps/desktop/upload/ \ No newline at end of file From dbad13c4e28d5f706c9e6ebea640da1431bc3d6e Mon Sep 17 00:00:00 2001 From: linull Date: Tue, 16 Sep 2025 22:13:26 +0800 Subject: [PATCH 7/7] Add comments explaining exclude/include matrix configuration --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a930984de..6a0a38752 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,10 +30,12 @@ jobs: image: win-signing shell: cmd forge_platform: win32 + # Exclude ARM64 Linux from default matrix to use native runner exclude: - arch: arm64 os: name: linux + # Add ARM64 Linux with native ubuntu-24.04-arm runner for better-sqlite3 compatibility include: - arch: arm64 os: