Skip to content

Commit d38e369

Browse files
committed
feat: add Electrobun auto-updater, GitHub Actions workflow, and slim Electron builds
- Add release.baseUrl to electrobun.config.ts pointing to GitHub Releases - Add build:canary and build:stable scripts to electrobun/package.json - Wire up Electrobun Updater API in main process: checks for updates 10s after launch and every 4 hours, downloads patches automatically - Update GitHub Actions workflow: trigger on tags only, keep Electron job, add electrobun-macos-arm64 job with Bun + code signing support - Slim Electron build targets to one per OS: dmg (mac), nsis (win), AppImage (linux) — removes redundant zip and deb artifacts - Bump Electron app version 6.0.0 -> 6.0.1
1 parent 7cc2bcd commit d38e369

7 files changed

Lines changed: 109 additions & 39 deletions

File tree

.github/workflows/build.yml

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name: Build/release
22

3-
on: push
3+
on:
4+
push:
5+
tags:
6+
- "v*"
47

58
jobs:
6-
release:
9+
# ---------------------------------------------------------------------------
10+
# Electron build (legacy) — macOS, Linux, Windows
11+
# ---------------------------------------------------------------------------
12+
electron:
713
runs-on: ${{ matrix.os }}
814
timeout-minutes: 30
915

@@ -24,17 +30,61 @@ jobs:
2430
- name: Build/release Electron app
2531
uses: samuelmeuli/action-electron-builder@v1.6.0
2632
with:
27-
# GitHub token, automatically provided to the action
28-
# (No need to define this secret in the repo settings)
2933
github_token: ${{ secrets.github_token }}
30-
31-
# macOS code signing certificate
3234
mac_certs: ${{ secrets.MAC_CERTS }}
3335
mac_certs_password: ${{ secrets.MAC_CERTS_PASSWORD }}
34-
35-
# If the commit is tagged with a version (e.g. "v1.0.0"),
36-
# release the app after building
3736
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
38-
39-
# Build only for current platform, explicitly publish
4037
args: ${{ matrix.os == 'macos-latest' && '--mac --publish always' || matrix.os == 'ubuntu-latest' && '--linux --publish always' || '--win --publish always' }}
38+
39+
# ---------------------------------------------------------------------------
40+
# Electrobun build — macOS ARM64 (Apple Silicon)
41+
# ---------------------------------------------------------------------------
42+
electrobun-macos-arm64:
43+
runs-on: macos-14
44+
timeout-minutes: 30
45+
46+
steps:
47+
- name: Check out Git repository
48+
uses: actions/checkout@v4
49+
50+
- name: Setup Bun
51+
uses: oven-sh/setup-bun@v2
52+
with:
53+
bun-version: latest
54+
55+
- name: Install dependencies
56+
run: bun install
57+
working-directory: electrobun
58+
59+
- name: Determine build environment
60+
id: build-env
61+
run: |
62+
if [[ "${{ github.ref_name }}" == *"-canary"* ]]; then
63+
echo "env=canary" >> $GITHUB_OUTPUT
64+
else
65+
echo "env=stable" >> $GITHUB_OUTPUT
66+
fi
67+
68+
- name: Build Electrobun app
69+
working-directory: electrobun
70+
env:
71+
ELECTROBUN_DEVELOPER_ID: ${{ secrets.ELECTROBUN_DEVELOPER_ID }}
72+
APPLE_ID: ${{ secrets.APPLE_ID }}
73+
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
74+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
75+
run: |
76+
if [ "${{ steps.build-env.outputs.env }}" = "canary" ]; then
77+
bun run build:canary
78+
else
79+
bun run build:stable
80+
fi
81+
82+
- name: Upload Electrobun artifacts to GitHub Release
83+
uses: softprops/action-gh-release@v1
84+
with:
85+
files: electrobun/artifacts/*
86+
draft: false
87+
prerelease: ${{ steps.build-env.outputs.env == 'canary' }}
88+
generate_release_notes: true
89+
env:
90+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/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.

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "space-radar",
33
"productName": "SpaceRadar",
4-
"version": "6.0.0",
4+
"version": "6.0.1",
55
"description": "Disk Usage Electron App",
66
"author": "Joshua Koo",
77
"main": "main.js",

electrobun/electrobun.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,7 @@ export default {
2020
"src/mainview/style.css": "views/mainview/style.css",
2121
},
2222
},
23+
release: {
24+
baseUrl: "https://github.com/zz85/space-radar/releases/latest/download",
25+
},
2326
};

electrobun/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"scripts": {
88
"start": "bun run build:dev && electrobun dev",
99
"build:dev": "bun install && electrobun build",
10-
"build:release": "electrobun build --release"
10+
"build:canary": "electrobun build --env=canary",
11+
"build:stable": "electrobun build --env=stable"
1112
},
1213
"dependencies": {
1314
"d3": "^3.5.17",

electrobun/src/bun/index.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Electrobun, {
1313
ContextMenu,
1414
Utils,
1515
Screen,
16+
Updater,
1617
} from "electrobun/bun";
1718
import { homedir } from "node:os";
1819
import { join } from "node:path";
@@ -936,3 +937,42 @@ console.log(
936937
);
937938
console.log(`[main] Platform: ${process.platform} ${process.arch}`);
938939
console.log(`[main] App data: ${getAppDataDir()}`);
940+
941+
// ---------------------------------------------------------------------------
942+
// Auto-updater — check for updates on launch and periodically
943+
// ---------------------------------------------------------------------------
944+
945+
const UPDATE_CHECK_INTERVAL = 4 * 60 * 60 * 1000; // 4 hours
946+
947+
async function checkAndApplyUpdate() {
948+
try {
949+
const localInfo = await Updater.getLocalInfo();
950+
console.log(
951+
`[updater] Local version: ${localInfo.version} (${localInfo.channel})`,
952+
);
953+
954+
const updateInfo = await Updater.checkForUpdate();
955+
if (!updateInfo.updateAvailable) {
956+
console.log("[updater] No update available");
957+
return;
958+
}
959+
960+
console.log(`[updater] Update available: ${updateInfo.version}`);
961+
await Updater.downloadUpdate();
962+
963+
const ready = Updater.updateInfo();
964+
if (ready?.updateReady) {
965+
console.log("[updater] Update downloaded and ready to install");
966+
// Don't force-apply — the update will be installed on next launch
967+
// or the user can trigger it. For now just log readiness.
968+
}
969+
} catch (err) {
970+
console.warn("[updater] Update check failed:", err);
971+
}
972+
}
973+
974+
// Initial check after a short delay so it doesn't block startup
975+
setTimeout(checkAndApplyUpdate, 10_000);
976+
977+
// Periodic checks
978+
setInterval(checkAndApplyUpdate, UPDATE_CHECK_INTERVAL);

package.json

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "space-radar",
33
"productName": "SpaceRadar",
4-
"version": "6.0.0",
4+
"version": "6.0.1",
55
"description": "Disk Usage Electron App",
66
"main": "app/main.js",
77
"scripts": {
@@ -73,13 +73,6 @@
7373
"x64",
7474
"arm64"
7575
]
76-
},
77-
{
78-
"target": "zip",
79-
"arch": [
80-
"x64",
81-
"arm64"
82-
]
8376
}
8477
],
8578
"hardenedRuntime": true,
@@ -106,12 +99,6 @@
10699
"arch": [
107100
"x64"
108101
]
109-
},
110-
{
111-
"target": "zip",
112-
"arch": [
113-
"x64"
114-
]
115102
}
116103
],
117104
"icon": "Icon.png"
@@ -129,18 +116,6 @@
129116
"arch": [
130117
"x64"
131118
]
132-
},
133-
{
134-
"target": "deb",
135-
"arch": [
136-
"x64"
137-
]
138-
},
139-
{
140-
"target": "zip",
141-
"arch": [
142-
"x64"
143-
]
144119
}
145120
],
146121
"category": "Utility",

0 commit comments

Comments
 (0)