diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0b514d..c297690 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,6 +33,17 @@ jobs: swift --version swift test --help + - name: Inject Version into Info.plist + run: | + VERSION="${{ github.event.inputs.version }}" + if [ -z "$VERSION" ]; then + VERSION="${{ github.ref_name }}" + fi + # Strip 'v' prefix if present for Info.plist compatibility + VERSION_CLEAN=$(echo $VERSION | sed 's/^v//') + echo "Injecting version $VERSION_CLEAN into Info.plist" + plutil -replace CFBundleShortVersionString -string "$VERSION_CLEAN" Sources/Browserly/Info.plist + - name: Build App run: swift build -c release diff --git a/README.md b/README.md index 390fe82..b9f0be2 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ A smart macOS menu bar app that routes URLs to the right browser based on custom - **Domain rules** — route `github.com` to Chrome, `twitter.com` to Safari - **Regex rules** — match any part of a URL with regular expressions - **Source app rules** — route based on which app opened the link (e.g. Slack → Work Chrome) -- **URL Redirector Decoding** — automatically "sees through" Teams, Outlook, Proofpoint, and Slack link wrappers to apply rules to the final destination URL +- **URL Redirector Decoding** — automatically "sees through" Teams, Outlook, Proofpoint, and Slack link wrappers +- **Update Notifications** — stay informed when a new version is released on GitHub - **Browser profiles** — target specific Chrome/Edge/Brave profiles - **Incognito mode** — open matched URLs in private windows - **Menu bar app** — lives in the menu bar, no Dock icon diff --git a/Sources/Browserly/App/AppDelegate.swift b/Sources/Browserly/App/AppDelegate.swift index b459218..90fc745 100644 --- a/Sources/Browserly/App/AppDelegate.swift +++ b/Sources/Browserly/App/AppDelegate.swift @@ -66,6 +66,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { // Check for URL passed via command line arguments (first instance only) processCommandLineArguments() + + // Check for updates + UpdateManager.shared.checkForUpdates() } public func syncLaunchAtLogin() { diff --git a/Sources/Browserly/Core/Storage/AppState.swift b/Sources/Browserly/Core/Storage/AppState.swift index be1155d..b3a4110 100644 --- a/Sources/Browserly/Core/Storage/AppState.swift +++ b/Sources/Browserly/Core/Storage/AppState.swift @@ -30,5 +30,18 @@ public class AppState { } } + // Update tracking + public var latestVersion: String? = nil + public var updateUrl: URL? = nil + + public var currentVersion: String { + Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0" + } + + public var isUpdateAvailable: Bool { + guard let latest = latestVersion else { return false } + return latest.compare(currentVersion, options: .numeric) == .orderedDescending + } + private init() {} } diff --git a/Sources/Browserly/Core/System/UpdateManager.swift b/Sources/Browserly/Core/System/UpdateManager.swift new file mode 100644 index 0000000..7e85ca8 --- /dev/null +++ b/Sources/Browserly/Core/System/UpdateManager.swift @@ -0,0 +1,39 @@ +import Foundation + +public class UpdateManager { + public static let shared = UpdateManager() + + private let repoUrl = "https://api.github.com/repos/andyzasl/browserly/releases/latest" + + private init() {} + + struct GitHubRelease: Codable { + let tag_name: String + let html_url: String + } + + public func checkForUpdates() { + guard let url = URL(string: repoUrl) else { return } + + let task = URLSession.shared.dataTask(with: url) { data, response, error in + guard let data = data, error == nil else { + print("Failed to check for updates: \(error?.localizedDescription ?? "No data")") + return + } + + do { + let release = try JSONDecoder().decode(GitHubRelease.self, from: data) + let version = release.tag_name.replacingOccurrences(of: "v", with: "") + + DispatchQueue.main.async { + AppState.shared.latestVersion = version + AppState.shared.updateUrl = URL(string: release.html_url) + } + } catch { + print("Failed to parse update info: \(error.localizedDescription)") + } + } + + task.resume() + } +} diff --git a/Sources/Browserly/Info.plist b/Sources/Browserly/Info.plist index acb7860..68b3514 100644 --- a/Sources/Browserly/Info.plist +++ b/Sources/Browserly/Info.plist @@ -13,9 +13,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 0.0.0-dev CFBundleVersion - 1 + 0 LSMinimumSystemVersion 14.0 LSUIElement diff --git a/Sources/Browserly/UI/MenuBar/PopoverView.swift b/Sources/Browserly/UI/MenuBar/PopoverView.swift index 6cb1413..f87c1d0 100644 --- a/Sources/Browserly/UI/MenuBar/PopoverView.swift +++ b/Sources/Browserly/UI/MenuBar/PopoverView.swift @@ -12,6 +12,28 @@ struct PopoverView: View { @Bindable var bAppState = appState VStack(alignment: .leading, spacing: 0) { + // --- UPDATE NOTIFICATION --- + if bAppState.isUpdateAvailable { + HStack { + Image(systemName: "arrow.up.circle.fill") + .foregroundColor(.blue) + Text("New version available: \(bAppState.latestVersion ?? "")") + .font(.system(size: 12, weight: .medium)) + Spacer() + Button("Update") { + if let url = bAppState.updateUrl { + NSWorkspace.shared.open(url) + } + } + .buttonStyle(.borderedProminent) + .controlSize(.small) + } + .padding(.horizontal) + .padding(.vertical, 8) + .background(Color.blue.opacity(0.1)) + Divider() + } + // --- HEADER --- VStack(alignment: .leading, spacing: 12) { HStack { @@ -144,10 +166,20 @@ struct PopoverView: View { } } .padding() + + HStack { + Spacer() + Text("v\(appState.currentVersion)") + .font(.system(size: 9)) + .foregroundColor(.secondary) + .padding(.trailing, 8) + .padding(.bottom, 4) + } } .frame(width: 350) .onAppear { historyManager.reloadHistory() + UpdateManager.shared.checkForUpdates() } } }