diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5b524e..c11e3f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,6 @@ -# Triggered by a version tag (v1.0.0): builds one DMG per architecture with -# ad-hoc signing and publishes a GitHub Release with checksums and first-launch -# instructions. Download URLs match the website convention agreed in fm-landing -# (site CTA points at /releases/latest). +# Triggered by a version tag (v1.0.0): publishes release notes and update instructions +# on GitHub Releases without producing ad-hoc prebuilt binaries (since File Provider +# extensions require local code signing with personal Apple ID for AMFI / App Groups). name: Release on: @@ -12,150 +11,26 @@ permissions: contents: write jobs: - build-dmg: - name: Build DMG (${{ matrix.arch }}) - runs-on: macos-26 - strategy: - matrix: - arch: [arm64, x86_64] - steps: - - uses: actions/checkout@v7 - - - name: Cache pinned rclone runtime - uses: actions/cache@v6 - with: - path: .build/rclone-artifacts - key: rclone-v1.75.1 - - - name: Install XcodeGen - run: brew install xcodegen - - - name: Materialize build configuration - env: - GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} - GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} - run: | - if [ -n "$GOOGLE_CLIENT_ID" ]; then - printf 'FREEMOUNT_GOOGLE_CLIENT_ID = %s\nFREEMOUNT_GOOGLE_CLIENT_SECRET = %s\nDEVELOPMENT_TEAM =\n' \ - "$GOOGLE_CLIENT_ID" "$GOOGLE_CLIENT_SECRET" > Configs/Secrets.xcconfig - else - cp Configs/Secrets.xcconfig.example Configs/Secrets.xcconfig - fi - - - name: Generate Xcode project - run: xcodegen generate - - - name: Build Release (${{ matrix.arch }}) - run: | - xcodebuild -project FreeMount.xcodeproj -scheme FreeMount \ - -configuration Release -destination 'platform=macOS' \ - -derivedDataPath ci-derived \ - ARCHS=${{ matrix.arch }} ONLY_ACTIVE_ARCH=NO \ - CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO \ - build - - - name: Verify OAuth config embedded in built app - run: | - APP="ci-derived/Build/Products/Release/FM.app" - ID="$(plutil -extract FreeMountGoogleOAuthClientID raw "$APP/Contents/Info.plist" 2>/dev/null || true)" - if [ -z "$ID" ]; then - echo "::error=Built app has empty FREEMOUNT_GOOGLE_CLIENT_ID — xcconfig wiring or secrets broken" - exit 1 - fi - - - name: Stage app bundle (rename, prune foreign rclone runtime) - run: | - APP="ci-derived/Build/Products/Release/FM.app" - # Reclaim runner disk before image creation. - rm -rf "$HOME/Library/Developer/Xcode/DerivedData" \ - ci-derived/Build/Intermediates.noindex - STAGE="dmg-stage" - mkdir -p "$STAGE" - # Ship as FreeMount.app even though PRODUCT_NAME is FM. - cp -R "$APP" "$STAGE/FreeMount.app" - # Slim DMG: keep only the rclone helper matching this build's arch. - if [ "${{ matrix.arch }}" = "arm64" ]; then - rm -f "$STAGE/FreeMount.app/Contents/Helpers/rclone-amd64" - else - rm -f "$STAGE/FreeMount.app/Contents/Helpers/rclone-arm64" - fi - ln -s /Applications "$STAGE/Applications" - - - name: Ad-hoc sign staged bundle (nested Mach-O first, then app) - run: | - APP="dmg-stage/FreeMount.app" - # TODO(Task 12 spike): verify App Group + Keychain access group + - # File Provider registration survive ad-hoc signing on a clean Mac. - # Xcode expands $(TeamIdentifierPrefix)/$(AppIdentifierPrefix) only in - # its own signing step; manual codesign embeds them literally, so for - # ad-hoc (no team) builds we strip the empty prefixes ourselves. - python3 - <<'PYEOF' - import plistlib - def clean(src, dst): - d = plistlib.load(open(src, "rb")) - for k, v in list(d.items()): - if isinstance(v, list): - v = [s.replace("$(TeamIdentifierPrefix)", "").replace("$(AppIdentifierPrefix)", "") - if isinstance(s, str) else s for s in v] - d[k] = [s for s in v if s != ""] - elif isinstance(v, str): - d[k] = v.replace("$(TeamIdentifierPrefix)", "").replace("$(AppIdentifierPrefix)", "") - plistlib.dump(d, open(dst, "wb")) - clean("App/Resources/FreeMount.entitlements", "/tmp/app.ent") - clean("App/FileProviderExtension/FreeMountFileProvider.entitlements", "/tmp/ext.ent") - PYEOF - # CI builds with signing disabled, so bundled rclone helpers arrive - # unsigned; every Mach-O must carry a signature to run (required on - # Apple silicon), hence sign helpers -> appex -> app. Helpers now - # contain exactly one entry, matching this DMG's architecture. - find "$APP/Contents/Helpers" -type f -exec codesign --force --sign - {} \; - codesign --force --sign - --entitlements /tmp/ext.ent \ - "$APP/Contents/PlugIns/FreeMountFileProvider.appex" - codesign --force --sign - --entitlements /tmp/app.ent "$APP" - codesign --verify --deep --strict --verbose=2 "$APP" - ! codesign -d --entitlements - "$APP" 2>/dev/null | grep -q 'TeamIdentifierPrefix' - - - name: Create DMG - run: | - hdiutil create -volname FreeMount -srcfolder dmg-stage -ov \ - -format UDZO "FreeMount-${GITHUB_REF_NAME}-${{ matrix.arch }}.dmg" - shasum -a 256 "FreeMount-${GITHUB_REF_NAME}-${{ matrix.arch }}.dmg" >> checksums.txt - rm -rf dmg-stage - - - name: Upload artifacts - uses: actions/upload-artifact@v7 - with: - name: dmg-${{ matrix.arch }} - path: | - FreeMount-${{ github.ref_name }}-${{ matrix.arch }}.dmg - checksums.txt - publish-release: - name: Publish GitHub Release - needs: build-dmg + name: Publish Release Notes runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v8 - with: - merge-multiple: true - - - name: Release notes - id: notes - run: | - { - echo 'body<> "$GITHUB_OUTPUT" - - - name: Create release + - name: Create GitHub Release uses: softprops/action-gh-release@v3 with: - files: FreeMount-*.dmg - body: ${{ steps.notes.outputs.body }} generate_release_notes: true + body: | + ### Installing or Updating FreeMount + + Because FreeMount uses Apple File Provider extensions, App Groups, and Keychain sharing, macOS requires it to be signed by your personal Apple ID team. Prebuilt unsigned or ad-hoc binaries cannot launch the extension on other Macs. + + #### One-line Install / Update + Run the install script in Terminal: + ```bash + git clone https://github.com/ChornyiDev/FreeMount.git && cd FreeMount && ./scripts/install-from-source.sh + ``` + + If you already have FreeMount installed, click **"Update Now"** in FreeMount Settings → About, or run: + ```bash + cd ~/FreeMount && git pull && ./scripts/install-from-source.sh + ``` diff --git a/App/Services/UpdateService.swift b/App/Services/UpdateService.swift new file mode 100644 index 0000000..6f065d6 --- /dev/null +++ b/App/Services/UpdateService.swift @@ -0,0 +1,116 @@ +import Foundation + +/// Represents a GitHub Release payload subset needed for update inspection. +public struct GitHubReleaseInfo: Codable, Sendable, Equatable { + public let tagName: String + public let name: String? + public let body: String? + public let htmlUrl: URL? + public let publishedAt: Date? + + enum CodingKeys: String, CodingKey { + case tagName = "tag_name" + case name + case body + case htmlUrl = "html_url" + case publishedAt = "published_at" + } +} + +/// Status of the manual update check. +public enum UpdateCheckStatus: Sendable, Equatable { + case idle + case checking + case upToDate(currentVersion: String) + case updateAvailable(latestVersion: String, currentVersion: String, release: GitHubReleaseInfo) + case failed(message: String) +} + +/// Actor responsible for performing on-demand manual update checks against GitHub Releases. +public actor UpdateService { + private let session: URLSession + private let repositoryOwner: String + private let repositoryName: String + + public init( + session: URLSession = .shared, + repositoryOwner: String = "ChornyiDev", + repositoryName: String = "FreeMount" + ) { + self.session = session + self.repositoryOwner = repositoryOwner + self.repositoryName = repositoryName + } + + /// Fetches the latest release from GitHub Releases API without downloading any binaries. + public func fetchLatestRelease() async throws -> GitHubReleaseInfo { + let endpoint = "https://api.github.com/repos/\(repositoryOwner)/\(repositoryName)/releases/latest" + guard let url = URL(string: endpoint) else { + throw URLError(.badURL) + } + + var request = URLRequest(url: url) + request.httpMethod = "GET" + request.setValue("application/vnd.github+json", forHTTPHeaderField: "Accept") + request.setValue("FreeMount-App", forHTTPHeaderField: "User-Agent") + request.timeoutInterval = 15 + + let (data, response) = try await session.data(for: request) + guard let httpResponse = response as? HTTPURLResponse else { + throw URLError(.badServerResponse) + } + + if httpResponse.statusCode == 404 { + // No releases published yet on the repository + throw UpdateError.noReleasesFound + } + + guard (200...299).contains(httpResponse.statusCode) else { + throw UpdateError.httpError(statusCode: httpResponse.statusCode) + } + + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .iso8601 + return try decoder.decode(GitHubReleaseInfo.self, from: data) + } + + /// Compares two semantic version strings (e.g. "v1.0.1" vs "1.0.0"). + /// Returns true if `remote` is strictly higher than `current`. + public static func isVersion(_ remote: String, newerThan current: String) -> Bool { + let cleanRemote = cleanVersion(remote) + let cleanCurrent = cleanVersion(current) + + let remoteParts = cleanRemote.split(separator: ".").compactMap { Int($0) } + let currentParts = cleanCurrent.split(separator: ".").compactMap { Int($0) } + + let count = max(remoteParts.count, currentParts.count) + for i in 0.. c { return true } + if r < c { return false } + } + return false + } + + private static func cleanVersion(_ version: String) -> String { + version.trimmingCharacters(in: .whitespacesAndNewlines) + .lowercased() + .trimmingCharacters(in: CharacterSet(charactersIn: "v")) + } +} + +public enum UpdateError: LocalizedError, Equatable { + case noReleasesFound + case httpError(statusCode: Int) + + public var errorDescription: String? { + switch self { + case .noReleasesFound: + return "No official releases found on GitHub." + case .httpError(let code): + return "GitHub API responded with HTTP status \(code)." + } + } +} + diff --git a/App/Services/UpdateWorkflowManager.swift b/App/Services/UpdateWorkflowManager.swift new file mode 100644 index 0000000..280df51 --- /dev/null +++ b/App/Services/UpdateWorkflowManager.swift @@ -0,0 +1,46 @@ +import AppKit +import Foundation + +/// Manages resolution and execution of the source-based update workflow. +public enum UpdateWorkflowManager { + public static let defaultRepoPathKey = "FreeMountSourceRepositoryPath" + public static let cloneCommand = "git clone https://github.com/ChornyiDev/FreeMount.git && cd FreeMount && ./scripts/install-from-source.sh" + + /// Discovers if the repository folder exists at the saved path or default home directory. + public static func resolveRepositoryPath() -> String? { + if let saved = UserDefaults.standard.string(forKey: defaultRepoPathKey), + FileManager.default.fileExists(atPath: saved + "/scripts/install-from-source.sh") { + return saved + } + + let homeCandidate = FileManager.default.homeDirectoryForCurrentUser + .appendingPathComponent("FreeMount", isDirectory: true).path + if FileManager.default.fileExists(atPath: homeCandidate + "/scripts/install-from-source.sh") { + return homeCandidate + } + + return nil + } + + /// Stores the active repository path in preferences. + public static func recordRepositoryPath(_ path: String) { + UserDefaults.standard.set(path, forKey: defaultRepoPathKey) + } + + /// Executes the update command in macOS Terminal using AppleScript. + /// This ensures that the user can see build progress and provide credentials if needed. + public static func executeUpdateInTerminal(at repoPath: String) { + let escapedPath = repoPath.replacingOccurrences(of: "\"", with: "\\\"") + let script = """ + tell application "Terminal" + activate + do script "cd \\"\(escapedPath)\\" && git pull && ./scripts/install-from-source.sh" + end tell + """ + var error: NSDictionary? + if let appleScript = NSAppleScript(source: script) { + appleScript.executeAndReturnError(&error) + } + } +} + diff --git a/App/ViewModels/SettingsViewModel.swift b/App/ViewModels/SettingsViewModel.swift index 83bb097..71c122f 100644 --- a/App/ViewModels/SettingsViewModel.swift +++ b/App/ViewModels/SettingsViewModel.swift @@ -13,6 +13,10 @@ final class SettingsViewModel { private(set) var isRestarting = false private(set) var errorMessage: String? + // Update checking state + private(set) var updateStatus: UpdateCheckStatus = .idle + private let updateService = UpdateService() + init(supervisor: RcloneProcessSupervisor) { self.supervisor = supervisor } @@ -64,4 +68,25 @@ final class SettingsViewModel { let minutes = (seconds % 3600) / 60 return hours > 0 ? "\(hours)h \(minutes)m" : "\(minutes)m" } + + func checkForUpdates(currentVersion: String) async { + guard updateStatus != .checking else { return } + updateStatus = .checking + do { + let release = try await updateService.fetchLatestRelease() + if UpdateService.isVersion(release.tagName, newerThan: currentVersion) { + updateStatus = .updateAvailable( + latestVersion: release.tagName, + currentVersion: currentVersion, + release: release + ) + } else { + updateStatus = .upToDate(currentVersion: currentVersion) + } + } catch UpdateError.noReleasesFound { + updateStatus = .upToDate(currentVersion: currentVersion) + } catch { + updateStatus = .failed(message: error.localizedDescription) + } + } } diff --git a/App/Views/Settings/SettingsView.swift b/App/Views/Settings/SettingsView.swift index 4d5c4a2..66393ac 100644 --- a/App/Views/Settings/SettingsView.swift +++ b/App/Views/Settings/SettingsView.swift @@ -131,6 +131,15 @@ struct SettingsView: View { Text("Native macOS cloud storage powered by Apple File Provider and rclone.") .multilineTextAlignment(.center) .foregroundStyle(Color.dsTextSecondary) + + UpdateSectionView( + status: viewModel.updateStatus, + currentVersion: appVersion, + onCheck: { + Task { await viewModel.checkForUpdates(currentVersion: appVersion) } + } + ) + Text("rclone is distributed under the MIT License. Notices are included with the application.") .font(.caption) .foregroundStyle(Color.dsTextMuted) diff --git a/App/Views/Settings/UpdateSectionView.swift b/App/Views/Settings/UpdateSectionView.swift new file mode 100644 index 0000000..ff53856 --- /dev/null +++ b/App/Views/Settings/UpdateSectionView.swift @@ -0,0 +1,172 @@ +import SwiftUI +import AppKit + +struct UpdateSectionView: View { + let status: UpdateCheckStatus + let currentVersion: String + let onCheck: () -> Void + + @State private var showingRecloneSheet = false + @State private var copiedCommand = false + + var body: some View { + VStack(spacing: DSSpacing.sm) { + renderContent() + } + .sheet(isPresented: $showingRecloneSheet) { + recloneSheetView + } + } + + @ViewBuilder + private func renderContent() -> some View { + switch status { + case .idle: + Button(action: onCheck) { + Label("Check for Updates", systemImage: "arrow.triangle.2.circlepath") + } + .buttonStyle(.bordered) + .controlSize(.small) + + case .checking: + HStack(spacing: DSSpacing.xs) { + ProgressView() + .controlSize(.small) + Text("Checking for updates…") + .font(.caption) + .foregroundStyle(Color.dsTextMuted) + } + + case .upToDate: + HStack(spacing: DSSpacing.xs) { + Image(systemName: "checkmark.circle.fill") + .foregroundStyle(Color.dsGreen) + Text("FreeMount is up to date") + .font(.caption) + .foregroundStyle(Color.dsTextSecondary) + Button("Check again", action: onCheck) + .buttonStyle(.link) + .font(.caption) + } + + case .updateAvailable(let latest, _, let release): + updateAvailableView(latest: latest, release: release) + + case .failed(let message): + failedView(message: message) + } + } + + private func updateAvailableView(latest: String, release: GitHubReleaseInfo) -> some View { + VStack(spacing: DSSpacing.xs) { + HStack(spacing: DSSpacing.xs) { + Image(systemName: "arrow.up.circle.fill") + .foregroundStyle(Color.dsAccent) + Text("New version available: \(latest)") + .font(.callout.bold()) + } + + if let body = release.body, !body.isEmpty { + let preview = String(body.prefix(140)) + (body.count > 140 ? "…" : "") + Text(preview) + .font(.caption2) + .foregroundStyle(Color.dsTextMuted) + .multilineTextAlignment(.center) + .lineLimit(2) + .padding(.horizontal, DSSpacing.md) + } + + HStack(spacing: DSSpacing.sm) { + Button(action: handleUpdateTrigger) { + Label("Update Now", systemImage: "arrow.down.circle") + } + .buttonStyle(.borderedProminent) + .controlSize(.small) + + if let url = release.htmlUrl { + Link("View Release", destination: url) + .font(.caption) + } + } + } + .padding(DSSpacing.sm) + .background(Color(nsColor: .controlBackgroundColor)) + .clipShape(RoundedRectangle(cornerRadius: 8)) + } + + private func failedView(message: String) -> some View { + VStack(spacing: DSSpacing.xs) { + HStack(spacing: DSSpacing.xs) { + Image(systemName: "exclamationmark.triangle.fill") + .foregroundStyle(Color.dsRed) + Text("Could not check for updates") + .font(.caption) + .foregroundStyle(Color.dsRed) + } + Text(message) + .font(.caption2) + .foregroundStyle(Color.dsTextMuted) + Button("Retry", action: onCheck) + .buttonStyle(.link) + .font(.caption) + } + } + + private func handleUpdateTrigger() { + if let repoPath = UpdateWorkflowManager.resolveRepositoryPath() { + UpdateWorkflowManager.executeUpdateInTerminal(at: repoPath) + } else { + showingRecloneSheet = true + } + } + + private var recloneSheetView: some View { + VStack(spacing: DSSpacing.md) { + Image(systemName: "folder.badge.questionmark") + .font(.system(size: 36)) + .foregroundStyle(Color.dsAccent) + + Text("Local Source Directory Not Found") + .font(.headline) + + Text("The original FreeMount source folder has been moved or removed. To update, re-clone the repository and run the install script:") + .font(.caption) + .foregroundStyle(Color.dsTextSecondary) + .multilineTextAlignment(.center) + + HStack { + Text(UpdateWorkflowManager.cloneCommand) + .font(.system(size: 11, design: .monospaced)) + .lineLimit(2) + .textSelection(.enabled) + .padding(DSSpacing.sm) + .frame(maxWidth: .infinity, alignment: .leading) + .background(Color.black.opacity(0.1)) + .cornerRadius(6) + + Button { + NSPasteboard.general.clearContents() + NSPasteboard.general.setString(UpdateWorkflowManager.cloneCommand, forType: .string) + copiedCommand = true + Task { + try? await Task.sleep(for: .seconds(2)) + copiedCommand = false + } + } label: { + Label(copiedCommand ? "Copied" : "Copy", systemImage: copiedCommand ? "checkmark" : "doc.on.doc") + } + .controlSize(.small) + } + + HStack { + Spacer() + Button("Done") { + showingRecloneSheet = false + } + .keyboardShortcut(.defaultAction) + } + } + .padding(DSSpacing.xl) + .frame(width: 480) + } +} diff --git a/FreeMount.xcodeproj/project.pbxproj b/FreeMount.xcodeproj/project.pbxproj index f4ef662..1f012f9 100644 --- a/FreeMount.xcodeproj/project.pbxproj +++ b/FreeMount.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ 575573215F4F54CCF9809A22 /* RcloneRemoteCredential.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE1A681282640DF383476AFC /* RcloneRemoteCredential.swift */; }; 5B8F6C73A59B634795A975B2 /* ConnectionManagerWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4C58E48E6C0B914B65F77D /* ConnectionManagerWindow.swift */; }; 5E6BF40871AD052BC6026A87 /* ConnectionDiagnostic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73F86CF1B1FA8183BDE7AC27 /* ConnectionDiagnostic.swift */; }; + 5F772BF7C21C7B53E4360FEA /* UpdateService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B77D562FE95A45B3698C508E /* UpdateService.swift */; }; 60F5E2AC01C3F94274EDB207 /* RcloneJobModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D799AD75BD423C55CB4EE95 /* RcloneJobModels.swift */; }; 612F16F805316A1239189FD2 /* SSHTunnelConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C2726BB361981A5C767923 /* SSHTunnelConfiguration.swift */; }; 61BA0F4EC7648FEC62177215 /* TransferStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FC3BA3EC71AFCD7A4CE8ED3 /* TransferStats.swift */; }; @@ -80,6 +81,7 @@ 7538D8CE7351DDBCAEA946E2 /* MenuBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B155EDD0651910A0FB34365A /* MenuBarView.swift */; }; 767100BFD2A5DB4D690BA831 /* ConnectionFormSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30E15859287E06296D129C4D /* ConnectionFormSection.swift */; }; 775FC3CBF6B861BC047AF268 /* ConnectionSidebarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584E765A87A42CB7CC534285 /* ConnectionSidebarView.swift */; }; + 77671E8C5C13E0CFCDD54D50 /* UpdateWorkflowManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87CE2CAD7AA678E56D78CA8 /* UpdateWorkflowManager.swift */; }; 776D87FFED621BC035ACFACD /* GoogleCloudStorageModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79E855D8007C2398697972AF /* GoogleCloudStorageModels.swift */; }; 7886A198AD8CECC2652D2EC7 /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC5438FBC1F5C96C964DCC9D /* Errors.swift */; }; 78FEE414E8C5BDAB4F5B8BF7 /* AppPreferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5795B9DA47C6CD208908508 /* AppPreferences.swift */; }; @@ -91,6 +93,7 @@ 8F27B02FBE887E07FB8A87FD /* CredentialRedactor.swift in Sources */ = {isa = PBXBuildFile; fileRef = A68BE09BABFD9847AF7BD487 /* CredentialRedactor.swift */; }; 951E5D6A90928E8E84F6C6C3 /* MountStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9FF66AA2849C2E0230AACA3 /* MountStatus.swift */; }; 954D94C53F19EF8082A293A4 /* SSHTunnelConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2C2726BB361981A5C767923 /* SSHTunnelConfiguration.swift */; }; + 95E08BD3518A780A3CD4B418 /* UpdateWorkflowManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = F87CE2CAD7AA678E56D78CA8 /* UpdateWorkflowManager.swift */; }; 9851C1B36C93FD9CA88C8001 /* FTPFileProviderBackend.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA61544B3A67E742E2FAEC8F /* FTPFileProviderBackend.swift */; }; 99037D0875A2F9BEED630133 /* ProviderID.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42E2BCD8B94D811E984DB95 /* ProviderID.swift */; }; 9A32EDB4BA9B8B3BD698DEAE /* FileProviderWorkingSetCollector.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3441C93E33048C0C4C9E7828 /* FileProviderWorkingSetCollector.swift */; }; @@ -102,6 +105,7 @@ ADDC8A3AC62EEE9F1897AF10 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94F147F1D26C596753CE1D9F /* SettingsViewModel.swift */; }; AEAA8C30AB2BC875A3DE3FC0 /* SSHKeyDiscoveryService.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9EE964AA60F26C21316EE56 /* SSHKeyDiscoveryService.swift */; }; B2D0D02B24E146DBCC4F19EF /* GoogleDriveFileProviderBackend.swift in Sources */ = {isa = PBXBuildFile; fileRef = E422A903F5E57FD69DC5E3C8 /* GoogleDriveFileProviderBackend.swift */; }; + B2ED010E0FF4AB7E2027A193 /* UpdateService.swift in Sources */ = {isa = PBXBuildFile; fileRef = B77D562FE95A45B3698C508E /* UpdateService.swift */; }; B4760D12F58B6D1587D76307 /* SMBConnectionForm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 541AD4606527357A4D40B06D /* SMBConnectionForm.swift */; }; B68BC3AB2284F688126246E4 /* ProviderID.swift in Sources */ = {isa = PBXBuildFile; fileRef = F42E2BCD8B94D811E984DB95 /* ProviderID.swift */; }; B8F4B124D540A3A3D8E6DFF9 /* ConnectionVerificationState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0844F4C1A173CF08A59CDF1C /* ConnectionVerificationState.swift */; }; @@ -137,6 +141,7 @@ DFA9E49355EFF4AD39AC7154 /* SMBConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 352FB7DF306047439F9945A6 /* SMBConfiguration.swift */; }; DFE9AEFF0FC1B128159AAE28 /* SettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94F147F1D26C596753CE1D9F /* SettingsViewModel.swift */; }; E043E7CFB41797032230209E /* SFTPFileProviderBackend.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C88B0957DED4BEAFF5C645C /* SFTPFileProviderBackend.swift */; }; + E086453CE0F6AD0040C54450 /* UpdateSectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8379200509ED114FC607FC2 /* UpdateSectionView.swift */; }; E1039C9945FAB5E4C434E928 /* ConnectionPreflightService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DE4781D4AD279629A81328E /* ConnectionPreflightService.swift */; }; E206F09ED8F87B274BA7D463 /* RcloneBinaryLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DC0CF94DA57D4CE411AA764 /* RcloneBinaryLocator.swift */; }; E3C1C6F120E443C4DF0288F4 /* ConnectionTestSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF1B1FDACE50287887666C43 /* ConnectionTestSection.swift */; }; @@ -249,6 +254,8 @@ B155EDD0651910A0FB34365A /* MenuBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarView.swift; sourceTree = ""; }; B16E4C199191E32BDAC02A03 /* AppLifecycleDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLifecycleDelegate.swift; sourceTree = ""; }; B170FCC8467337B42EB06234 /* CloudProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloudProvider.swift; sourceTree = ""; }; + B77D562FE95A45B3698C508E /* UpdateService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateService.swift; sourceTree = ""; }; + B8379200509ED114FC607FC2 /* UpdateSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateSectionView.swift; sourceTree = ""; }; BD287CCB1D246EDF08BA679B /* GoogleDriveOAuthService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleDriveOAuthService.swift; sourceTree = ""; }; BE69F5E28BFE906B8D923AEA /* WebDAVConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebDAVConfiguration.swift; sourceTree = ""; }; C41930E6164FF50FC269922C /* GoogleCloudHealthDiagnostic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleCloudHealthDiagnostic.swift; sourceTree = ""; }; @@ -276,6 +283,7 @@ EF1B1FDACE50287887666C43 /* ConnectionTestSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionTestSection.swift; sourceTree = ""; }; F0E4F7A2121757919668EF2A /* FileProviderDomainStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileProviderDomainStore.swift; sourceTree = ""; }; F42E2BCD8B94D811E984DB95 /* ProviderID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProviderID.swift; sourceTree = ""; }; + F87CE2CAD7AA678E56D78CA8 /* UpdateWorkflowManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateWorkflowManager.swift; sourceTree = ""; }; FA26B8E29653BA18752651DA /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -328,6 +336,8 @@ 26BAE57AFC786C4702B31C50 /* SSHConfigParser.swift */, E9EE964AA60F26C21316EE56 /* SSHKeyDiscoveryService.swift */, E2C2726BB361981A5C767923 /* SSHTunnelConfiguration.swift */, + B77D562FE95A45B3698C508E /* UpdateService.swift */, + F87CE2CAD7AA678E56D78CA8 /* UpdateWorkflowManager.swift */, ); path = Services; sourceTree = ""; @@ -361,6 +371,7 @@ isa = PBXGroup; children = ( 2BF0E329C2FC0395C80D619C /* SettingsView.swift */, + B8379200509ED114FC607FC2 /* UpdateSectionView.swift */, ); path = Settings; sourceTree = ""; @@ -824,6 +835,9 @@ DFE9AEFF0FC1B128159AAE28 /* SettingsViewModel.swift in Sources */, 2D5D86EAEB2B2E0B4F559347 /* ThroughputWidget.swift in Sources */, 61BA0F4EC7648FEC62177215 /* TransferStats.swift in Sources */, + E086453CE0F6AD0040C54450 /* UpdateSectionView.swift in Sources */, + 5F772BF7C21C7B53E4360FEA /* UpdateService.swift in Sources */, + 95E08BD3518A780A3CD4B418 /* UpdateWorkflowManager.swift in Sources */, DB99A6A06F89E1394AD73F52 /* WebDAVConfiguration.swift in Sources */, EE344D71C195BB644500204B /* WebDAVConnectionForm.swift in Sources */, CE8AF3A208E7280975727D26 /* WebDAVFileProviderBackend.swift in Sources */, @@ -893,6 +907,8 @@ 954D94C53F19EF8082A293A4 /* SSHTunnelConfiguration.swift in Sources */, ADDC8A3AC62EEE9F1897AF10 /* SettingsViewModel.swift in Sources */, FDCCA1AEF0E48710B8245B76 /* TransferStats.swift in Sources */, + B2ED010E0FF4AB7E2027A193 /* UpdateService.swift in Sources */, + 77671E8C5C13E0CFCDD54D50 /* UpdateWorkflowManager.swift in Sources */, 56735BAC481CA1DF103F39A8 /* WebDAVConfiguration.swift in Sources */, 2FD1CFDA25C1A19D32385184 /* WebDAVFileProviderBackend.swift in Sources */, ); diff --git a/Tests/Services/UpdateServiceTests.swift b/Tests/Services/UpdateServiceTests.swift new file mode 100644 index 0000000..261e82b --- /dev/null +++ b/Tests/Services/UpdateServiceTests.swift @@ -0,0 +1,39 @@ +import XCTest +@testable import FreeMount + +final class UpdateServiceTests: XCTestCase { + func testSemanticVersionComparison() { + XCTAssertTrue(UpdateService.isVersion("v1.0.1", newerThan: "1.0.0")) + XCTAssertTrue(UpdateService.isVersion("1.1.0", newerThan: "1.0.9")) + XCTAssertTrue(UpdateService.isVersion("v2.0.0", newerThan: "v1.9.9")) + XCTAssertTrue(UpdateService.isVersion("1.0.0.1", newerThan: "1.0.0")) + + XCTAssertFalse(UpdateService.isVersion("1.0.0", newerThan: "1.0.0")) + XCTAssertFalse(UpdateService.isVersion("v1.0.0", newerThan: "1.0.0")) + XCTAssertFalse(UpdateService.isVersion("0.9.9", newerThan: "1.0.0")) + XCTAssertFalse(UpdateService.isVersion("1.0.0", newerThan: "1.0.1")) + } + + func testDecodeReleaseInfo() throws { + let json = """ + { + "tag_name": "v1.2.3", + "name": "FreeMount v1.2.3", + "body": "Fixed WebDAV reconnection.", + "html_url": "https://github.com/ChornyiDev/FreeMount/releases/tag/v1.2.3", + "published_at": "2026-10-31T12:00:00Z" + } + """.data(using: .utf8)! + + let decoder = JSONDecoder() + decoder.dateDecodingStrategy = .iso8601 + let release = try decoder.decode(GitHubReleaseInfo.self, from: json) + + XCTAssertEqual(release.tagName, "v1.2.3") + XCTAssertEqual(release.name, "FreeMount v1.2.3") + XCTAssertEqual(release.body, "Fixed WebDAV reconnection.") + XCTAssertEqual(release.htmlUrl?.absoluteString, "https://github.com/ChornyiDev/FreeMount/releases/tag/v1.2.3") + XCTAssertNotNil(release.publishedAt) + } +} + diff --git a/scripts/install-from-source.sh b/scripts/install-from-source.sh index c0ce212..ea8c031 100755 --- a/scripts/install-from-source.sh +++ b/scripts/install-from-source.sh @@ -88,6 +88,9 @@ xcodebuild -project FreeMount.xcodeproj -scheme FreeMount \ APP="build/install-dd/Build/Products/Release/FM.app" codesign --verify --deep --strict "$APP" || { print -u2 "Built bundle failed signature verification."; exit 1; } +# Record repository directory in user defaults so the app knows where to pull updates from +defaults write com.freemount.app FreeMountSourceRepositoryPath "$PWD" + pkill -x FM 2>/dev/null || true if [[ -d /Applications/FreeMount.app ]]; then rm -rf /Applications/FreeMount.app; fi cp -R "$APP" /Applications/FreeMount.app