Skip to content

Commit 9e7c4ba

Browse files
authored
Merge pull request #19 from runtime-org/feat/tauri-auto-update
Feat/tauri auto update
2 parents 6af86a7 + e94a41e commit 9e7c4ba

File tree

5 files changed

+57
-80
lines changed

5 files changed

+57
-80
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"copy-webpack-plugin": "^13.0.0",
3737
"eslint": "^9.29.0",
3838
"eslint-plugin-react": "^7.37.5",
39+
"fast-glob": "^3.3.3",
3940
"globals": "^16.2.0",
4041
"puppeteer-core": "^24.9.0",
4142
"tailwindcss": "^4.1.6",

scripts.mjs

Lines changed: 0 additions & 80 deletions
This file was deleted.

scripts/make-latest-json.mjs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// scripts/make-latest-json.mjs
2+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
3+
import { basename } from 'node:path';
4+
import fg from 'fast-glob';
5+
6+
function getVersion() {
7+
if (process.env.APP_VERSION) return process.env.APP_VERSION;
8+
const cfg = JSON.parse(readFileSync('src-tauri/tauri.conf.json', 'utf8'));
9+
if (!cfg.version) throw new Error('No version in src-tauri/tauri.conf.json and APP_VERSION not set');
10+
return cfg.version;
11+
}
12+
13+
function reqEnv(name) {
14+
const v = process.env[name];
15+
if (!v) throw new Error(`Missing env ${name}`);
16+
return v;
17+
}
18+
19+
async function findOne(glob) {
20+
const list = await fg(glob);
21+
return list[0] || null;
22+
}
23+
24+
(async () => {
25+
const OWNER = 'runtime-org';
26+
const REPO = 'runtime';
27+
const VERSION = getVersion();
28+
const TAG = process.env.GIT_TAG || `v${VERSION}`;
29+
30+
// Universal artifacts
31+
const base = 'src-tauri/target/universal-apple-darwin/release/bundle/macos';
32+
const tar = await findOne(`${base}/*.app.tar.gz`);
33+
const sig = await findOne(`${base}/*.app.tar.gz.sig`);
34+
if (!tar || !sig) {
35+
throw new Error('Universal updater artifacts not found. Did you build with "--target universal-apple-darwin --bundles dmg app"?');
36+
}
37+
38+
const url = `https://github.com/${OWNER}/${REPO}/releases/download/${TAG}/${basename(tar)}`;
39+
const signature = readFileSync(sig, 'utf8').trim();
40+
41+
const latest = {
42+
version: VERSION,
43+
notes: "",
44+
pub_date: new Date().toISOString(),
45+
platforms: {
46+
// Point both architectures to the same universal tarball
47+
"darwin-aarch64": { url, signature },
48+
"darwin-x86_64": { url, signature }
49+
}
50+
};
51+
52+
if (!existsSync('dist')) mkdirSync('dist', { recursive: true });
53+
writeFileSync('dist/latest.json', JSON.stringify(latest, null, 2));
54+
console.log('dist/latest.json written for universal macOS');
55+
})();
File renamed without changes.

0 commit comments

Comments
 (0)