Add signed, notarized releases with the server inside the app

This commit is contained in:
Ian Gulliver
2026-10-18 15:19:57 -07:00
parent 10a80ccb22
commit 6b86a7d5a9
20 changed files with 388 additions and 66 deletions
+4
View File
@@ -14,6 +14,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
Notifier.shared.install()
Updater.shared.start()
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
@@ -64,6 +65,9 @@ struct ByreApp: App {
.defaultSize(width: 1280, height: 820)
.commands {
CommandGroup(after: .appInfo) {
Button("Check for Updates…") {
Updater.shared.check()
}
Button("Change Server…") {
connection.changeServer()
}
+1 -1
View File
@@ -371,7 +371,7 @@ private actor Hands {
let stdin = Pipe()
let stdout = Pipe()
let p = Process()
p.executableURL = Bundle.main.executableURL!.deletingLastPathComponent().appending(path: "byre-hands")
p.executableURL = Bundle.main.bundleURL.appending(path: "Contents/Helpers/byre-hands")
p.standardInput = stdin
p.standardOutput = stdout
p.standardError = FileHandle.nullDevice
+53
View File
@@ -0,0 +1,53 @@
import Foundation
import Sparkle
private struct LaunchAgent: Decodable {
let programArguments: [String]
enum CodingKeys: String, CodingKey {
case programArguments = "ProgramArguments"
}
}
private let lastVersionKey = "lastLaunchedVersion"
@MainActor
final class Updater {
static let shared = Updater()
private lazy var controller = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
func start() {
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
let last = UserDefaults.standard.string(forKey: lastVersionKey)
UserDefaults.standard.set(version, forKey: lastVersionKey)
if last != nil && last != version {
restartServer()
}
_ = controller
}
func check() {
controller.checkForUpdates(nil)
}
private func restartServer() {
let agent = FileManager.default.homeDirectoryForCurrentUser.appending(path: "Library/LaunchAgents/run.fc.byre.plist")
let server = Bundle.main.bundleURL.appending(path: "Contents/Helpers/byre").path
guard let data = try? Data(contentsOf: agent),
let plist = try? PropertyListDecoder().decode(LaunchAgent.self, from: data),
plist.programArguments.first == server
else {
return
}
let p = Process()
p.executableURL = URL(filePath: "/bin/launchctl")
p.arguments = ["kickstart", "-k", "gui/\(getuid())/run.fc.byre"]
do {
try p.run()
p.waitUntilExit()
log.info("restarted byre server: status \(p.terminationStatus)")
} catch {
log.error("restart byre server: \(errorText(error), privacy: .public)")
}
}
}