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.
6767
6868* Updating
6969
70orgstar doesn't update itself. With Homebrew, run =brew upgrade --cask orgstar=; otherwise
71download the new DMG and replace the app. From source, pull and build again:
70orgstar checks for a new release once a day, after asking on its second launch whether it
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):
7275
7376#+BEGIN_SRC sh
7477git pull
docs/plans/2026-10-10-sparkle-updates.md +28 −21
@@ -43,7 +43,7 @@
4343- Modify: `Package.swift` (dependencies; `Orgstar` target)
4444- Modify: `scripts/build-app.sh`
4545
46- [ ] Add the dependency and the product to the app target:
46- [x] Add the dependency and the product to the app target:
4747
4848```swift
4949.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.7.0"),
@@ -51,7 +51,7 @@
5151.executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]),
5252```
5353
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.
5555
5656```sh
5757sparkle="$(find .build/artifacts -path '*Sparkle.xcframework/macos-*/Sparkle.framework' -maxdepth 6 | head -1)"
@@ -61,7 +61,7 @@ ditto "$sparkle" "$app/Contents/Frameworks/Sparkle.framework"
6161install_name_tool -add_rpath @executable_path/../Frameworks "$app/Contents/MacOS/Orgstar"
6262```
6363
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:
6565
6666```sh
6767fw="$app/Contents/Frameworks/Sparkle.framework/Versions/B"
@@ -70,7 +70,7 @@ for item in "$fw/XPCServices/Installer.xpc" "$fw/XPCServices/Downloader.xpc" "$f
7070done
7171```
7272
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 `-`:
7474
7575```sh
7676if [ "$sign" != "-" ]; then
@@ -82,8 +82,8 @@ fi
8282
8383and `${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.
8484
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".
8787
8888### Task 2: Check for Updates… and the setting
8989
@@ -91,7 +91,7 @@ and `${feed_keys}` in the plist heredoc after `LSMinimumSystemVersion`. The publ
9191- Modify: `Sources/Orgstar/OrgstarApp.swift` (`AppDelegate` at line 151; `.commands`)
9292- Modify: `Sources/Orgstar/OrgstarApp.swift` (`SettingsView`, the General tab at line 551)
9393
94- [ ] In the app delegate, one controller for the process:
94- [x] In the app delegate, one controller for the process:
9595
9696```swift
9797import Sparkle
@@ -100,7 +100,7 @@ let updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegat
100100
101101Without a feed URL (dev builds) the updater logs that it can't start and `canCheckForUpdates` stays false; that is the intended dev behaviour.
102102
103- [ ] Menu item after About, following Sparkle's SwiftUI sample:
103- [x] Menu item after About, following Sparkle's SwiftUI sample:
104104
105105```swift
106106CommandGroup(after: .appInfo) {
@@ -111,9 +111,9 @@ CommandGroup(after: .appInfo) {
111111
112112`canCheckForUpdates` is KVO-observable; wrap the updater in a small `@Observable` holder that observes it, so the button enables once the updater starts.
113113
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".
117117
118118### Task 3: Keys and the appcast file
119119
@@ -122,8 +122,8 @@ CommandGroup(after: .appInfo) {
122122- Create: `scripts/appcast-add.sh`
123123- 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)
124124
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- [ ] 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- [x] The empty appcast:
127127
128128```xml
129129<?xml version="1.0" encoding="utf-8"?>
@@ -135,7 +135,7 @@ CommandGroup(after: .appInfo) {
135135</rss>
136136```
137137
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:
139139
140140```xml
141141 <item>
@@ -152,8 +152,8 @@ CommandGroup(after: .appInfo) {
152152
153153Insertion 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"`.
154154
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".
157157
158158### Task 4: Release script and cask
159159
@@ -161,7 +161,7 @@ Insertion is a `sed`/`awk` on the first `</link>` after `<channel>`; the script
161161- Modify: `scripts/release-mac.sh`
162162- Modify: `packaging/orgstar.rb`
163163
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:
165165
166166```sh
167167notes="Universal (Apple silicon and Intel), macOS 26 or later. Notarized."
@@ -180,7 +180,14 @@ sh scripts/publish-docs.sh
180180
181181`$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.
182182
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. 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
99 url "https://gitbay.org/krz/orgstar/releases/download/v#{version}/orgstar-#{version}.dmg"
1010 name "orgstar"
1111 desc "Native org-mode editor and agenda"
12 auto_updates true
1213 homepage "https://gitbay.org/krz/orgstar"
1314
1415 depends_on macos: :tahoe
scripts/release-mac.sh +32 −2
@@ -6,6 +6,11 @@
66# ORGSTAR_NOTARY notarytool keychain profile (default: orgstar)
77# ORGSTAR_TAP the homebrew-tap checkout (default: ../homebrew-tap)
88# 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.
914set -eu
1015
1116cd "$(dirname "$0")/.."
@@ -16,6 +21,9 @@ tap="${ORGSTAR_TAP:-../homebrew-tap}"
1621publish="${ORGSTAR_PUBLISH:-1}"
1722sign="${ORGSTAR_SIGN:-$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: .*\)"/\1/p' | head -1)}"
1823[ -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."
1927
2028if [ "$publish" != 0 ]; then
2129 [ -z "$(git status --porcelain)" ] || { echo "The working tree has changes." >&2; exit 1; }
@@ -44,14 +52,36 @@ xcrun stapler staple "$app"
4452spctl --assess --type open --context context:primary-signature -v "$dmg"
4553sha="$(shasum -a 256 "$dmg" | cut -d' ' -f1)"
4654echo "$dmg $sha"
55printf '%s\n' "$notes" > "$out/notes.txt"
4756
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
4963
5064git tag -s "$tag" -m "orgstar $version"
5165git 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"
5367gitbay release asset add krz/orgstar "$tag" "orgstar-$version.dmg" < "$dmg"
5468
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
5585# The cask goes in through a merge request, as every change to the tap's main does.
5686branch="orgstar-$version"
5787git -C "$tap" switch -q main