From 4fb5461321e0399f5c201fcc5df5dbbe4b9526e7 Mon Sep 17 00:00:00 2001 From: MiTHRAL Date: Tue, 21 Apr 2026 14:37:52 -0400 Subject: [PATCH] fix: stamp package.json version from git tag at build time, add updater logging Auto-updater was always reporting version 1.3.0 regardless of release, making it impossible to detect whether an update had been applied. CI now rewrites package.json version from the tag before building. Updater errors are now logged to console instead of silently swallowed. Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/build.yml | 6 ++++++ src/native/updater.ts | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 55e1ddf..43655a7 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -21,6 +21,12 @@ jobs: - name: Install dependencies run: pnpm install + - name: Set version from tag + run: | + VERSION="${{ github.ref_name }}" + VERSION="${VERSION#v}" + node -e "const fs=require('fs'),p=JSON.parse(fs.readFileSync('package.json')); p.version='$VERSION'; fs.writeFileSync('package.json', JSON.stringify(p, null, 2)+'\n')" + - name: Install Linux build deps run: apt-get update && apt-get install -y --fix-missing python3 make g++ libgtk-3-dev libnss3-dev libxss1 libasound2-dev libgbm-dev dpkg fakeroot zip diff --git a/src/native/updater.ts b/src/native/updater.ts index b0c7147..2e17ba7 100644 --- a/src/native/updater.ts +++ b/src/native/updater.ts @@ -32,12 +32,16 @@ export async function checkForUpdates() { if (!isNewer(latest, current)) return; const asset = findAsset(release.assets); - if (!asset) return; + if (!asset) { + console.error("[updater] no matching asset found for platform:", process.platform, release.assets.map(a => a.name)); + return; + } + console.log(`[updater] update available: ${current} → ${latest}, downloading ${asset.name}`); notify("Update Downloading", `Sanctum ${latest} is downloading in the background…`); await downloadAndInstall(asset.browser_download_url, latest); - } catch { - // non-critical + } catch (err) { + console.error("[updater] update check failed:", err); } } @@ -54,10 +58,12 @@ async function downloadAndInstall(url: string, version: string) { const zipPath = join(tmpDir, "update.zip"); const extractDir = join(tmpDir, "extracted"); + console.log(`[updater] downloading from ${url}`); const res = await fetch(url); if (!res.ok) throw new Error(`Download failed: ${res.status}`); await pipeline(Readable.fromWeb(res.body as Parameters[0]), createWriteStream(zipPath)); + console.log(`[updater] download complete, extracting to ${installDir}`); const installDir = dirname(process.execPath); @@ -67,9 +73,10 @@ async function downloadAndInstall(url: string, version: string) { ? `powershell -Command "Expand-Archive -Force -Path '${zipPath}' -DestinationPath '${extractDir}'; $sub = (Get-ChildItem '${extractDir}' | Select-Object -First 1).FullName; Copy-Item -Recurse -Force \\"$sub\\*\\" '${installDir}'"` : `unzip -o "${zipPath}" -d "${extractDir}" && SUBDIR=$(ls "${extractDir}" | head -1) && cp -rT "${extractDir}/$SUBDIR" "${installDir}"`; - exec(cmd, { shell: process.platform === "win32" ? undefined : "/bin/bash" }, (err) => - err ? reject(err) : resolve(), - ); + exec(cmd, { shell: process.platform === "win32" ? undefined : "/bin/bash" }, (err, _stdout, stderr) => { + if (err) { console.error("[updater] extract failed:", stderr); reject(err); } + else resolve(); + }); }); const n = notify("Update Ready", `Sanctum ${version} is installed — click to restart.`);