projects

rheaarchived

A grocery receipt scanning application

feat: sparkle 2 auto-updates with stable appcast feed branch

daniel daum committed parent f5efaae commit f6e7423Signed, not verified

SignedGitea couldn't verify the signature.

Showing 8 changed files with 183 additions and 5 deletions.

.gitea/workflows/release.yml +27 −4
@@ -215,10 +215,9 @@ jobs:215215          rm -f "$SPARKLE_KEY_FILE"216216          PUB_DATE=$(date -u +"%a, %d %b %Y %H:%M:%S +0000")217217218          # NOTE: this release-side appcast only lists the current release. Sparkle isn't219          # wired into the app yet (see ticket #45 scope decision), so there's no in-app220          # consumer of update history to preserve; a follow-up ticket that adds Sparkle to221          # the app should also decide how far back the feed needs to accumulate.218          # This release-side appcast only lists the current release — see the219          # "Publish appcast to stable feed branch" step below for why a single-item feed220          # is sufficient and how it's exposed at one stable URL for the app's SUFeedURL.222221          cat > appcast.xml <<XMLEOF223222          <?xml version="1.0" encoding="utf-8"?>224223          <rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle">@@ -243,3 +242,27 @@ jobs:243242            -H "Authorization: token $GITEA_TOKEN" \244243            -F "attachment=@appcast.xml" \245244            "${{ github.server_url }}/api/v1/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.release_id }}/assets?name=appcast.xml"245246      - name: Publish appcast to stable feed branch247        env:248          GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}249        run: |250          # The per-release appcast.xml uploaded above lives at a URL that changes every251          # release; Sparkle's SUFeedURL needs one URL that never changes. Gitea has no252          # GitHub-style "latest release asset" redirect (confirmed: /releases/latest/download/253          # 404s), so instead force-push the same appcast.xml to a dedicated orphan branch and254          # serve it via Gitea's raw-file endpoint, which is stable by construction. Only the255          # current release needs to be advertised — Sparkle just compares the feed's newest256          # sparkle:version against the running app, so a single-item feed with no history is257          # sufficient and the branch is simply overwritten each run.258          cp appcast.xml "$RUNNER_TEMP/appcast.xml"259          git config user.name "gitea-actions"260          git config user.email "actions@git.danieldaum.net"261          SERVER_HOST=$(echo "${{ github.server_url }}" | sed -e 's#^https://##')262          AUTH_URL="https://x-access-token:${GITEA_TOKEN}@${SERVER_HOST}/${{ github.repository }}.git"263          git checkout --orphan appcast-feed264          git rm -rf . > /dev/null 2>&1 || true265          cp "$RUNNER_TEMP/appcast.xml" appcast.xml266          git add appcast.xml267          git commit -m "chore: publish appcast.xml for ${{ steps.version.outputs.tag }}"268          git push "$AUTH_URL" HEAD:appcast-feed --force
CHANGELOG.md +8 −0
@@ -4,6 +4,14 @@ All notable changes to this project are documented here. Format loosely follows44[Keep a Changelog](https://keepachangelog.com/); versioning is pre-1.0, so breaking55changes may land in minor releases.667## [0.2.1] - 2026-07-1089### Added10- Sparkle 2 auto-updates (ticket #27): "Check for Updates…" menu item, with automatic11  background checks after a one-time first-run consent prompt (Sparkle's own). The12  release workflow now also force-pushes each release's `appcast.xml` to a dedicated13  `appcast-feed` branch, giving the app one stable feed URL across releases.14715## [0.2.0] - 2026-07-10816917### Added
CLAUDE.md +29 −1
@@ -13,7 +13,10 @@ source image, confirms it, and exports confirmed records to CSV or Postgres for1313- Bundle identifier: `net.danieldaum.rhea`. Product/app name: `Rhea`.1414- Architecture: MVVM. Views are dumb; state lives in a single `@Observable @MainActor` view model (`ReceiptsViewModel`).1515- No third-party SPM/runtime dependencies — Apple frameworks only (SwiftUI, AppKit, PDFKit, Foundation,16  Observation). XcodeGen is a build-time dev tool installed via Homebrew, not an app dependency.16  Observation), with one deliberate exception: **Sparkle 2** (`sparkle-project/Sparkle`, pinned exact17  version in `project.yml`'s `packages:`), added for in-app auto-updates (ticket #27) since Apple provides18  no first-party update mechanism outside the App Store. XcodeGen is a build-time dev tool installed via19  Homebrew, not an app dependency.1720- File layout: `Rhea/{Models,ViewModels,Views,Services}`, plus `Rhea/Assets.xcassets`.18211922## Build & distribution@@ -57,6 +60,10 @@ source image, confirms it, and exports confirmed records to CSV or Postgres for5760- `Rhea/Services/PersistenceStore.swift` — persistence protocol.5861- `Rhea/Services/CSVExporter.swift`, `CSVStore.swift` — CSV export.5962- `Rhea/Services/PostgresStore.swift`, `PostgresSQLExporter.swift` — Postgres export via `psql` + schema constant.63- `Rhea/Services/UpdaterService.swift` — Sparkle `SPUStandardUpdaterController` wrapper + `UpdaterViewModel`64  for the "Check for Updates…" menu item.65- `Rhea/Info.plist` — partial plist merged into the `GENERATE_INFOPLIST_FILE`-generated one; holds66  `SUFeedURL`/`SUPublicEDKey`, which aren't keys Xcode recognizes as `INFOPLIST_KEY_*` synonyms.6067- `Rhea/Views/` — `ReceiptListView`, `ReceiptDetailView`, `ReceiptEditForm`, `SidebarView`, `SettingsView`, `ResizableSplitView`.6168- `Packaging/AppIcon.png` — 1024px icon master.6269@@ -141,6 +148,22 @@ Only confirmed receipts with extracted data are exported.141148  `ALTER TABLE ... ADD COLUMN IF NOT EXISTS` so older databases upgrade in place. `PostgresSQLExporter`142149  holds the schema constant shown in Settings.143150151## Auto-updates (Sparkle)152- `UpdaterService` wraps `SPUStandardUpdaterController`; `RheaApp` adds a "Check for Updates…" item to the153  app menu (`CommandGroup(after: .appInfo)`) bound to `UpdaterViewModel.canCheckForUpdates`.154- `SUEnableAutomaticChecks` is deliberately not set — Sparkle shows its own one-time consent alert on first155  launch rather than the app silently opting the user into background checks.156- `SUFeedURL`/`SUPublicEDKey` live in `Rhea/Info.plist` (see File map) rather than as `INFOPLIST_KEY_*`157  build settings, since Xcode doesn't recognize those as generated-Info.plist synonyms.158- **Stable feed URL**: each tagged release's `appcast.xml` is uploaded as a release asset (per-release URL,159  changes every tag) *and* force-pushed to a dedicated orphan branch `appcast-feed`160  (`.gitea/workflows/release.yml`, "Publish appcast to stable feed branch" step). `SUFeedURL` points at that161  branch's raw file (`.../raw/branch/appcast-feed/appcast.xml`), which is the one URL that never changes.162  Gitea has no GitHub-style `/releases/latest/download/<asset>` redirect (confirmed 404), which is why this163  exists instead of pointing `SUFeedURL` straight at a release asset.164- The feed is single-item (current release only, no history) — Sparkle only needs the newest165  `sparkle:version` to compare against the running app.166144167## Change log1451681. **Filters & statuses:** top filter is now All / Queued / Processed / Confirmed / Failed; the post-extraction146169   `done` state is labeled blue **"Processed"**, green only after the user confirms.@@ -182,6 +205,11 @@ Only confirmed receipts with extracted data are exported.182205    GROCERY OUTLET and PIEDMONT GROCERY. The baseline dataset/pipeline lives in `receipts_raw/`183206    (extraction spec, per-receipt JSONs, `qc.py`, `assemble.py`, `products_map.csv`) and loads via184207    `db/baseline_full.sql` or `db/load_baseline.sh`; analysis queries in `db/analysis_queries.sql`.20817. **Sparkle 2 auto-updates** (ticket #27, first third-party dependency — see "Stack & build" exception):209    `UpdaterService` + "Check for Updates…" menu item; `SUFeedURL`/`SUPublicEDKey` merged into the generated210    Info.plist via `Rhea/Info.plist`; release workflow force-pushes each release's `appcast.xml` to a211    dedicated `appcast-feed` branch so Sparkle has one stable feed URL (Gitea has no "latest release asset"212    redirect). See "Auto-updates (Sparkle)" above for details.185213186214## Working agreement187215- Keep the build green (`xcodebuild ... build`) after each change; run `xcodegen generate` after editing `project.yml`.
Rhea/Info.plistadded +18 −0
@@ -0,0 +1,18 @@1<?xml version="1.0" encoding="UTF-8"?>2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">3<plist version="1.0">4<dict>5	<!--6	Sparkle 2 update feed. GENERATE_INFOPLIST_FILE merges this partial plist with the7	build-setting-driven keys (INFOPLIST_KEY_*) rather than replacing them — Sparkle's8	SUFeedURL/SUPublicEDKey aren't keys Xcode recognizes as INFOPLIST_KEY_ synonyms, so9	they have to be supplied this way.10	SUEnableAutomaticChecks is deliberately omitted so Sparkle shows its own one-time11	consent alert on first launch instead of silently opting the user in.12	-->13	<key>SUFeedURL</key>14	<string>https://git.danieldaum.net/daniel-daum/rhea/raw/branch/appcast-feed/appcast.xml</string>15	<key>SUPublicEDKey</key>16	<string>1gC9ygjUSyFdMuzMR3lkO8WbrJtZfnKHDlS2SLqh3zU=</string>17</dict>18</plist>
Rhea/RheaApp.swift +15 −0
@@ -7,6 +7,13 @@ struct RheaApp: App {77    @State private var viewModel = RheaApp.makeViewModel()88    @State private var columnVisibility = NavigationSplitViewVisibility.all99    @Environment(\.scenePhase) private var scenePhase10    private let updaterService = UpdaterService()11    @StateObject private var updaterViewModel: UpdaterViewModel1213    init() {14        let service = updaterService15        _updaterViewModel = StateObject(wrappedValue: UpdaterViewModel(updater: service.updater))16    }10171118    var body: some Scene {1219        WindowGroup {@@ -27,6 +34,14 @@ struct RheaApp: App {2734                if phase != .active { viewModel.saveAll() }2835            }2936        }37        .commands {38            CommandGroup(after: .appInfo) {39                Button("Check for Updates…") {40                    updaterService.checkForUpdates()41                }42                .disabled(!updaterViewModel.canCheckForUpdates)43            }44        }3045    }31463247    // MARK: - XCUITest seam
Rhea/Services/UpdaterService.swiftadded +43 −0
@@ -0,0 +1,43 @@1import Sparkle2import SwiftUI34/// Thin wrapper around Sparkle's standard updater controller so `RheaApp` can expose a5/// "Check for Updates…" menu command. Automatic background checks and first-run consent6/// are handled entirely by Sparkle itself (driven by the `SUFeedURL`/`SUPublicEDKey`7/// Info.plist keys) — this type just gives SwiftUI something to bind the menu item to.8@MainActor9final class UpdaterService {10    let updater: SPUUpdater11    private let controller: SPUStandardUpdaterController1213    init() {14        // XCUITest drives the compiled app as a black box and always sets UITEST_VAULT_DIR15        // (see RheaApp's UI-test seam); Sparkle's first-run consent alert is an app-modal16        // sheet that would otherwise block every UI test waiting on the main window's17        // accessibility elements, so the updater is never started under test.18        let isUITest = ProcessInfo.processInfo.environment["UITEST_VAULT_DIR"] != nil19        controller = SPUStandardUpdaterController(20            startingUpdater: !isUITest,21            updaterDelegate: nil,22            userDriverDelegate: nil23        )24        updater = controller.updater25    }2627    func checkForUpdates() {28        controller.checkForUpdates(nil)29    }30}3132/// Mirrors Sparkle's own `CheckForUpdatesViewModel` sample: `canCheckForUpdates` is a33/// KVO-compliant property on `SPUUpdater`, published here so the menu item can disable34/// itself while a check is already in flight.35@MainActor36final class UpdaterViewModel: ObservableObject {37    @Published var canCheckForUpdates = false3839    init(updater: SPUUpdater) {40        updater.publisher(for: \.canCheckForUpdates)41            .assign(to: &$canCheckForUpdates)42    }43}
Tests/RheaTests/SparkleConfigurationTests.swiftadded +33 −0
@@ -0,0 +1,33 @@1import Testing2import Foundation34/// Guards the Sparkle wiring that isn't otherwise exercised by an automated end-to-end update5/// (that's verified manually against the real appcast — see ticket #27): the merged Info.plist6/// keys Sparkle reads at launch, and that the feed points at the stable `appcast-feed` branch7/// rather than a per-release asset URL (which changes every tag and can't serve as `SUFeedURL`).8struct SparkleConfigurationTests {9    private var infoPlist: [String: Any] {10        get throws {11            let thisFile = URL(fileURLWithPath: #filePath)12            let repoRoot = thisFile13                .deletingLastPathComponent() // RheaTests14                .deletingLastPathComponent() // Tests15                .deletingLastPathComponent() // repo root16            let infoPlistURL = repoRoot.appending(path: "Rhea/Info.plist")17            let data = try Data(contentsOf: infoPlistURL)18            let plist = try PropertyListSerialization.propertyList(from: data, format: nil)19            return try #require(plist as? [String: Any])20        }21    }2223    @Test func feedURLPointsAtTheStableAppcastFeedBranchNotAReleaseAsset() throws {24        let feedURL = try #require(infoPlist["SUFeedURL"] as? String)25        #expect(feedURL == "https://git.danieldaum.net/daniel-daum/rhea/raw/branch/appcast-feed/appcast.xml")26        #expect(!feedURL.contains("/releases/download/"))27    }2829    @Test func publicEDKeyIsPresentAndNonEmpty() throws {30        let publicKey = try #require(infoPlist["SUPublicEDKey"] as? String)31        #expect(!publicKey.isEmpty)32    }33}
project.yml +10 −0
@@ -9,6 +9,10 @@ settings:99    MARKETING_VERSION: "1.0"1010    CURRENT_PROJECT_VERSION: "1"1111    SWIFT_VERSION: "5.0"12packages:13  Sparkle:14    url: https://github.com/sparkle-project/Sparkle15    exactVersion: 2.6.41216targets:1317  Rhea:1418    type: application@@ -16,6 +20,8 @@ targets:1620    deploymentTarget: "14.0"1721    sources:1822      - path: Rhea23    dependencies:24      - package: Sparkle1925    settings:2026      base:2127        PRODUCT_NAME: Rhea@@ -27,6 +33,10 @@ targets:2733        INFOPLIST_KEY_CFBundleDisplayName: Rhea2834        INFOPLIST_KEY_LSApplicationCategoryType: public.app-category.productivity2935        INFOPLIST_KEY_NSHumanReadableCopyright: "© 2026 Daniel Daum"36        # Custom Sparkle keys (SUFeedURL, SUPublicEDKey) aren't ones Xcode recognizes as37        # INFOPLIST_KEY_ synonyms, so they come from a merged partial plist instead; see38        # Rhea/Info.plist.39        INFOPLIST_FILE: Rhea/Info.plist3040      configs:3141        Debug:3242          # Ad-hoc "sign to run locally" so local/CI builds work without a team.