Commit df0789ff05

df0789ff05be961a84b57ad14a62d925842ee380

parent: 5892c992e6

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-11 05:06 UTC

Release script writes the appcast; cask auto_updates

Layout: unified · split

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* Updating 68* Updating
69 69
70orgstar doesn't update itself. With Homebrew, run =brew upgrade --cask orgstar=; otherwise 70orgstar checks for a new release once a day, after asking on its second launch whether it
71download the new DMG and replace the app. From source, pull and build again: 71may; orgstar ▸ Check for Updates… checks now, and Settings ▸ General has the switch. An update
72downloads, is checked against the key the releases are signed with, and installs when you
73agree. With Homebrew, =brew upgrade --cask orgstar= works too; the cask leaves updating to the
74app otherwise. From source, pull and build again (a build without a Developer ID never checks):
72 75
73#+BEGIN_SRC sh 76#+BEGIN_SRC sh
74git pull 77git pull
docs/plans/2026-10-10-sparkle-updates.md +28 −21
@@ -43,7 +43,7 @@
43- Modify: `Package.swift` (dependencies; `Orgstar` target) 43- Modify: `Package.swift` (dependencies; `Orgstar` target)
44- Modify: `scripts/build-app.sh` 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```swift 48```swift
49.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.7.0"), 49.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.7.0"),
@@ -51,7 +51,7 @@
51.executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]), 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```sh 56```sh
57sparkle="$(find .build/artifacts -path '*Sparkle.xcframework/macos-*/Sparkle.framework' -maxdepth 6 | head -1)" 57sparkle="$(find .build/artifacts -path '*Sparkle.xcframework/macos-*/Sparkle.framework' -maxdepth 6 | head -1)"
@@ -61,7 +61,7 @@ ditto "$sparkle" "$app/Contents/Frameworks/Sparkle.framework"
61install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar" 61install_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```sh 66```sh
67fw="$app/Contents/Frameworks/Sparkle.framework/Versions/B" 67fw="$app/Contents/Frameworks/Sparkle.framework/Versions/B"
@@ -70,7 +70,7 @@ for item in "$fw/XPCServices/Installer.xpc" "$fw/XPCServices/Downloader.xpc" "$f
70done 70done
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```sh 75```sh
76if [ "$sign" != "-" ]; then 76if [ "$sign" != "-" ]; then
@@ -82,8 +82,8 @@ fi
82 82
83and `${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. 83and `${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. 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- [ ] Commit "Link Sparkle and bundle its framework". 86- [x] Commit "Link Sparkle and bundle its framework".
87 87
88### Task 2: Check for Updates… and the setting 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- Modify: `Sources/Orgstar/OrgstarApp.swift` (`AppDelegate` at line 151; `.commands`) 91- Modify: `Sources/Orgstar/OrgstarApp.swift` (`AppDelegate` at line 151; `.commands`)
92- Modify: `Sources/Orgstar/OrgstarApp.swift` (`SettingsView`, the General tab at line 551) 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```swift 96```swift
97import Sparkle 97import Sparkle
@@ -100,7 +100,7 @@ let updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegat
100 100
101Without a feed URL (dev builds) the updater logs that it can't start and `canCheckForUpdates` stays false; that is the intended dev behaviour. 101Without 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```swift 105```swift
106CommandGroup(after: .appInfo) { 106CommandGroup(after: .appInfo) {
@@ -111,9 +111,9 @@ CommandGroup(after: .appInfo) {
111 111
112`canCheckForUpdates` is KVO-observable; wrap the updater in a small `@Observable` holder that observes it, so the button enables once the updater starts. 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". 114- [x] 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. 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- [ ] Commit "Check for Updates… and automatic checks". 116- [x] Commit "Check for Updates… and automatic checks".
117 117
118### Task 3: Keys and the appcast file 118### Task 3: Keys and the appcast file
119 119
@@ -122,8 +122,8 @@ CommandGroup(after: .appInfo) {
122- Create: `scripts/appcast-add.sh` 122- Create: `scripts/appcast-add.sh`
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) 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`. 125- [ ] Generate the key pair once on the release Mac (not done here; it writes a private key to the login keychain): `"$(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: 126- [x] The empty appcast:
127 127
128```xml 128```xml
129<?xml version="1.0" encoding="utf-8"?> 129<?xml version="1.0" encoding="utf-8"?>
@@ -135,7 +135,7 @@ CommandGroup(after: .appInfo) {
135</rss> 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```xml 140```xml
141 <item> 141 <item>
@@ -152,8 +152,8 @@ CommandGroup(after: .appInfo) {
152 152
153Insertion 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"`. 153Insertion 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. 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- [ ] Commit "Appcast file and appcast-add.sh". 156- [x] Commit "Appcast file and appcast-add.sh".
157 157
158### Task 4: Release script and cask 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- Modify: `scripts/release-mac.sh` 161- Modify: `scripts/release-mac.sh`
162- Modify: `packaging/orgstar.rb` 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```sh 166```sh
167notes="Universal (Apple silicon and Intel), macOS 26 or later. Notarized." 167notes="Universal (Apple silicon and Intel), macOS 26 or later. Notarized."
@@ -180,7 +180,14 @@ sh scripts/publish-docs.sh
180 180
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. 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. 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: 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`. 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- [ ] 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`). 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- [ ] Commit "Release script writes the appcast; cask 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. Not checked: a signed build against a local appcast, which needs the Developer ID and the generated key.
packaging/orgstar.rb +1
@@ -9,6 +9,7 @@ cask "orgstar" do
9 url "https://gitbay.org/krz/orgstar/releases/download/v#{version}/orgstar-#{version}.dmg" 9 url "https://gitbay.org/krz/orgstar/releases/download/v#{version}/orgstar-#{version}.dmg"
10 name "orgstar" 10 name "orgstar"
11 desc "Native org-mode editor and agenda" 11 desc "Native org-mode editor and agenda"
12 auto_updates true
12 homepage "https://gitbay.org/krz/orgstar" 13 homepage "https://gitbay.org/krz/orgstar"
13 14
14 depends_on macos: :tahoe 15 depends_on macos: :tahoe
scripts/release-mac.sh +32 −2
@@ -6,6 +6,11 @@
6# ORGSTAR_NOTARY notarytool keychain profile (default: orgstar) 6# ORGSTAR_NOTARY notarytool keychain profile (default: orgstar)
7# ORGSTAR_TAP the homebrew-tap checkout (default: ../homebrew-tap) 7# ORGSTAR_TAP the homebrew-tap checkout (default: ../homebrew-tap)
8# ORGSTAR_PUBLISH 0 builds and notarizes without tagging, uploading or touching the tap 8# ORGSTAR_PUBLISH 0 builds and notarizes without tagging, uploading or touching the tap
9# ORGSTAR_ED_PUBLIC_KEY the Sparkle public key, as generate_keys printed it (the private key
10# is in the login keychain); passed on to build-app.sh and sign_update
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.
9set -eu 14set -eu
10 15
11cd "$(dirname "$0")/.." 16cd "$(dirname "$0")/.."
@@ -16,6 +21,9 @@ tap="${ORGSTAR_TAP:-../homebrew-tap}"
16publish="${ORGSTAR_PUBLISH:-1}" 21publish="${ORGSTAR_PUBLISH:-1}"
17sign="${ORGSTAR_SIGN:-$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: .*\)"/\1/p' | head -1)}" 22sign="${ORGSTAR_SIGN:-$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: .*\)"/\1/p' | head -1)}"
18[ -n "$sign" ] || { echo "No Developer ID Application identity in the keychain." >&2; exit 1; } 23[ -n "$sign" ] || { echo "No Developer ID Application identity in the keychain." >&2; exit 1; }
24: "${ORGSTAR_ED_PUBLIC_KEY:?set ORGSTAR_ED_PUBLIC_KEY to the key generate_keys printed}"
25export ORGSTAR_ED_PUBLIC_KEY
26notes="Universal (Apple silicon and Intel), macOS 26 or later. Notarized."
19 27
20if [ "$publish" != 0 ]; then 28if [ "$publish" != 0 ]; then
21 [ -z "$(git status --porcelain)" ] || { echo "The working tree has changes." >&2; exit 1; } 29 [ -z "$(git status --porcelain)" ] || { echo "The working tree has changes." >&2; exit 1; }
@@ -44,14 +52,36 @@ xcrun stapler staple "$app"
44spctl --assess --type open --context context:primary-signature -v "$dmg" 52spctl --assess --type open --context context:primary-signature -v "$dmg"
45sha="$(shasum -a 256 "$dmg" | cut -d' ' -f1)" 53sha="$(shasum -a 256 "$dmg" | cut -d' ' -f1)"
46echo "$dmg $sha" 54echo "$dmg $sha"
55printf '%s\n' "$notes" > "$out/notes.txt"
47 56
48[ "$publish" != 0 ] || exit 0 57if [ "$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
62fi
49 63
50git tag -s "$tag" -m "orgstar $version" 64git tag -s "$tag" -m "orgstar $version"
51git push origin "$tag" 65git push origin "$tag"
52gitbay release create krz/orgstar "$tag" --title "orgstar $version" --notes "Universal (Apple silicon and Intel), macOS 26 or later. Notarized." 66gitbay release create krz/orgstar "$tag" --title "orgstar $version" --notes "$notes"
53gitbay release asset add krz/orgstar "$tag" "orgstar-$version.dmg" < "$dmg" 67gitbay 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.
71branch="appcast-$version"
72git switch -q -c "$branch"
73sh scripts/appcast-add.sh docs/manual/appcast.xml "$version" "$build" "$dmg" "$out/notes.txt"
74git add docs/manual/appcast.xml
75git commit -q -m "Appcast for $version"
76git push -q -u origin "$branch"
77mr="$(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')"
78gitbay mr merge "$mr" --strategy ff
79git switch -q main
80git pull -q --ff-only
81git branch -d "$branch"
82git push -q origin --delete "$branch"
83sh scripts/publish-docs.sh
84
55# The cask goes in through a merge request, as every change to the tap's main does. 85# The cask goes in through a merge request, as every change to the tap's main does.
56branch="orgstar-$version" 86branch="orgstar-$version"
57git -C "$tap" switch -q main 87git -C "$tap" switch -q main