Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc710d53aa | ||
|
|
db1f15f981 | ||
|
|
db58a5c048 | ||
|
|
00978b096b | ||
|
|
73d81216bb |
2
.gitignore
vendored
@@ -3,3 +3,5 @@ xcuserdata/
|
|||||||
DerivedData/
|
DerivedData/
|
||||||
build/
|
build/
|
||||||
Build/
|
Build/
|
||||||
|
dist/
|
||||||
|
.signing.env
|
||||||
|
|||||||
@@ -1,51 +1,61 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_16x16.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "16x16"
|
"size" : "16x16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_16x16@2x.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "16x16"
|
"size" : "16x16"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_32x32.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "32x32"
|
"size" : "32x32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_32x32@2x.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "32x32"
|
"size" : "32x32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_128x128.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "128x128"
|
"size" : "128x128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_128x128@2x.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "128x128"
|
"size" : "128x128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_256x256.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "256x256"
|
"size" : "256x256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_256x256@2x.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "256x256"
|
"size" : "256x256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_512x512.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "1x",
|
"scale" : "1x",
|
||||||
"size" : "512x512"
|
"size" : "512x512"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"filename" : "icon_512x512@2x.png",
|
||||||
"idiom" : "mac",
|
"idiom" : "mac",
|
||||||
"scale" : "2x",
|
"scale" : "2x",
|
||||||
"size" : "512x512"
|
"size" : "512x512"
|
||||||
|
|||||||
BIN
Assets.xcassets/AppIcon.appiconset/icon_128x128.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_16x16.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_256x256.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png
Normal file
|
After Width: | Height: | Size: 230 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_32x32.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png
Normal file
|
After Width: | Height: | Size: 5.3 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_512x512.png
Normal file
|
After Width: | Height: | Size: 230 KiB |
BIN
Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
Assets/dmg_background.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
@@ -7,4 +7,7 @@
|
|||||||
- Added verbose logging in `MainView` to trace server loading, selection, and fetch/ping activity when the list appears empty.
|
- Added verbose logging in `MainView` to trace server loading, selection, and fetch/ping activity when the list appears empty.
|
||||||
- Switched `MainView` and `ServerFormView` to the version-aware API client (`APIFactory`/`APIv2_12`) for server summaries and introduced a shared `PingService`.
|
- Switched `MainView` and `ServerFormView` to the version-aware API client (`APIFactory`/`APIv2_12`) for server summaries and introduced a shared `PingService`.
|
||||||
- Detection now probes `meta.api_version` so future API versions are selected automatically, and the ping loop logs only failures to keep output quiet.
|
- Detection now probes `meta.api_version` so future API versions are selected automatically, and the ping loop logs only failures to keep output quiet.
|
||||||
|
- Introduced repository-wide version management via `version.json` + `scripts/sync_version.sh`, ensuring Xcode targets and release artifacts stay aligned.
|
||||||
|
- Enhanced `scripts/build_release.sh` to timestamp/harden signatures, notarize DMGs, and optionally publish tagged releases (pre-release by default) with ZIP/DMG assets directly to Gitea when credentials are configured.
|
||||||
|
- Added a lightweight update checker that polls the latest Gitea release, surfaces alerts + download shortcuts, and exposes new toggles (auto-check + prerelease channel) inside Preferences.
|
||||||
- Further reduced MainView console noise by removing redundant refresh/onAppear logs.
|
- Further reduced MainView console noise by removing redundant refresh/onAppear logs.
|
||||||
|
|||||||
3
NOTES.md
@@ -3,5 +3,6 @@
|
|||||||
dynamic Data
|
dynamic Data
|
||||||
static Data
|
static Data
|
||||||
|
|
||||||
move source to /src. like iKeyMon before
|
|
||||||
add a merker for "reboot required"
|
add a merker for "reboot required"
|
||||||
|
Add dmg download option for macOS
|
||||||
|
Add versioning
|
||||||
|
|||||||
33
README.md
@@ -11,6 +11,7 @@ iKeyMon is a native macOS app written in SwiftUI that provides live monitoring f
|
|||||||
- Automatic updates:
|
- Automatic updates:
|
||||||
- Ping every 10 seconds
|
- Ping every 10 seconds
|
||||||
- Server info every 60 seconds
|
- Server info every 60 seconds
|
||||||
|
- Optional automatic update checks that watch the latest Gitea release (with manual “Check now” button and prerelease channel toggle)
|
||||||
- Organized layout using tabs: General / Resources / Services
|
- Organized layout using tabs: General / Resources / Services
|
||||||
- Stores API keys securely in the macOS Keychain
|
- Stores API keys securely in the macOS Keychain
|
||||||
- Native macOS look & feel using SwiftUI
|
- Native macOS look & feel using SwiftUI
|
||||||
@@ -39,13 +40,41 @@ open iKeyMon.xcodeproj
|
|||||||
|
|
||||||
### Local release build
|
### Local release build
|
||||||
|
|
||||||
Use the helper script to produce a zipped `.app` in `dist/`:
|
Use the helper script to produce distributables in `dist/`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./scripts/build_release.sh
|
./scripts/build_release.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
It cleans previous artifacts, builds the `Release` configuration, and drops `iKeyMon-<version>.zip` into the `dist` folder (ignored by git).
|
It cleans previous artifacts, builds the `Release` configuration, and drops both `iKeyMon-<version>.zip` and `iKeyMon-<version>.dmg` into the `dist` folder (ignored by git). To enable codesigning + notarization, copy `signing.env.example` to `.signing.env`, fill in your Developer ID identity, Apple ID, team ID, and app-specific password. The script sources that file locally (it remains gitignored) and performs signing/notarization when the values are present.
|
||||||
|
|
||||||
|
To auto-publish the artifacts as a Gitea release, extend `.signing.env` with:
|
||||||
|
|
||||||
|
```
|
||||||
|
GITEA_TOKEN="..."
|
||||||
|
GITEA_OWNER="tracer"
|
||||||
|
GITEA_REPO="iKeyMon"
|
||||||
|
# optional: GITEA_API_BASE="https://git.24unix.net/api/v1"
|
||||||
|
# optional: GITEA_TARGET_COMMIT="master"
|
||||||
|
# optional: GITEA_PRERELEASE="false" # defaults to true until preferences are done
|
||||||
|
```
|
||||||
|
|
||||||
|
`GITEA_TARGET_COMMIT` defaults to the current `HEAD` commit, so overriding it lets you publish from another branch if needed. Whenever those variables are set, the script will create (or reuse) tag `v<version>` and upload both ZIP and DMG as release assets automatically.
|
||||||
|
|
||||||
|
### Update checks
|
||||||
|
|
||||||
|
- The app can automatically query the Gitea release feed on launch (Preferences → Updates → “Automatically check for updates”).
|
||||||
|
- “Check for updates” also lives in the main window toolbar; if you're already up to date, you'll get a confirmation alert.
|
||||||
|
- Preferences let you opt into prerelease builds (enabled by default for now because current releases are flagged prerelease) and show the latest fetched release number for reference.
|
||||||
|
- When a newer build is available, a prompt offers to open the DMG download (or you can revisit the release info inside Preferences).
|
||||||
|
|
||||||
|
### Versioning workflow
|
||||||
|
|
||||||
|
- The canonical marketing version lives in `version.json` and follows the format `YY.major.minor` (example: `26.1.2`). Update that file manually whenever you cut a new release branch.
|
||||||
|
- The build number is derived automatically from the git commit count on the current branch (you can override it by exporting `BUILD_NUMBER` before running the script if needed).
|
||||||
|
- Run `./scripts/sync_version.sh` anytime after editing `version.json` (the release script already calls it). The helper updates `MARKETING_VERSION` and `CURRENT_PROJECT_VERSION` inside `iKeyMon.xcodeproj`, keeping Xcode, the app bundle, and release artifacts in sync.
|
||||||
|
- `scripts/build_release.sh` reads the same `version.json` for naming the generated ZIP/DMG, so the artifact names, Info.plist values, and UI displays all stay aligned.
|
||||||
|
|
||||||
## 📦 License
|
## 📦 License
|
||||||
|
|
||||||
MIT — see [LICENSE](LICENSE) for details.
|
MIT — see [LICENSE](LICENSE) for details.
|
||||||
|
|||||||
@@ -15,11 +15,10 @@ struct ShimmerModifier: ViewModifier {
|
|||||||
guard active else { return }
|
guard active else { return }
|
||||||
animate()
|
animate()
|
||||||
}
|
}
|
||||||
.onChange(of: active) { isActive in
|
.onChange(of: active) {
|
||||||
if isActive {
|
guard active else { return }
|
||||||
phase = -1
|
phase = -1
|
||||||
animate()
|
animate()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
160
Sources/Model/Updates/UpdateService.swift
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct ReleaseInfo: Identifiable {
|
||||||
|
let id = UUID()
|
||||||
|
let version: VersionNumber
|
||||||
|
let versionString: String
|
||||||
|
let notes: String
|
||||||
|
let downloadURL: URL
|
||||||
|
let releaseURL: URL
|
||||||
|
let prerelease: Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
struct VersionNumber: Comparable, CustomStringConvertible {
|
||||||
|
let rawValue: String
|
||||||
|
private let components: [Int]
|
||||||
|
|
||||||
|
init(_ raw: String) {
|
||||||
|
self.rawValue = raw
|
||||||
|
self.components = raw
|
||||||
|
.split(separator: ".")
|
||||||
|
.map { Int($0) ?? 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
var description: String { rawValue }
|
||||||
|
|
||||||
|
static func < (lhs: VersionNumber, rhs: VersionNumber) -> Bool {
|
||||||
|
let maxCount = max(lhs.components.count, rhs.components.count)
|
||||||
|
for index in 0..<maxCount {
|
||||||
|
let left = index < lhs.components.count ? lhs.components[index] : 0
|
||||||
|
let right = index < rhs.components.count ? rhs.components[index] : 0
|
||||||
|
if left != right {
|
||||||
|
return left < right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum UpdateServiceError: LocalizedError {
|
||||||
|
case invalidResponse
|
||||||
|
case noReleasesAvailable
|
||||||
|
case missingDownloadAsset
|
||||||
|
|
||||||
|
var errorDescription: String? {
|
||||||
|
switch self {
|
||||||
|
case .invalidResponse:
|
||||||
|
return "The update server returned an invalid response."
|
||||||
|
case .noReleasesAvailable:
|
||||||
|
return "No releases are currently available."
|
||||||
|
case .missingDownloadAsset:
|
||||||
|
return "The release did not include downloadable artifacts."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UpdateService {
|
||||||
|
private struct APIRelease: Decodable {
|
||||||
|
struct Asset: Decodable {
|
||||||
|
let name: String
|
||||||
|
let browserDownloadURL: URL?
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case name
|
||||||
|
case browserDownloadURL = "browser_download_url"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let tagName: String
|
||||||
|
let body: String?
|
||||||
|
let prerelease: Bool
|
||||||
|
let draft: Bool
|
||||||
|
let htmlURL: URL?
|
||||||
|
let createdAt: Date
|
||||||
|
let assets: [Asset]
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case tagName = "tag_name"
|
||||||
|
case body
|
||||||
|
case prerelease
|
||||||
|
case draft
|
||||||
|
case htmlURL = "html_url"
|
||||||
|
case createdAt = "created_at"
|
||||||
|
case assets
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private let baseURL = URL(string: "https://git.24unix.net/api/v1")!
|
||||||
|
private let owner = "tracer"
|
||||||
|
private let repo = "iKeyMon"
|
||||||
|
private let session: URLSession
|
||||||
|
|
||||||
|
init(session: URLSession = .shared) {
|
||||||
|
self.session = session
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchLatestRelease(includePrerelease: Bool) async throws -> ReleaseInfo {
|
||||||
|
let releasesURL = baseURL
|
||||||
|
.appendingPathComponent("repos")
|
||||||
|
.appendingPathComponent(owner)
|
||||||
|
.appendingPathComponent(repo)
|
||||||
|
.appendingPathComponent("releases")
|
||||||
|
|
||||||
|
var request = URLRequest(url: releasesURL)
|
||||||
|
request.addValue("application/json", forHTTPHeaderField: "Accept")
|
||||||
|
|
||||||
|
let (data, response) = try await session.data(for: request)
|
||||||
|
guard let httpResponse = response as? HTTPURLResponse,
|
||||||
|
200..<300 ~= httpResponse.statusCode else {
|
||||||
|
throw UpdateServiceError.invalidResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
let decoder = JSONDecoder()
|
||||||
|
decoder.dateDecodingStrategy = .iso8601
|
||||||
|
let releases = try decoder.decode([APIRelease].self, from: data)
|
||||||
|
|
||||||
|
let filtered = releases
|
||||||
|
.filter { !$0.draft }
|
||||||
|
.filter { includePrerelease || !$0.prerelease }
|
||||||
|
.sorted(by: { $0.createdAt > $1.createdAt })
|
||||||
|
|
||||||
|
guard let release = filtered.first else {
|
||||||
|
throw UpdateServiceError.noReleasesAvailable
|
||||||
|
}
|
||||||
|
|
||||||
|
guard let asset = preferredAsset(from: release.assets),
|
||||||
|
let downloadURL = asset.browserDownloadURL else {
|
||||||
|
throw UpdateServiceError.missingDownloadAsset
|
||||||
|
}
|
||||||
|
|
||||||
|
let cleanTag = release.tagName.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
|
let version = cleanTag.hasPrefix("v") ? String(cleanTag.dropFirst()) : cleanTag
|
||||||
|
|
||||||
|
return ReleaseInfo(
|
||||||
|
version: VersionNumber(version),
|
||||||
|
versionString: version,
|
||||||
|
notes: release.body ?? "",
|
||||||
|
downloadURL: downloadURL,
|
||||||
|
releaseURL: release.htmlURL ?? releasesURL,
|
||||||
|
prerelease: release.prerelease
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func preferredAsset(from assets: [APIRelease.Asset]) -> APIRelease.Asset? {
|
||||||
|
return assets
|
||||||
|
.sorted { lhs, rhs in
|
||||||
|
priority(for: lhs.name) > priority(for: rhs.name)
|
||||||
|
}
|
||||||
|
.first(where: { $0.browserDownloadURL != nil })
|
||||||
|
}
|
||||||
|
|
||||||
|
private func priority(for name: String) -> Int {
|
||||||
|
if name.lowercased().hasSuffix(".dmg") {
|
||||||
|
return 3
|
||||||
|
}
|
||||||
|
if name.lowercased().hasSuffix(".zip") {
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
95
Sources/ViewModels/UpdateViewModel.swift
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import Foundation
|
||||||
|
#if os(macOS)
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
final class UpdateViewModel: ObservableObject {
|
||||||
|
struct StatusAlert: Identifiable {
|
||||||
|
let id = UUID()
|
||||||
|
let title: String
|
||||||
|
let message: String
|
||||||
|
}
|
||||||
|
|
||||||
|
@Published var availableRelease: ReleaseInfo?
|
||||||
|
@Published var latestFetchedRelease: ReleaseInfo?
|
||||||
|
@Published var statusAlert: StatusAlert?
|
||||||
|
@Published var isChecking = false
|
||||||
|
|
||||||
|
private let service: UpdateService
|
||||||
|
private let userDefaults: UserDefaults
|
||||||
|
private let autoCheckKey = "autoCheckUpdates"
|
||||||
|
private let includePrereleaseKey = "includePrereleaseUpdates"
|
||||||
|
|
||||||
|
init(service: UpdateService = UpdateService(), userDefaults: UserDefaults = .standard) {
|
||||||
|
self.service = service
|
||||||
|
self.userDefaults = userDefaults
|
||||||
|
registerDefaultsIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
|
func startAutomaticCheckIfNeeded() {
|
||||||
|
if userDefaults.bool(forKey: autoCheckKey) {
|
||||||
|
checkForUpdates(userInitiated: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkForUpdates(userInitiated: Bool) {
|
||||||
|
guard !isChecking else { return }
|
||||||
|
isChecking = true
|
||||||
|
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
let release = try await service.fetchLatestRelease(includePrerelease: userDefaults.bool(forKey: includePrereleaseKey))
|
||||||
|
handle(release: release, userInitiated: userInitiated)
|
||||||
|
} catch {
|
||||||
|
if userInitiated {
|
||||||
|
statusAlert = StatusAlert(
|
||||||
|
title: "Update Check Failed",
|
||||||
|
message: error.localizedDescription
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.isChecking = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func openReleaseNotes() {
|
||||||
|
guard let releaseURL = availableRelease?.releaseURL ?? latestFetchedRelease?.releaseURL else { return }
|
||||||
|
#if os(macOS)
|
||||||
|
NSWorkspace.shared.open(releaseURL)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
func downloadLatest() {
|
||||||
|
let release = availableRelease ?? latestFetchedRelease
|
||||||
|
availableRelease = nil
|
||||||
|
guard let downloadURL = release?.downloadURL else { return }
|
||||||
|
#if os(macOS)
|
||||||
|
NSWorkspace.shared.open(downloadURL)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private func handle(release: ReleaseInfo, userInitiated: Bool) {
|
||||||
|
let currentVersion = VersionNumber(
|
||||||
|
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0.0"
|
||||||
|
)
|
||||||
|
|
||||||
|
latestFetchedRelease = release
|
||||||
|
|
||||||
|
if release.version > currentVersion {
|
||||||
|
availableRelease = release
|
||||||
|
} else if userInitiated {
|
||||||
|
statusAlert = StatusAlert(
|
||||||
|
title: "You're Up To Date",
|
||||||
|
message: "iKeyMon \(currentVersion.rawValue) is the latest version."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func registerDefaultsIfNeeded() {
|
||||||
|
userDefaults.register(defaults: [
|
||||||
|
autoCheckKey: true,
|
||||||
|
includePrereleaseKey: true
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ struct MainView: View {
|
|||||||
private static let serverOrderKeyStatic = "serverOrder"
|
private static let serverOrderKeyStatic = "serverOrder"
|
||||||
private static let storedServersKeyStatic = "storedServers"
|
private static let storedServersKeyStatic = "storedServers"
|
||||||
|
|
||||||
|
@EnvironmentObject private var updateViewModel: UpdateViewModel
|
||||||
@State var showAddServerSheet: Bool = false
|
@State var showAddServerSheet: Bool = false
|
||||||
@State private var serverBeingEdited: Server?
|
@State private var serverBeingEdited: Server?
|
||||||
@State private var serverToDelete: Server?
|
@State private var serverToDelete: Server?
|
||||||
@@ -30,9 +31,9 @@ struct MainView: View {
|
|||||||
@State private var selectedServerID: UUID?
|
@State private var selectedServerID: UUID?
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
var mainContent: some View {
|
||||||
NavigationSplitView {
|
NavigationSplitView {
|
||||||
List(selection: $selectedServerID) {
|
List(selection: $selectedServerID) {
|
||||||
ForEach(servers) { server in
|
ForEach(servers) { server in
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "dot.circle.fill")
|
Image(systemName: "dot.circle.fill")
|
||||||
@@ -61,6 +62,19 @@ struct MainView: View {
|
|||||||
}
|
}
|
||||||
.help("Add Host")
|
.help("Add Host")
|
||||||
}
|
}
|
||||||
|
ToolbarItem {
|
||||||
|
Button {
|
||||||
|
updateViewModel.checkForUpdates(userInitiated: true)
|
||||||
|
} label: {
|
||||||
|
if updateViewModel.isChecking {
|
||||||
|
ProgressView()
|
||||||
|
.scaleEffect(0.6)
|
||||||
|
} else {
|
||||||
|
Image(systemName: "square.and.arrow.down")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.help("Check for Updates")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("Servers")
|
.navigationTitle("Servers")
|
||||||
.onChange(of: selectedServerID) {
|
.onChange(of: selectedServerID) {
|
||||||
@@ -76,7 +90,9 @@ struct MainView: View {
|
|||||||
} else {
|
} else {
|
||||||
ContentUnavailableView("No Server Selected", systemImage: "server.rack")
|
ContentUnavailableView("No Server Selected", systemImage: "server.rack")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return mainContent
|
||||||
.sheet(isPresented: $showAddServerSheet) {
|
.sheet(isPresented: $showAddServerSheet) {
|
||||||
ServerFormView(
|
ServerFormView(
|
||||||
mode: .add,
|
mode: .add,
|
||||||
@@ -128,9 +144,26 @@ struct MainView: View {
|
|||||||
pingTimer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: true) { _ in
|
pingTimer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: true) { _ in
|
||||||
pingAllServers()
|
pingAllServers()
|
||||||
}
|
}
|
||||||
|
updateViewModel.startAutomaticCheckIfNeeded()
|
||||||
}
|
}
|
||||||
.frame(minWidth: 800, minHeight: 450)
|
.frame(minWidth: 800, minHeight: 450)
|
||||||
|
.alert(item: availableReleaseBinding) { release in
|
||||||
|
Alert(
|
||||||
|
title: Text("Update Available"),
|
||||||
|
message: Text("iKeyMon \(release.versionString) is available."),
|
||||||
|
primaryButton: .default(Text("Download")) {
|
||||||
|
updateViewModel.downloadLatest()
|
||||||
|
},
|
||||||
|
secondaryButton: .cancel(Text("Later"))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
.alert(item: statusAlertBinding) { alert in
|
||||||
|
Alert(
|
||||||
|
title: Text(alert.title),
|
||||||
|
message: Text(alert.message),
|
||||||
|
dismissButton: .default(Text("OK"))
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func fetchServerInfo(for id: UUID) {
|
private func fetchServerInfo(for id: UUID) {
|
||||||
@@ -257,8 +290,23 @@ struct MainView: View {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var availableReleaseBinding: Binding<ReleaseInfo?> {
|
||||||
|
Binding(
|
||||||
|
get: { updateViewModel.availableRelease },
|
||||||
|
set: { updateViewModel.availableRelease = $0 }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var statusAlertBinding: Binding<UpdateViewModel.StatusAlert?> {
|
||||||
|
Binding(
|
||||||
|
get: { updateViewModel.statusAlert },
|
||||||
|
set: { updateViewModel.statusAlert = $0 }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
MainView()
|
MainView()
|
||||||
|
.environmentObject(UpdateViewModel())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ import SwiftUI
|
|||||||
|
|
||||||
struct PreferencesView: View {
|
struct PreferencesView: View {
|
||||||
private enum Tab: CaseIterable {
|
private enum Tab: CaseIterable {
|
||||||
case monitor, notifications, alerts
|
case monitor, notifications, alerts, updates
|
||||||
|
|
||||||
var title: String {
|
var title: String {
|
||||||
switch self {
|
switch self {
|
||||||
case .monitor: return "Monitor"
|
case .monitor: return "Monitor"
|
||||||
case .notifications: return "Notifications"
|
case .notifications: return "Notifications"
|
||||||
case .alerts: return "Alerts"
|
case .alerts: return "Alerts"
|
||||||
|
case .updates: return "Updates"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,13 +18,17 @@ struct PreferencesView: View {
|
|||||||
case .monitor: return "waveform.path.ecg"
|
case .monitor: return "waveform.path.ecg"
|
||||||
case .notifications: return "bell.badge"
|
case .notifications: return "bell.badge"
|
||||||
case .alerts: return "exclamationmark.triangle"
|
case .alerts: return "exclamationmark.triangle"
|
||||||
|
case .updates: return "square.and.arrow.down"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@EnvironmentObject private var updateViewModel: UpdateViewModel
|
||||||
|
|
||||||
@AppStorage("pingInterval") private var storedPingInterval: Int = 10
|
@AppStorage("pingInterval") private var storedPingInterval: Int = 10
|
||||||
@AppStorage("refreshInterval") private var storedRefreshInterval: Int = 60
|
@AppStorage("refreshInterval") private var storedRefreshInterval: Int = 60
|
||||||
@AppStorage("showIntervalIndicator") private var showIntervalIndicator: Bool = true
|
@AppStorage("showIntervalIndicator") private var showIntervalIndicator: Bool = true
|
||||||
|
@AppStorage("autoCheckUpdates") private var autoCheckUpdates: Bool = true
|
||||||
|
@AppStorage("includePrereleaseUpdates") private var includePrereleaseUpdates: Bool = true
|
||||||
|
|
||||||
@State private var pingIntervalSlider: Double = 10
|
@State private var pingIntervalSlider: Double = 10
|
||||||
@State private var refreshIntervalSlider: Double = 60
|
@State private var refreshIntervalSlider: Double = 60
|
||||||
@@ -77,14 +82,14 @@ struct PreferencesView: View {
|
|||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
.padding(.horizontal, 10)
|
.padding(.horizontal, 10)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
.background(
|
||||||
|
Capsule(style: .continuous)
|
||||||
|
.fill(backgroundColor(for: tab))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
.focusable(false)
|
.focusable(false)
|
||||||
.contentShape(Capsule())
|
.contentShape(Capsule())
|
||||||
.background(
|
|
||||||
Capsule(style: .continuous)
|
|
||||||
.fill(backgroundColor(for: tab))
|
|
||||||
)
|
|
||||||
.foregroundColor(selection == tab ? .white : .primary)
|
.foregroundColor(selection == tab ? .white : .primary)
|
||||||
.onHover { isHovering in
|
.onHover { isHovering in
|
||||||
hoveredTab = isHovering ? tab : (hoveredTab == tab ? nil : hoveredTab)
|
hoveredTab = isHovering ? tab : (hoveredTab == tab ? nil : hoveredTab)
|
||||||
@@ -120,6 +125,12 @@ struct PreferencesView: View {
|
|||||||
NotificationsPreferencesView()
|
NotificationsPreferencesView()
|
||||||
case .alerts:
|
case .alerts:
|
||||||
AlertsPreferencesView()
|
AlertsPreferencesView()
|
||||||
|
case .updates:
|
||||||
|
UpdatesPreferencesView(
|
||||||
|
autoCheckUpdates: $autoCheckUpdates,
|
||||||
|
includePrereleaseUpdates: $includePrereleaseUpdates
|
||||||
|
)
|
||||||
|
.environmentObject(updateViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,6 +231,51 @@ private struct MonitorPreferencesView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct UpdatesPreferencesView: View {
|
||||||
|
@Binding var autoCheckUpdates: Bool
|
||||||
|
@Binding var includePrereleaseUpdates: Bool
|
||||||
|
@EnvironmentObject var updateViewModel: UpdateViewModel
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack(alignment: .leading, spacing: 16) {
|
||||||
|
Toggle("Automatically check for updates", isOn: $autoCheckUpdates)
|
||||||
|
.toggleStyle(.switch)
|
||||||
|
|
||||||
|
Toggle("Include pre-release builds", isOn: $includePrereleaseUpdates)
|
||||||
|
.toggleStyle(.switch)
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
if updateViewModel.isChecking {
|
||||||
|
ProgressView()
|
||||||
|
.progressViewStyle(.circular)
|
||||||
|
Text("Checking for updates…")
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
} else {
|
||||||
|
Button("Check Now") {
|
||||||
|
updateViewModel.checkForUpdates(userInitiated: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let release = updateViewModel.latestFetchedRelease {
|
||||||
|
VStack(alignment: .leading, spacing: 4) {
|
||||||
|
Text("Latest available: \(release.versionString)")
|
||||||
|
.font(.subheadline)
|
||||||
|
if release.prerelease {
|
||||||
|
Text("Pre-release build")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.top, 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private struct NotificationsPreferencesView: View {
|
private struct NotificationsPreferencesView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading, spacing: 12) {
|
VStack(alignment: .leading, spacing: 12) {
|
||||||
|
|||||||
@@ -59,10 +59,11 @@ struct GeneralView: View {
|
|||||||
var description = os.label.trimmingCharacters(in: .whitespacesAndNewlines)
|
var description = os.label.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
if description.isEmpty {
|
if description.isEmpty {
|
||||||
description = distro
|
description = distro
|
||||||
} else if !distro.isEmpty && distro.caseInsensitiveCompare(description) != .orderedSame {
|
} else if !distro.isEmpty && description.range(of: distro, options: [.caseInsensitive]) == nil {
|
||||||
description += " • \(distro)"
|
description += " • \(distro)"
|
||||||
}
|
}
|
||||||
if !os.architecture.isEmpty {
|
if !os.architecture.isEmpty &&
|
||||||
|
description.range(of: os.architecture, options: [.caseInsensitive]) == nil {
|
||||||
description += " (\(os.architecture))"
|
description += " (\(os.architecture))"
|
||||||
}
|
}
|
||||||
if !description.isEmpty {
|
if !description.isEmpty {
|
||||||
|
|||||||
@@ -6,12 +6,26 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
#if os(macOS)
|
||||||
|
import AppKit
|
||||||
|
#endif
|
||||||
|
|
||||||
@main
|
@main
|
||||||
struct iKeyMonApp: App {
|
struct iKeyMonApp: App {
|
||||||
|
@StateObject private var updateViewModel = UpdateViewModel()
|
||||||
|
|
||||||
|
init() {
|
||||||
|
#if os(macOS)
|
||||||
|
if let customIcon = NSImage(named: "AppIcon") {
|
||||||
|
NSApplication.shared.applicationIconImage = customIcon
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
MainView()
|
MainView()
|
||||||
|
.environmentObject(updateViewModel)
|
||||||
.onDisappear {
|
.onDisappear {
|
||||||
NSApp.terminate(nil)
|
NSApp.terminate(nil)
|
||||||
}
|
}
|
||||||
@@ -21,6 +35,7 @@ struct iKeyMonApp: App {
|
|||||||
Settings {
|
Settings {
|
||||||
PreferencesView()
|
PreferencesView()
|
||||||
.padding()
|
.padding()
|
||||||
|
.environmentObject(updateViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
52A9B79F2EC8E7EE004DD4A2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 52A9B7872EC8E7EE004DD4A2 /* Assets.xcassets */; };
|
52A9B79F2EC8E7EE004DD4A2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 52A9B7872EC8E7EE004DD4A2 /* Assets.xcassets */; };
|
||||||
52A9B8222EC8FA8A004DD4A2 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 52A9B8212EC8FA8A004DD4A2 /* CHANGELOG.md */; };
|
52A9B8222EC8FA8A004DD4A2 /* CHANGELOG.md in Resources */ = {isa = PBXBuildFile; fileRef = 52A9B8212EC8FA8A004DD4A2 /* CHANGELOG.md */; };
|
||||||
|
52A9B9722ECF751C004DD4A2 /* signing.env.example in Resources */ = {isa = PBXBuildFile; fileRef = 52A9B9712ECF751C004DD4A2 /* signing.env.example */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
52A9B7882EC8E7EE004DD4A2 /* iKeyMon.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iKeyMon.entitlements; sourceTree = "<group>"; };
|
52A9B7882EC8E7EE004DD4A2 /* iKeyMon.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = iKeyMon.entitlements; sourceTree = "<group>"; };
|
||||||
52A9B8212EC8FA8A004DD4A2 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
|
52A9B8212EC8FA8A004DD4A2 /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
|
||||||
52A9B8BA2ECA35FB004DD4A2 /* NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = NOTES.md; sourceTree = "<group>"; };
|
52A9B8BA2ECA35FB004DD4A2 /* NOTES.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = NOTES.md; sourceTree = "<group>"; };
|
||||||
|
52A9B9712ECF751C004DD4A2 /* signing.env.example */ = {isa = PBXFileReference; lastKnownFileType = text; path = signing.env.example; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||||
@@ -47,12 +49,13 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
52A9B8BE2ECB68B5004DD4A2 /* Sources */,
|
52A9B8BE2ECB68B5004DD4A2 /* Sources */,
|
||||||
52A9B8BA2ECA35FB004DD4A2 /* NOTES.md */,
|
|
||||||
52A9B7872EC8E7EE004DD4A2 /* Assets.xcassets */,
|
52A9B7872EC8E7EE004DD4A2 /* Assets.xcassets */,
|
||||||
52A9B7882EC8E7EE004DD4A2 /* iKeyMon.entitlements */,
|
52A9B7882EC8E7EE004DD4A2 /* iKeyMon.entitlements */,
|
||||||
52A9B8F72ECB6B8A004DD4A2 /* Preview Content */,
|
52A9B8F72ECB6B8A004DD4A2 /* Preview Content */,
|
||||||
5203C24E2D997D2800576D4A /* Products */,
|
5203C24E2D997D2800576D4A /* Products */,
|
||||||
52A9B8212EC8FA8A004DD4A2 /* CHANGELOG.md */,
|
52A9B8212EC8FA8A004DD4A2 /* CHANGELOG.md */,
|
||||||
|
52A9B8BA2ECA35FB004DD4A2 /* NOTES.md */,
|
||||||
|
52A9B9712ECF751C004DD4A2 /* signing.env.example */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
@@ -131,6 +134,7 @@
|
|||||||
files = (
|
files = (
|
||||||
52A9B8222EC8FA8A004DD4A2 /* CHANGELOG.md in Resources */,
|
52A9B8222EC8FA8A004DD4A2 /* CHANGELOG.md in Resources */,
|
||||||
52A9B79F2EC8E7EE004DD4A2 /* Assets.xcassets in Resources */,
|
52A9B79F2EC8E7EE004DD4A2 /* Assets.xcassets in Resources */,
|
||||||
|
52A9B9722ECF751C004DD4A2 /* signing.env.example in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@@ -273,18 +277,19 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = iKeyMon.entitlements;
|
CODE_SIGN_ENTITLEMENTS = iKeyMon.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 30;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = Q5486ZVAFT;
|
DEVELOPMENT_TEAM = Q5486ZVAFT;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_KEY_CFBundleIconName = AppIcon;
|
||||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 26.0.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.24unix.iKeyMon;
|
PRODUCT_BUNDLE_IDENTIFIER = net.24unix.iKeyMon;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -300,18 +305,19 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = iKeyMon.entitlements;
|
CODE_SIGN_ENTITLEMENTS = iKeyMon.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 30;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"Preview Content\"";
|
||||||
DEVELOPMENT_TEAM = Q5486ZVAFT;
|
DEVELOPMENT_TEAM = Q5486ZVAFT;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
|
INFOPLIST_KEY_CFBundleIconName = AppIcon;
|
||||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0;
|
MARKETING_VERSION = 26.0.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = net.24unix.iKeyMon;
|
PRODUCT_BUNDLE_IDENTIFIER = net.24unix.iKeyMon;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|||||||
@@ -6,6 +6,17 @@ BUILD_DIR="$ROOT_DIR/build"
|
|||||||
ARTIFACTS_DIR="$ROOT_DIR/dist"
|
ARTIFACTS_DIR="$ROOT_DIR/dist"
|
||||||
SCHEME="iKeyMon"
|
SCHEME="iKeyMon"
|
||||||
PROJECT="iKeyMon.xcodeproj"
|
PROJECT="iKeyMon.xcodeproj"
|
||||||
|
CREDENTIALS_FILE="$ROOT_DIR/.signing.env"
|
||||||
|
VERSION_FILE="$ROOT_DIR/version.json"
|
||||||
|
|
||||||
|
if [[ -f "$CREDENTIALS_FILE" ]]; then
|
||||||
|
set -a
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
source "$CREDENTIALS_FILE"
|
||||||
|
set +a
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$ROOT_DIR/scripts/sync_version.sh"
|
||||||
|
|
||||||
rm -rf "$BUILD_DIR" "$ARTIFACTS_DIR"
|
rm -rf "$BUILD_DIR" "$ARTIFACTS_DIR"
|
||||||
mkdir -p "$ARTIFACTS_DIR"
|
mkdir -p "$ARTIFACTS_DIR"
|
||||||
@@ -15,6 +26,7 @@ xcodebuild \
|
|||||||
-scheme "$SCHEME" \
|
-scheme "$SCHEME" \
|
||||||
-configuration Release \
|
-configuration Release \
|
||||||
-derivedDataPath "$BUILD_DIR" \
|
-derivedDataPath "$BUILD_DIR" \
|
||||||
|
CODE_SIGNING_ALLOWED=NO \
|
||||||
clean build
|
clean build
|
||||||
|
|
||||||
APP_PATH="$BUILD_DIR/Build/Products/Release/iKeyMon.app"
|
APP_PATH="$BUILD_DIR/Build/Products/Release/iKeyMon.app"
|
||||||
@@ -23,20 +35,61 @@ if [[ ! -d "$APP_PATH" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION=$(xcodebuild \
|
if [[ -n "${CODESIGN_IDENTITY:-}" ]]; then
|
||||||
-project "$ROOT_DIR/$PROJECT" \
|
echo "🔏 Codesigning app with identity: $CODESIGN_IDENTITY"
|
||||||
-scheme "$SCHEME" \
|
codesign \
|
||||||
-configuration Release \
|
--deep \
|
||||||
-showBuildSettings | awk '/MARKETING_VERSION/ {print $3; exit}')
|
--force \
|
||||||
if [[ -z "$VERSION" ]]; then
|
--options runtime \
|
||||||
VERSION="dev"
|
--timestamp \
|
||||||
|
--entitlements "$ROOT_DIR/iKeyMon.entitlements" \
|
||||||
|
--sign "$CODESIGN_IDENTITY" \
|
||||||
|
"$APP_PATH"
|
||||||
|
else
|
||||||
|
echo "⚠️ Skipping codesign (CODESIGN_IDENTITY not set)."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
STAGING_DIR=$(mktemp -d)
|
||||||
|
mkdir -p "$STAGING_DIR"
|
||||||
|
cp -R "$APP_PATH" "$STAGING_DIR/"
|
||||||
|
ln -s /Applications "$STAGING_DIR/Applications"
|
||||||
|
mkdir -p "$STAGING_DIR/.background"
|
||||||
|
cp "$ROOT_DIR/Assets/dmg_background.png" "$STAGING_DIR/.background/background.png"
|
||||||
|
|
||||||
|
VERSION="$(python3 - <<'PY' "$VERSION_FILE"
|
||||||
|
import json, sys
|
||||||
|
with open(sys.argv[1], "r", encoding="utf-8") as handle:
|
||||||
|
data = json.load(handle)
|
||||||
|
print(data.get("marketing_version", "dev"))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
ZIP_NAME="iKeyMon-${VERSION}.zip"
|
ZIP_NAME="iKeyMon-${VERSION}.zip"
|
||||||
pushd "$(dirname "$APP_PATH")" >/dev/null
|
pushd "$(dirname "$APP_PATH")" >/dev/null
|
||||||
zip -r "$ARTIFACTS_DIR/$ZIP_NAME" "$(basename "$APP_PATH")"
|
zip -r "$ARTIFACTS_DIR/$ZIP_NAME" "$(basename "$APP_PATH")"
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
||||||
DMG_NAME="iKeyMon-${VERSION}.dmg"
|
DMG_NAME="iKeyMon-${VERSION}.dmg"
|
||||||
hdiutil create -volname "iKeyMon" -srcfolder "$APP_PATH" -ov -format UDZO "$ARTIFACTS_DIR/$DMG_NAME"
|
hdiutil create -volname "iKeyMon" -srcfolder "$STAGING_DIR" -ov -format UDZO "$ARTIFACTS_DIR/$DMG_NAME"
|
||||||
|
|
||||||
echo "✅ Build complete. Artifact: $ARTIFACTS_DIR/$ZIP_NAME"
|
if [[ -n "${NOTARY_APPLE_ID:-}" && -n "${NOTARY_TEAM_ID:-}" && -n "${NOTARY_PASSWORD:-}" ]]; then
|
||||||
|
echo "📝 Submitting DMG for notarization..."
|
||||||
|
xcrun notarytool submit "$ARTIFACTS_DIR/$DMG_NAME" \
|
||||||
|
--apple-id "$NOTARY_APPLE_ID" \
|
||||||
|
--team-id "$NOTARY_TEAM_ID" \
|
||||||
|
--password "$NOTARY_PASSWORD" \
|
||||||
|
--wait
|
||||||
|
xcrun stapler staple "$ARTIFACTS_DIR/$DMG_NAME"
|
||||||
|
else
|
||||||
|
echo "⚠️ Skipping notarization (NOTARY_* variables not set)."
|
||||||
|
fi
|
||||||
|
rm -rf "$STAGING_DIR"
|
||||||
|
|
||||||
|
if [[ -n "${GITEA_TOKEN:-}" && -n "${GITEA_OWNER:-}" && -n "${GITEA_REPO:-}" ]]; then
|
||||||
|
"$ROOT_DIR/scripts/publish_release.sh" "$VERSION" "$ARTIFACTS_DIR/$ZIP_NAME" "$ARTIFACTS_DIR/$DMG_NAME"
|
||||||
|
else
|
||||||
|
echo "ℹ️ Skipping Gitea release publishing (GITEA_* variables not fully set)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ Build complete. Artifacts:"
|
||||||
|
echo " - $ARTIFACTS_DIR/$ZIP_NAME"
|
||||||
|
echo " - $ARTIFACTS_DIR/$DMG_NAME"
|
||||||
|
|||||||
81
scripts/publish_release.sh
Executable file
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
VERSION="$1"
|
||||||
|
ZIP_PATH="$2"
|
||||||
|
DMG_PATH="$3"
|
||||||
|
|
||||||
|
: "${GITEA_TOKEN:?Set GITEA_TOKEN in .signing.env}"
|
||||||
|
: "${GITEA_OWNER:?Set GITEA_OWNER in .signing.env}"
|
||||||
|
: "${GITEA_REPO:?Set GITEA_REPO in .signing.env}"
|
||||||
|
|
||||||
|
TARGET_COMMIT="${GITEA_TARGET_COMMIT:-$(git -C "$ROOT_DIR" rev-parse HEAD)}"
|
||||||
|
API_BASE="${GITEA_API_BASE:-https://git.24unix.net/api/v1}"
|
||||||
|
API_BASE="${API_BASE%/}"
|
||||||
|
RELEASE_TAG="v${VERSION}"
|
||||||
|
API_URL="${API_BASE}/repos/${GITEA_OWNER}/${GITEA_REPO}"
|
||||||
|
|
||||||
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
|
echo "❌ jq is required to parse Gitea responses." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PRERELEASE_FLAG="${GITEA_PRERELEASE:-true}"
|
||||||
|
|
||||||
|
create_payload="$(jq -n \
|
||||||
|
--arg tag "$RELEASE_TAG" \
|
||||||
|
--arg name "iKeyMon ${VERSION}" \
|
||||||
|
--arg target "$TARGET_COMMIT" \
|
||||||
|
--argjson prerelease "$PRERELEASE_FLAG" \
|
||||||
|
'{ tag_name: $tag, name: $name, target_commitish: $target, draft: false, prerelease: $prerelease }')"
|
||||||
|
|
||||||
|
response_file="$(mktemp)"
|
||||||
|
http_code=$(curl -sS -w "%{http_code}" -o "$response_file" \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-X POST \
|
||||||
|
-d "$create_payload" \
|
||||||
|
"${API_URL}/releases")
|
||||||
|
|
||||||
|
if [[ "$http_code" == "201" ]]; then
|
||||||
|
echo "✅ Created release ${RELEASE_TAG}"
|
||||||
|
elif [[ "$http_code" == "409" ]]; then
|
||||||
|
echo "ℹ️ Release ${RELEASE_TAG} already exists, fetching existing ID."
|
||||||
|
else
|
||||||
|
echo "❌ Failed to create release (HTTP ${http_code}):"
|
||||||
|
cat "$response_file"
|
||||||
|
rm -f "$response_file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$http_code" == "409" ]]; then
|
||||||
|
curl -sS \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
"${API_URL}/releases/tags/${RELEASE_TAG}" >"$response_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
release_id=$(jq -r '.id' "$response_file")
|
||||||
|
rm -f "$response_file"
|
||||||
|
|
||||||
|
if [[ -z "$release_id" || "$release_id" == "null" ]]; then
|
||||||
|
echo "❌ Could not determine release ID for ${RELEASE_TAG}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
upload_asset() {
|
||||||
|
local file="$1"
|
||||||
|
local filename
|
||||||
|
filename="$(basename "$file")"
|
||||||
|
|
||||||
|
echo "⬆️ Uploading ${filename}"
|
||||||
|
curl -sS \
|
||||||
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
|
-F "attachment=@${file}" \
|
||||||
|
"${API_URL}/releases/${release_id}/assets" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
upload_asset "$ZIP_PATH"
|
||||||
|
upload_asset "$DMG_PATH"
|
||||||
|
|
||||||
|
echo "🎉 Release ${RELEASE_TAG} assets uploaded."
|
||||||
56
scripts/sync_version.sh
Executable file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
VERSION_FILE="$ROOT_DIR/version.json"
|
||||||
|
PROJECT_FILE="$ROOT_DIR/iKeyMon.xcodeproj/project.pbxproj"
|
||||||
|
|
||||||
|
if [[ ! -f "$VERSION_FILE" ]]; then
|
||||||
|
echo "❌ version.json not found at $VERSION_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
|
echo "❌ jq is required but not found in PATH" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
MARKETING_VERSION="$(jq -r '.marketing_version // empty' "$VERSION_FILE")"
|
||||||
|
if [[ -z "$MARKETING_VERSION" ]]; then
|
||||||
|
echo "❌ marketing_version missing in $VERSION_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! "$MARKETING_VERSION" =~ ^[0-9]{2}\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo "❌ marketing_version '$MARKETING_VERSION' must follow YY.major.minor (e.g. 26.1.2)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_NUMBER="${BUILD_NUMBER:-$(git -C "$ROOT_DIR" rev-list --count HEAD)}"
|
||||||
|
if [[ -z "$BUILD_NUMBER" ]]; then
|
||||||
|
echo "❌ Unable to derive BUILD_NUMBER" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
update_setting() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
local tmp
|
||||||
|
tmp="$(mktemp)"
|
||||||
|
LC_ALL=C sed -E "s/(${key}[[:space:]]*=[[:space:]]*)[^;]+;/\\1${value};/g" "$PROJECT_FILE" >"$tmp"
|
||||||
|
if cmp -s "$tmp" "$PROJECT_FILE"; then
|
||||||
|
if ! grep -q "${key} = ${value};" "$PROJECT_FILE"; then
|
||||||
|
rm -f "$tmp"
|
||||||
|
echo "❌ Failed to update ${key} in $PROJECT_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
rm -f "$tmp"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
mv "$tmp" "$PROJECT_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
update_setting "MARKETING_VERSION" "$MARKETING_VERSION"
|
||||||
|
update_setting "CURRENT_PROJECT_VERSION" "$BUILD_NUMBER"
|
||||||
|
|
||||||
|
echo "✅ Synced marketing version $MARKETING_VERSION and build $BUILD_NUMBER into Xcode project."
|
||||||
10
signing.env.example
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
CODESIGN_IDENTITY="Developer ID Application: Your Name (TEAMID1234)"
|
||||||
|
NOTARY_APPLE_ID="appleid@example.com"
|
||||||
|
NOTARY_TEAM_ID="TEAMID1234"
|
||||||
|
NOTARY_PASSWORD="app-specific-password"
|
||||||
|
GITEA_TOKEN="personal-access-token"
|
||||||
|
GITEA_OWNER="tracer"
|
||||||
|
GITEA_REPO="iKeyMon"
|
||||||
|
# GITEA_API_BASE="https://git.24unix.net/api/v1"
|
||||||
|
# GITEA_TARGET_COMMIT="master"
|
||||||
|
# GITEA_PRERELEASE="false"
|
||||||
3
version.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"marketing_version": "26.0.3"
|
||||||
|
}
|
||||||