fix: stamp package.json version from git tag at build time, add updater logging
All checks were successful
Build & Release / build (push) Successful in 2m25s
All checks were successful
Build & Release / build (push) Successful in 2m25s
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 <noreply@anthropic.com>
This commit is contained in:
parent
04cae9d50b
commit
4fb5461321
2 changed files with 19 additions and 6 deletions
|
|
@ -21,6 +21,12 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install
|
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
|
- 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
|
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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,16 @@ export async function checkForUpdates() {
|
||||||
if (!isNewer(latest, current)) return;
|
if (!isNewer(latest, current)) return;
|
||||||
|
|
||||||
const asset = findAsset(release.assets);
|
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…`);
|
notify("Update Downloading", `Sanctum ${latest} is downloading in the background…`);
|
||||||
await downloadAndInstall(asset.browser_download_url, latest);
|
await downloadAndInstall(asset.browser_download_url, latest);
|
||||||
} catch {
|
} catch (err) {
|
||||||
// non-critical
|
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 zipPath = join(tmpDir, "update.zip");
|
||||||
const extractDir = join(tmpDir, "extracted");
|
const extractDir = join(tmpDir, "extracted");
|
||||||
|
|
||||||
|
console.log(`[updater] downloading from ${url}`);
|
||||||
const res = await fetch(url);
|
const res = await fetch(url);
|
||||||
if (!res.ok) throw new Error(`Download failed: ${res.status}`);
|
if (!res.ok) throw new Error(`Download failed: ${res.status}`);
|
||||||
|
|
||||||
await pipeline(Readable.fromWeb(res.body as Parameters<typeof Readable.fromWeb>[0]), createWriteStream(zipPath));
|
await pipeline(Readable.fromWeb(res.body as Parameters<typeof Readable.fromWeb>[0]), createWriteStream(zipPath));
|
||||||
|
console.log(`[updater] download complete, extracting to ${installDir}`);
|
||||||
|
|
||||||
const installDir = dirname(process.execPath);
|
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}'"`
|
? `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}"`;
|
: `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) =>
|
exec(cmd, { shell: process.platform === "win32" ? undefined : "/bin/bash" }, (err, _stdout, stderr) => {
|
||||||
err ? reject(err) : resolve(),
|
if (err) { console.error("[updater] extract failed:", stderr); reject(err); }
|
||||||
);
|
else resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const n = notify("Update Ready", `Sanctum ${version} is installed — click to restart.`);
|
const n = notify("Update Ready", `Sanctum ${version} is installed — click to restart.`);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue