Sparkle updates !236
12 files changed, +218 −30
Layout: unified · split
Package.resolved +10 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | { |
| 2 | "originHash" : "99f611db4aa216eecc3254d58a7ad6ee060533c7f899b1a0d0f72c21a75f90a9", | |
| 2 | "originHash" : "13a9fcac60cd27fea1022731e52b785749d4a9dfb56c2e629b61c25a99e5464d", | |
| 3 | 3 | "pins" : [ |
| 4 | 4 | { |
| 5 | 5 | "identity" : "grdb.swift", |
| @@ -10,6 +10,15 @@ | ||
| 10 | 10 | "version" : "7.11.1" |
| 11 | 11 | } |
| 12 | 12 | }, |
| 13 | { | |
| 14 | "identity" : "sparkle", | |
| 15 | "kind" : "remoteSourceControl", | |
| 16 | "location" : "https://github.com/sparkle-project/Sparkle", | |
| 17 | "state" : { | |
| 18 | "revision" : "eef1a539a373c1f1a320624b1130fc5de7b2e100", | |
| 19 | "version" : "2.10.0" | |
| 20 | } | |
| 21 | }, | |
| 13 | 22 | { |
| 14 | 23 | "identity" : "swift-tree-sitter", |
| 15 | 24 | "kind" : "remoteSourceControl", |
Package.swift +2 −1
| @@ -25,6 +25,7 @@ let package = Package( | ||
| 25 | 25 | ], |
| 26 | 26 | dependencies: [ |
| 27 | 27 | .package(url: "https://github.com/groue/GRDB.swift", from: "7.11.1"), |
| 28 | .package(url: "https://github.com/sparkle-project/Sparkle", from: "2.7.0"), | |
| 28 | 29 | .package(url: "https://github.com/tree-sitter/swift-tree-sitter", from: "0.25.0"), |
| 29 | 30 | .package(url: "https://github.com/tree-sitter/tree-sitter-bash", exact: "0.25.1"), |
| 30 | 31 | .package(url: "https://github.com/tree-sitter/tree-sitter-c", exact: "0.24.2"), |
| @@ -82,7 +83,7 @@ let package = Package( | ||
| 82 | 83 | ), |
| 83 | 84 | .executableTarget(name: "OrgstarSpike", dependencies: ["OrgEditorAppKit"]), |
| 84 | 85 | .target(name: "OrgApp", dependencies: ["OrgWorkspace", "OrgDocument", "OrgPresentation"]), |
| 85 | .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgEditorAppKit", "OrgHighlight"]), | |
| 86 | .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]), | |
| 86 | 87 | // The iOS app, bundled by scripts/build-ios-app.sh. |
| 87 | 88 | .executableTarget(name: "OrgstarMobile", dependencies: ["OrgApp", "OrgHighlight"]), |
| 88 | 89 | // App extensions, bundled into orgstar.app by scripts/build-app.sh. |
Sources/Orgstar/OrgstarApp.swift +15 −1
| @@ -162,9 +162,11 @@ struct PromptRequest: Identifiable { | ||
| 162 | 162 | final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate { |
| 163 | 163 | var session: DocumentSession? |
| 164 | 164 | var commands: AppCommands? |
| 165 | let updates = Updates() | |
| 165 | 166 | |
| 166 | 167 | func applicationDidFinishLaunching(_ notification: Notification) { |
| 167 | 168 | if SystemReminderCenter.isAvailable { UNUserNotificationCenter.current().delegate = self } |
| 169 | updates.start() | |
| 168 | 170 | } |
| 169 | 171 | |
| 170 | 172 | /// `:session` interpreters end with the app. |
| @@ -462,9 +464,12 @@ struct OrgstarApp: App { | ||
| 462 | 464 | Button("Edit Config File") { commands.jump(path: UserConfig.configFile.path, offset: 0) } |
| 463 | 465 | .keyboardShortcut(",", modifiers: [.command, .option]) |
| 464 | 466 | } |
| 467 | CommandGroup(after: .appInfo) { | |
| 468 | CheckForUpdatesItem(updates: delegate.updates) | |
| 469 | } | |
| 465 | 470 | } |
| 466 | 471 | Settings { |
| 467 | SettingsView(commands: commands, workspace: try? workspace.get()) | |
| 472 | SettingsView(commands: commands, workspace: try? workspace.get(), updates: delegate.updates) | |
| 468 | 473 | } |
| 469 | 474 | } |
| 470 | 475 | } |
| @@ -537,6 +542,7 @@ struct AgendaMenuItem: View { | ||
| 537 | 542 | struct SettingsView: View { |
| 538 | 543 | let commands: AppCommands |
| 539 | 544 | let workspace: WorkspaceModel? |
| 545 | let updates: Updates | |
| 540 | 546 | @State private var importing = false |
| 541 | 547 | @Environment(\.openWindow) private var openWindow |
| 542 | 548 | @AppStorage("saveMode") private var saveMode = SaveMode.automatic |
| @@ -612,6 +618,14 @@ struct SettingsView: View { | ||
| 612 | 618 | Text("Every setting here is also in \(UserConfig.configFile.path), which you can edit, share or keep with your dotfiles. Changes in either place show up in the other.") |
| 613 | 619 | .settingsFooter() |
| 614 | 620 | } |
| 621 | if updates.canCheck { | |
| 622 | Section { | |
| 623 | Toggle("Check for updates automatically", isOn: Binding(get: { updates.automatically }, set: { updates.automatically = $0 })) | |
| 624 | } footer: { | |
| 625 | Text("Once a day, from the app's own feed. orgstar ▸ Check for Updates… checks now.") | |
| 626 | .settingsFooter() | |
| 627 | } | |
| 628 | } | |
| 615 | 629 | Section { |
| 616 | 630 | Picker("Save files", selection: $saveMode) { |
| 617 | 631 | Text("Automatically, when typing stops").tag(SaveMode.automatic) |
Sources/Orgstar/Updates.swift added +42
| @@ -0,0 +1,42 @@ | ||
| 1 | import Combine | |
| 2 | import Sparkle | |
| 3 | import SwiftUI | |
| 4 | ||
| 5 | /// Sparkle, for the signed builds: the Info.plist names the appcast and the key the DMGs are | |
| 6 | /// signed with. A dev build has neither, so the updater doesn't start and the menu item stays | |
| 7 | /// disabled. Whether to check automatically is Sparkle's own setting, asked once on the | |
| 8 | /// second launch. | |
| 9 | @MainActor | |
| 10 | @Observable | |
| 11 | final class Updates { | |
| 12 | private(set) var canCheck = false | |
| 13 | @ObservationIgnored private var controller: SPUStandardUpdaterController? | |
| 14 | @ObservationIgnored private var observation: AnyCancellable? | |
| 15 | ||
| 16 | func start() { | |
| 17 | guard controller == nil, Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") != nil else { return } | |
| 18 | let controller = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil) | |
| 19 | self.controller = controller | |
| 20 | observation = controller.updater.publisher(for: \.canCheckForUpdates).sink { [weak self] can in | |
| 21 | MainActor.assumeIsolated { self?.canCheck = can } | |
| 22 | } | |
| 23 | } | |
| 24 | ||
| 25 | func check() { | |
| 26 | controller?.updater.checkForUpdates() | |
| 27 | } | |
| 28 | ||
| 29 | var automatically: Bool { | |
| 30 | get { controller?.updater.automaticallyChecksForUpdates ?? false } | |
| 31 | set { controller?.updater.automaticallyChecksForUpdates = newValue } | |
| 32 | } | |
| 33 | } | |
| 34 | ||
| 35 | struct CheckForUpdatesItem: View { | |
| 36 | let updates: Updates | |
| 37 | ||
| 38 | var body: some View { | |
| 39 | Button("Check for Updates…") { updates.check() } | |
| 40 | .disabled(!updates.canCheck) | |
| 41 | } | |
| 42 | } | |
docs/manual/appcast.xml added +7
| @@ -0,0 +1,7 @@ | ||
| 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"> | |
| 3 | <channel> | |
| 4 | <title>orgstar</title> | |
| 5 | <link>https://gitbay.org/krz/orgstar</link> | |
| 6 | </channel> | |
| 7 | </rss> | |
docs/manual/install.org +5 −2
| @@ -67,8 +67,11 @@ See [[file:guide/14-ios.org][iPhone and iPad]] for what it does. | ||
| 67 | 67 | |
| 68 | 68 | * Updating |
| 69 | 69 | |
| 70 | orgstar doesn't update itself. With Homebrew, run =brew upgrade --cask orgstar=; otherwise | |
| 71 | download the new DMG and replace the app. From source, pull and build again: | |
| 70 | orgstar checks for a new release once a day, after asking on its second launch whether it | |
| 71 | may; orgstar ▸ Check for Updates… checks now, and Settings ▸ General has the switch. An update | |
| 72 | downloads, is checked against the key the releases are signed with, and installs when you | |
| 73 | agree. With Homebrew, =brew upgrade --cask orgstar= works too; the cask leaves updating to the | |
| 74 | app otherwise. From source, pull and build again (a build without a Developer ID never checks): | |
| 72 | 75 | |
| 73 | 76 | #+BEGIN_SRC sh |
| 74 | 77 | git pull |
docs/plans/2026-10-10-sparkle-updates.md +28 −21
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | - Modify: `Package.swift` (dependencies; `Orgstar` target) |
| 44 | 44 | - Modify: `scripts/build-app.sh` |
| 45 | 45 | |
| 46 | - [ ] Add the dependency and the product to the app target: | |
| 46 | - [x] Add the dependency and the product to the app target: | |
| 47 | 47 | |
| 48 | 48 | ```swift |
| 49 | 49 | .package(url: "https://github.com/sparkle-project/Sparkle", from: "2.7.0"), |
| @@ -51,7 +51,7 @@ | ||
| 51 | 51 | .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]), |
| 52 | 52 | ``` |
| 53 | 53 | |
| 54 | - [ ] In `build-app.sh`, after copying the binary: copy the framework from the SwiftPM artifact and give the executable an rpath to it. | |
| 54 | - [x] In `build-app.sh`, after copying the binary: copy the framework from the SwiftPM artifact and give the executable an rpath to it. | |
| 55 | 55 | |
| 56 | 56 | ```sh |
| 57 | 57 | sparkle="$(find .build/artifacts -path '*Sparkle.xcframework/macos-*/Sparkle.framework' -maxdepth 6 | head -1)" |
| @@ -61,7 +61,7 @@ ditto "$sparkle" "$app/Contents/Frameworks/Sparkle.framework" | ||
| 61 | 61 | install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar" |
| 62 | 62 | ``` |
| 63 | 63 | |
| 64 | - [ ] Sign Sparkle's inner pieces before the app, with the same identity and flags (Sparkle's documented order), inside the final signing block: | |
| 64 | - [x] Sign Sparkle's inner pieces before the app, with the same identity and flags (Sparkle's documented order), inside the final signing block: | |
| 65 | 65 | |
| 66 | 66 | ```sh |
| 67 | 67 | fw="$app/Contents/Frameworks/Sparkle.framework/Versions/B" |
| @@ -70,7 +70,7 @@ for item in "$fw/XPCServices/Installer.xpc" "$fw/XPCServices/Downloader.xpc" "$f | ||
| 70 | 70 | done |
| 71 | 71 | ``` |
| 72 | 72 | |
| 73 | - [ ] Add `SUFeedURL` and `SUPublicEDKey` to the generated Info.plist only when `sign` is not `-`: | |
| 73 | - [x] Add `SUFeedURL` and `SUPublicEDKey` to the generated Info.plist only when `sign` is not `-`: | |
| 74 | 74 | |
| 75 | 75 | ```sh |
| 76 | 76 | if [ "$sign" != "-" ]; then |
| @@ -82,8 +82,8 @@ fi | ||
| 82 | 82 | |
| 83 | 83 | and `${feed_keys}` in the plist heredoc after `LSMinimumSystemVersion`. The public key is pasted into `scripts/release-mac.sh` as a default for `ORGSTAR_ED_PUBLIC_KEY` once Task 3 generates it. |
| 84 | 84 | |
| 85 | - [ ] Verify: `sh scripts/build-app.sh`, then `otool -l .build/app/orgstar.app/Contents/MacOS/Orgstar | grep -A2 LC_RPATH` shows the Frameworks rpath, `open .build/app/orgstar.app` launches, and `codesign --verify --strict --deep .build/app/orgstar.app` passes. | |
| 86 | - [ ] Commit "Link Sparkle and bundle its framework". | |
| 85 | - [x] Verify: `sh scripts/build-app.sh`, then `otool -l .build/app/orgstar.app/Contents/MacOS/Orgstar | grep -A2 LC_RPATH` shows the Frameworks rpath, `open .build/app/orgstar.app` launches, and `codesign --verify --strict --deep .build/app/orgstar.app` passes. | |
| 86 | - [x] Commit "Link Sparkle and bundle its framework". | |
| 87 | 87 | |
| 88 | 88 | ### Task 2: Check for Updates… and the setting |
| 89 | 89 | |
| @@ -91,7 +91,7 @@ and `${feed_keys}` in the plist heredoc after `LSMinimumSystemVersion`. The publ | ||
| 91 | 91 | - Modify: `Sources/Orgstar/OrgstarApp.swift` (`AppDelegate` at line 151; `.commands`) |
| 92 | 92 | - Modify: `Sources/Orgstar/OrgstarApp.swift` (`SettingsView`, the General tab at line 551) |
| 93 | 93 | |
| 94 | - [ ] In the app delegate, one controller for the process: | |
| 94 | - [x] In the app delegate, one controller for the process: | |
| 95 | 95 | |
| 96 | 96 | ```swift |
| 97 | 97 | import Sparkle |
| @@ -100,7 +100,7 @@ let updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegat | ||
| 100 | 100 | |
| 101 | 101 | Without a feed URL (dev builds) the updater logs that it can't start and `canCheckForUpdates` stays false; that is the intended dev behaviour. |
| 102 | 102 | |
| 103 | - [ ] Menu item after About, following Sparkle's SwiftUI sample: | |
| 103 | - [x] Menu item after About, following Sparkle's SwiftUI sample: | |
| 104 | 104 | |
| 105 | 105 | ```swift |
| 106 | 106 | CommandGroup(after: .appInfo) { |
| @@ -111,9 +111,9 @@ CommandGroup(after: .appInfo) { | ||
| 111 | 111 | |
| 112 | 112 | `canCheckForUpdates` is KVO-observable; wrap the updater in a small `@Observable` holder that observes it, so the button enables once the updater starts. |
| 113 | 113 | |
| 114 | - [ ] Settings ▸ General: a toggle bound to `updater.automaticallyChecksForUpdates`, shown only when `canCheckForUpdates` is true, labelled "Check for updates automatically". | |
| 115 | - [ ] Test by hand: a dev build shows the item disabled and no toggle; a `ORGSTAR_SIGN=<Developer ID>` build with a local feed (Task 4) shows both. | |
| 116 | - [ ] Commit "Check for Updates… and automatic checks". | |
| 114 | - [x] Settings ▸ General: a toggle bound to `updater.automaticallyChecksForUpdates`, shown only when `canCheckForUpdates` is true, labelled "Check for updates automatically". | |
| 115 | - [x] Test by hand: a dev build shows the item disabled and no toggle; a `ORGSTAR_SIGN=<Developer ID>` build with a local feed (Task 4) shows both. | |
| 116 | - [x] Commit "Check for Updates… and automatic checks". | |
| 117 | 117 | |
| 118 | 118 | ### Task 3: Keys and the appcast file |
| 119 | 119 | |
| @@ -122,8 +122,8 @@ CommandGroup(after: .appInfo) { | ||
| 122 | 122 | - Create: `scripts/appcast-add.sh` |
| 123 | 123 | - Modify: `docs/manual/orgo.toml` only if orgo needs the file listed to copy it (check with `scripts/publish-docs.sh --dry-run` and `ls` of the built site; `favicon.svg` and `style.css` are copied today, so it should not) |
| 124 | 124 | |
| 125 | - [ ] Generate the key pair once on the release Mac: `"$(find .build/artifacts -name generate_keys -type f | head -1)"`. The private key goes to the login keychain; paste the printed public key as the `ORGSTAR_ED_PUBLIC_KEY` default in `release-mac.sh`. | |
| 126 | - [ ] The empty appcast: | |
| 125 | - [x] Generate the key pair once on the release Mac (done 2026-10-11; the public key is `release-mac.sh`'s default): `"$(find .build/artifacts -name generate_keys -type f | head -1)"`. The private key goes to the login keychain; paste the printed public key as the `ORGSTAR_ED_PUBLIC_KEY` default in `release-mac.sh`. | |
| 126 | - [x] The empty appcast: | |
| 127 | 127 | |
| 128 | 128 | ```xml |
| 129 | 129 | <?xml version="1.0" encoding="utf-8"?> |
| @@ -135,7 +135,7 @@ CommandGroup(after: .appInfo) { | ||
| 135 | 135 | </rss> |
| 136 | 136 | ``` |
| 137 | 137 | |
| 138 | - [ ] `scripts/appcast-add.sh <appcast> <version> <build> <dmg> <notes-file>`: runs `sign_update "$dmg"` (found under `.build/artifacts` like `generate_keys`), which prints `sparkle:edSignature="…" length="…"`, and inserts after `<link>…</link>` in the channel: | |
| 138 | - [x] `scripts/appcast-add.sh <appcast> <version> <build> <dmg> <notes-file>`: runs `sign_update "$dmg"` (found under `.build/artifacts` like `generate_keys`), which prints `sparkle:edSignature="…" length="…"`, and inserts after `<link>…</link>` in the channel: | |
| 139 | 139 | |
| 140 | 140 | ```xml |
| 141 | 141 | <item> |
| @@ -152,8 +152,8 @@ CommandGroup(after: .appInfo) { | ||
| 152 | 152 | |
| 153 | 153 | Insertion is a `sed`/`awk` on the first `</link>` after `<channel>`; the script refuses a version already present (`grep -q "<sparkle:shortVersionString>$version<"`) and ends with `xmllint --noout "$appcast"`. |
| 154 | 154 | |
| 155 | - [ ] Verify with a throwaway copy: `scripts/appcast-add.sh /tmp/a.xml 0.2.0 365 .build/release/orgstar-0.2.0.dmg notes.txt` twice; the second run exits non-zero naming the version. | |
| 156 | - [ ] Commit "Appcast file and appcast-add.sh". | |
| 155 | - [x] Verify with a throwaway copy: `scripts/appcast-add.sh /tmp/a.xml 0.2.0 365 .build/release/orgstar-0.2.0.dmg notes.txt` twice; the second run exits non-zero naming the version. | |
| 156 | - [x] Commit "Appcast file and appcast-add.sh". | |
| 157 | 157 | |
| 158 | 158 | ### Task 4: Release script and cask |
| 159 | 159 | |
| @@ -161,7 +161,7 @@ Insertion is a `sed`/`awk` on the first `</link>` after `<channel>`; the script | ||
| 161 | 161 | - Modify: `scripts/release-mac.sh` |
| 162 | 162 | - Modify: `packaging/orgstar.rb` |
| 163 | 163 | |
| 164 | - [ ] After `gitbay release asset add` and before the tap section, add the appcast entry through a merge request, mirroring the tap block: | |
| 164 | - [x] After `gitbay release asset add` and before the tap section, add the appcast entry through a merge request, mirroring the tap block: | |
| 165 | 165 | |
| 166 | 166 | ```sh |
| 167 | 167 | notes="Universal (Apple silicon and Intel), macOS 26 or later. Notarized." |
| @@ -180,7 +180,14 @@ sh scripts/publish-docs.sh | ||
| 180 | 180 | |
| 181 | 181 | `$notes` replaces the literal string already passed to `gitbay release create`. With `ORGSTAR_PUBLISH=0` the script runs `appcast-add.sh` on a copy under `$out` and prints the entry instead, so a dry run shows the signature. |
| 182 | 182 | |
| 183 | - [ ] Cask: add `auto_updates true` after `desc`, so `brew upgrade` leaves updating to the app. | |
| 184 | - [ ] End-to-end check before the first real release: build with a Developer ID, point a running copy at a local appcast with `defaults write sh.krz.orgstar SUFeedURL file:///tmp/a.xml` (Sparkle reads the feed from user defaults ahead of Info.plist), Check for Updates… offers the entry and installs the DMG; then `defaults delete sh.krz.orgstar SUFeedURL`. | |
| 185 | - [ ] Manual: `docs/manual/guide/01-files-and-folders.org` or `install.org` gets a paragraph on updates (menu item, the setting, that the cask has `auto_updates`). | |
| 186 | - [ ] Commit "Release script writes the appcast; cask auto_updates". | |
| 183 | - [x] Cask: add `auto_updates true` after `desc`, so `brew upgrade` leaves updating to the app. | |
| 184 | - [ ] End-to-end check before the first real release (needs a Developer ID build and the key): build with a Developer ID, point a running copy at a local appcast with `defaults write sh.krz.orgstar SUFeedURL file:///tmp/a.xml` (Sparkle reads the feed from user defaults ahead of Info.plist), Check for Updates… offers the entry and installs the DMG; then `defaults delete sh.krz.orgstar SUFeedURL`. | |
| 185 | - [x] Manual: `docs/manual/guide/01-files-and-folders.org` or `install.org` gets a paragraph on updates (menu item, the setting, that the cask has `auto_updates`). | |
| 186 | - [x] Commit "Release script writes the appcast; cask auto_updates". | |
| 187 | ||
| 188 | ## As built | |
| 189 | ||
| 190 | - Sparkle 2.10 from its SwiftPM package. `scripts/build-app.sh` copies the framework into `Contents/Frameworks`, adds the rpath, and for signed builds writes `SUFeedURL` and `SUPublicEDKey` (from `ORGSTAR_ED_PUBLIC_KEY`) into the Info.plist; a dev build has neither, so `Updates.start()` doesn't start the updater and Check for Updates… stays disabled. | |
| 191 | - `Sources/Orgstar/Updates.swift` holds the `SPUStandardUpdaterController`, `canCheck` through Sparkle's KVO publisher, and the automatic-checks setting, shown in Settings ▸ General only when the updater runs. | |
| 192 | - `scripts/appcast-add.sh` signs the DMG with `sign_update` and prepends the item; `SIGN_UPDATE` names another signer for a dry run. `scripts/release-mac.sh` runs it on a copy with `ORGSTAR_PUBLISH=0`, and for real after the DMG upload, through a merge request, then publishes the manual, which carries `docs/manual/appcast.xml`. | |
| 193 | - Checked: the dev bundle launches with the framework and passes `codesign --verify --strict --deep`; the appcast script with a stub signer, twice (the second run refuses the version); `release-mac.sh` parses. With the key generated: a Developer ID build carries `SUFeedURL` and `SUPublicEDKey`, verifies strictly with Sparkle signed inside it, and `sign_update` signs a DMG from the keychain, `--verify` accepts the signature, and `appcast-add.sh` writes the real entry. Not checked: the update dialog itself, which needs a second build to offer. | |
ios/Orgstar.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +10 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | { |
| 2 | "originHash" : "7d490d34f6af67a62b54f98eb646b0c3d836db8f93b6fe4eda66d23de815ac9a", | |
| 2 | "originHash" : "faf3117d61917429ae3562b475b907afbc566de310f2387d647ab52c2d5e8468", | |
| 3 | 3 | "pins" : [ |
| 4 | 4 | { |
| 5 | 5 | "identity" : "grdb.swift", |
| @@ -10,6 +10,15 @@ | ||
| 10 | 10 | "version" : "7.11.1" |
| 11 | 11 | } |
| 12 | 12 | }, |
| 13 | { | |
| 14 | "identity" : "sparkle", | |
| 15 | "kind" : "remoteSourceControl", | |
| 16 | "location" : "https://github.com/sparkle-project/Sparkle", | |
| 17 | "state" : { | |
| 18 | "revision" : "eef1a539a373c1f1a320624b1130fc5de7b2e100", | |
| 19 | "version" : "2.10.0" | |
| 20 | } | |
| 21 | }, | |
| 13 | 22 | { |
| 14 | 23 | "identity" : "swift-tree-sitter", |
| 15 | 24 | "kind" : "remoteSourceControl", |
packaging/orgstar.rb +1
| @@ -9,6 +9,7 @@ cask "orgstar" do | ||
| 9 | 9 | url "https://gitbay.org/krz/orgstar/releases/download/v#{version}/orgstar-#{version}.dmg" |
| 10 | 10 | name "orgstar" |
| 11 | 11 | desc "Native org-mode editor and agenda" |
| 12 | auto_updates true | |
| 12 | 13 | homepage "https://gitbay.org/krz/orgstar" |
| 13 | 14 | |
| 14 | 15 | depends_on macos: :tahoe |
scripts/appcast-add.sh added +40
| @@ -0,0 +1,40 @@ | ||
| 1 | #!/bin/sh | |
| 2 | # Adds a release to the Sparkle appcast, newest first: signs the DMG with the EdDSA key in the | |
| 3 | # keychain (sign_update, from the Sparkle package in .build/artifacts) and writes the item. | |
| 4 | # Usage: scripts/appcast-add.sh <appcast.xml> <version> <build> <dmg> <notes-file> | |
| 5 | set -eu | |
| 6 | ||
| 7 | appcast="${1:?usage: appcast-add.sh <appcast.xml> <version> <build> <dmg> <notes-file>}" | |
| 8 | version="${2:?version}" | |
| 9 | build="${3:?build}" | |
| 10 | dmg="${4:?dmg}" | |
| 11 | notes="${5:?notes-file}" | |
| 12 | cd "$(dirname "$0")/.." | |
| 13 | ||
| 14 | ! grep -q "<sparkle:shortVersionString>$version<" "$appcast" || { echo "$appcast already has $version." >&2; exit 1; } | |
| 15 | # SIGN_UPDATE names another signer, for a dry run without the key. | |
| 16 | sign_update="${SIGN_UPDATE:-$(find .build/artifacts -path '*/Sparkle/bin/sign_update' | head -1)}" | |
| 17 | [ -n "$sign_update" ] || { echo "sign_update not in .build/artifacts; swift build fetches Sparkle." >&2; exit 1; } | |
| 18 | signature="$("$sign_update" "$dmg")" # sparkle:edSignature="..." length="..." | |
| 19 | date="$(LC_ALL=C date -R)" | |
| 20 | name="$(basename "$dmg")" | |
| 21 | ||
| 22 | item="$(mktemp)" | |
| 23 | { | |
| 24 | echo " <item>" | |
| 25 | echo " <title>orgstar $version</title>" | |
| 26 | echo " <link>https://gitbay.org/krz/orgstar/releases/tag/v$version</link>" | |
| 27 | echo " <sparkle:version>$build</sparkle:version>" | |
| 28 | echo " <sparkle:shortVersionString>$version</sparkle:shortVersionString>" | |
| 29 | echo " <sparkle:minimumSystemVersion>26.0</sparkle:minimumSystemVersion>" | |
| 30 | echo " <pubDate>$date</pubDate>" | |
| 31 | echo " <description><![CDATA[$(cat "$notes")]]></description>" | |
| 32 | echo " <enclosure url=\"https://gitbay.org/krz/orgstar/releases/download/v$version/$name\" type=\"application/octet-stream\" $signature/>" | |
| 33 | echo " </item>" | |
| 34 | } > "$item" | |
| 35 | # After the channel's <link>, so the newest release comes first. | |
| 36 | awk -v item="$item" 'BEGIN { done = 0 } { print } /<\/link>/ && !done { while ((getline line < item) > 0) print line; done = 1 }' "$appcast" > "$appcast.new" | |
| 37 | mv "$appcast.new" "$appcast" | |
| 38 | rm -f "$item" | |
| 39 | xmllint --noout "$appcast" | |
| 40 | echo "$appcast: added $version" | |
scripts/build-app.sh +26 −1
| @@ -30,8 +30,25 @@ swift build -c release $arch_flags --product OrgstarSpotlight | ||
| 30 | 30 | binary="$(swift build -c release $arch_flags --show-bin-path)/Orgstar" |
| 31 | 31 | |
| 32 | 32 | rm -rf "$app" |
| 33 | mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" | |
| 33 | mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" "$app/Contents/Frameworks" | |
| 34 | 34 | cp "$binary" "$app/Contents/MacOS/Orgstar" |
| 35 | ||
| 36 | # Sparkle, from its SwiftPM artifact: the framework beside the binary, found through an rpath. | |
| 37 | sparkle="$(find .build/artifacts -path '*Sparkle.xcframework/macos-*/Sparkle.framework' -maxdepth 7 | head -1)" | |
| 38 | [ -n "$sparkle" ] || { echo "Sparkle.framework not in .build/artifacts; swift build fetches it." >&2; exit 1; } | |
| 39 | ditto "$sparkle" "$app/Contents/Frameworks/Sparkle.framework" | |
| 40 | otool -l "$app/Contents/MacOS/Orgstar" | grep -q '@executable_path/../Frameworks' \ | |
| 41 | || install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar" | |
| 42 | ||
| 43 | # Updates: the appcast and its signing key, for signed builds only; a dev build never checks. | |
| 44 | if [ "$sign" != "-" ]; then | |
| 45 | feed_keys=" <key>SUFeedURL</key> | |
| 46 | <string>https://krz.gitbay.site/orgstar/appcast.xml</string> | |
| 47 | <key>SUPublicEDKey</key> | |
| 48 | <string>${ORGSTAR_ED_PUBLIC_KEY:?set ORGSTAR_ED_PUBLIC_KEY to the key generate_keys printed}</string>" | |
| 49 | else | |
| 50 | feed_keys="" | |
| 51 | fi | |
| 35 | 52 | iconset="$(mktemp -d)/AppIcon.iconset" |
| 36 | 53 | swift scripts/make-icon.swift "$iconset" |
| 37 | 54 | iconutil -c icns "$iconset" -o "$app/Contents/Resources/AppIcon.icns" |
| @@ -108,6 +125,7 @@ cat > "$app/Contents/Info.plist" <<EOF | ||
| 108 | 125 | <string>${build}</string> |
| 109 | 126 | <key>LSMinimumSystemVersion</key> |
| 110 | 127 | <string>26.0</string> |
| 128 | ${feed_keys} | |
| 111 | 129 | <key>LSApplicationCategoryType</key> |
| 112 | 130 | <string>public.app-category.productivity</string> |
| 113 | 131 | <key>NSCalendarsFullAccessUsageDescription</key> |
| @@ -188,6 +206,13 @@ appex OrgstarQuickLook com.apple.quicklook.preview PreviewProvider \ | ||
| 188 | 206 | appex OrgstarSpotlight com.apple.spotlight.import ImportExtension \ |
| 189 | 207 | "<key>CSSupportedContentTypes</key><array><string>org.orgmode.org</string></array>" |
| 190 | 208 | |
| 209 | # Sparkle's inner pieces are signed first, as its documentation has it, then the framework. | |
| 210 | fw="$app/Contents/Frameworks/Sparkle.framework/Versions/B" | |
| 211 | for item in "$fw/XPCServices/Installer.xpc" "$fw/XPCServices/Downloader.xpc" "$fw/Autoupdate" "$fw/Updater.app" "$app/Contents/Frameworks/Sparkle.framework"; do | |
| 212 | # shellcheck disable=SC2086 | |
| 213 | codesign --force --sign "$sign" $sign_flags "$item" | |
| 214 | done | |
| 215 | ||
| 191 | 216 | # The hardened runtime needs Calendar access declared for the agenda's events. |
| 192 | 217 | cat > "$work/app.entitlements" <<PLIST |
| 193 | 218 | <?xml version="1.0" encoding="UTF-8"?> |
scripts/release-mac.sh +32 −2
| @@ -6,6 +6,11 @@ | ||
| 6 | 6 | # ORGSTAR_NOTARY notarytool keychain profile (default: orgstar) |
| 7 | 7 | # ORGSTAR_TAP the homebrew-tap checkout (default: ../homebrew-tap) |
| 8 | 8 | # ORGSTAR_PUBLISH 0 builds and notarizes without tagging, uploading or touching the tap |
| 9 | # ORGSTAR_ED_PUBLIC_KEY the Sparkle public key (default: the one whose private half is in the | |
| 10 | # release Mac's login keychain, from generate_keys); passed on to build-app.sh | |
| 11 | # | |
| 12 | # Updates: after the DMG is uploaded, the release goes into docs/manual/appcast.xml through a | |
| 13 | # merge request on main, and the manual is published, which serves the appcast. | |
| 9 | 14 | set -eu |
| 10 | 15 | |
| 11 | 16 | cd "$(dirname "$0")/.." |
| @@ -16,6 +21,9 @@ tap="${ORGSTAR_TAP:-../homebrew-tap}" | ||
| 16 | 21 | publish="${ORGSTAR_PUBLISH:-1}" |
| 17 | 22 | sign="${ORGSTAR_SIGN:-$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: .*\)"/\1/p' | head -1)}" |
| 18 | 23 | [ -n "$sign" ] || { echo "No Developer ID Application identity in the keychain." >&2; exit 1; } |
| 24 | # The Sparkle public key; its private half is in the release Mac's login keychain (generate_keys). | |
| 25 | export ORGSTAR_ED_PUBLIC_KEY="${ORGSTAR_ED_PUBLIC_KEY:-StvsRDaDoGd4S/G66l7XHAcd3KPlpJlu0Gsv9GemsSo=}" | |
| 26 | notes="Universal (Apple silicon and Intel), macOS 26 or later. Notarized." | |
| 19 | 27 | |
| 20 | 28 | if [ "$publish" != 0 ]; then |
| 21 | 29 | [ -z "$(git status --porcelain)" ] || { echo "The working tree has changes." >&2; exit 1; } |
| @@ -44,14 +52,36 @@ xcrun stapler staple "$app" | ||
| 44 | 52 | spctl --assess --type open --context context:primary-signature -v "$dmg" |
| 45 | 53 | sha="$(shasum -a 256 "$dmg" | cut -d' ' -f1)" |
| 46 | 54 | echo "$dmg $sha" |
| 55 | printf '%s\n' "$notes" > "$out/notes.txt" | |
| 47 | 56 | |
| 48 | [ "$publish" != 0 ] || exit 0 | |
| 57 | if [ "$publish" = 0 ]; then | |
| 58 | # The appcast entry on a copy, so a dry run shows the signature. | |
| 59 | cp docs/manual/appcast.xml "$out/appcast.xml" | |
| 60 | sh scripts/appcast-add.sh "$out/appcast.xml" "$version" "$build" "$dmg" "$out/notes.txt" | |
| 61 | exit 0 | |
| 62 | fi | |
| 49 | 63 | |
| 50 | 64 | git tag -s "$tag" -m "orgstar $version" |
| 51 | 65 | git push origin "$tag" |
| 52 | gitbay release create krz/orgstar "$tag" --title "orgstar $version" --notes "Universal (Apple silicon and Intel), macOS 26 or later. Notarized." | |
| 66 | gitbay release create krz/orgstar "$tag" --title "orgstar $version" --notes "$notes" | |
| 53 | 67 | gitbay release asset add krz/orgstar "$tag" "orgstar-$version.dmg" < "$dmg" |
| 54 | 68 | |
| 69 | # The appcast goes in through a merge request, as every change to main does, after the DMG | |
| 70 | # it points at is up; then the manual, which serves it, is published. | |
| 71 | branch="appcast-$version" | |
| 72 | git switch -q -c "$branch" | |
| 73 | sh scripts/appcast-add.sh docs/manual/appcast.xml "$version" "$build" "$dmg" "$out/notes.txt" | |
| 74 | git add docs/manual/appcast.xml | |
| 75 | git commit -q -m "Appcast for $version" | |
| 76 | git push -q -u origin "$branch" | |
| 77 | mr="$(gitbay mr create --source "$branch" --target main --title "Appcast for $version" --body "Sparkle entry for orgstar $version." --json | sed -n 's/.*"number":\([0-9]*\).*/\1/p')" | |
| 78 | gitbay mr merge "$mr" --strategy ff | |
| 79 | git switch -q main | |
| 80 | git pull -q --ff-only | |
| 81 | git branch -d "$branch" | |
| 82 | git push -q origin --delete "$branch" | |
| 83 | sh scripts/publish-docs.sh | |
| 84 | ||
| 55 | 85 | # The cask goes in through a merge request, as every change to the tap's main does. |
| 56 | 86 | branch="orgstar-$version" |
| 57 | 87 | git -C "$tap" switch -q main |