Skip to content

Commit fabfd76

Browse files
authored
feat: add header for release build (#551)
* feat: add header for release build * check * fix: leverage appVersion as release build flag * fix: add try/catch and log
1 parent 206b1b8 commit fabfd76

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

main/src/main.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
binPath,
3434
} from './toolhive-manager'
3535
import log from './logger'
36-
import { getAppVersion, pollWindowReady } from './util'
36+
import { getAppVersion, isOfficialReleaseBuild, pollWindowReady } from './util'
3737
import { delay } from '../../utils/delay'
3838

3939
import Store from 'electron-store'
@@ -541,6 +541,10 @@ ipcMain.handle('install-update-and-restart', async () => {
541541
return { success: true }
542542
})
543543

544+
ipcMain.handle('is-release-build', () => {
545+
return isOfficialReleaseBuild()
546+
})
547+
544548
// Shutdown store IPC handlers
545549
ipcMain.handle('shutdown-store:get-last-servers', () => {
546550
return getLastShutdownServers()

main/src/util.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ function getVersionFromGit(): string {
99
encoding: 'utf8',
1010
stdio: 'pipe',
1111
}).trim()
12-
1312
return exactTag.replace(/^v/, '')
1413
} catch {
1514
try {
@@ -30,7 +29,6 @@ export function getAppVersion(): string {
3029
if (process.env.SENTRY_RELEASE) {
3130
return process.env.SENTRY_RELEASE
3231
}
33-
3432
return getVersionFromGit()
3533
}
3634

@@ -44,3 +42,13 @@ export async function pollWindowReady(window: BrowserWindow): Promise<void> {
4442
await delay(100)
4543
return pollWindowReady(window)
4644
}
45+
46+
export function isOfficialReleaseBuild(): boolean {
47+
try {
48+
const version = getAppVersion()
49+
return /^\d+\.\d+\.\d+$/.test(version)
50+
} catch {
51+
log.error('Failed to get app version')
52+
return false
53+
}
54+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "toolhive-studio",
33
"productName": "ToolHive",
4-
"version": "0.0.5",
4+
"version": "0.0.0-dev",
55
"description": "ToolHive is an application that allows you to install, manage and run MCP servers and connect them to AI agents and clients",
66
"main": ".vite/build/main.js",
77
"repository": "https://github.com/stacklok/toolhive-studio",

preload/src/preload.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
1818

1919
// App version
2020
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
21+
isReleaseBuild: () => ipcRenderer.invoke('is-release-build'),
2122

2223
// ToolHive port
2324
getToolhivePort: () => ipcRenderer.invoke('get-toolhive-port'),
@@ -98,6 +99,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
9899

99100
export interface ElectronAPI {
100101
getAppVersion: () => Promise<string>
102+
isReleaseBuild: () => Promise<boolean>
101103
getAutoLaunchStatus: () => Promise<boolean>
102104
setAutoLaunch: (enabled: boolean) => Promise<boolean>
103105
showApp: () => Promise<void>

renderer/src/renderer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ if (!window.electronAPI || !window.electronAPI.getToolhivePort) {
7878
try {
7979
const port = await window.electronAPI.getToolhivePort()
8080
const appVersion = await window.electronAPI.getAppVersion()
81+
const isReleaseBuild = await window.electronAPI.isReleaseBuild()
8182
const baseUrl = `http://localhost:${port}`
8283

8384
client.setConfig({
@@ -86,6 +87,7 @@ if (!window.electronAPI || !window.electronAPI.getToolhivePort) {
8687
'X-Client-Type': 'toolhive-studio',
8788
'X-Client-Version': appVersion,
8889
'X-Client-Platform': window.electronAPI.platform,
90+
'X-Client-Release-Build': isReleaseBuild,
8991
},
9092
})
9193
} catch (e) {

0 commit comments

Comments
 (0)