Commit 4a422fe598

4a422fe5984a6551fd399b8a9308917b4f65e670

parent: df08e11a9f

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-10 21:53 UTC

Mac release script: universal, Developer ID, notarized DMG, Homebrew cask

build-app.sh takes a signing identity (hardened runtime and timestamp when not ad hoc), architectures and a build number. release-mac.sh notarizes and staples a DMG, tags the version, uploads the DMG to the gitbay release and updates the cask in krz/homebrew-tap; ORGSTAR_PUBLISH=0 stops after notarizing.

Layout: unified · split

README.md +4
@@ -21,6 +21,10 @@ scripts/build-app.sh # builds .build/app/orgstar.app, signed ad hoc
21open .build/app/orgstar.app 21open .build/app/orgstar.app
22``` 22```
23 23
24`scripts/release-mac.sh <version>` builds a universal app, signs it with the keychain's
25Developer ID, notarizes a DMG, tags `v<version>`, uploads the DMG to the gitbay release
26and updates the cask in krz/homebrew-tap.
27
24Add a folder with File > Add Folder… (⇧⌘O). ⌘P opens a file by name, ⇧⌘F 28Add a folder with File > Add Folder… (⇧⌘O). ⌘P opens a file by name, ⇧⌘F
25searches, ⇧⌘A shows the agenda. In the editor, TAB on a heading cycles its 29searches, ⇧⌘A shows the agenda. In the editor, TAB on a heading cycles its
26folding and Shift-TAB cycles the whole file. orgstar opens `.org` files from 30folding and Shift-TAB cycles the whole file. orgstar opens `.org` files from
docs/manual/install.org +21 −4
@@ -1,6 +1,6 @@
1#+TITLE: Install 1#+TITLE: Install
2#+DESCRIPTION: Building orgstar for the Mac and the iOS Simulator from source. 2#+DESCRIPTION: Installing orgstar on the Mac with Homebrew or a download, and building it from source.
3#+LEDE: orgstar is built from source; there are no prebuilt downloads yet. 3#+LEDE: The Mac app comes as a notarized download and a Homebrew cask; the iOS app is built from source.
4 4
5* Requirements 5* Requirements
6 6
@@ -13,6 +13,21 @@
13 13
14* The Mac app 14* The Mac app
15 15
16** With Homebrew
17
18#+BEGIN_SRC sh
19brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git
20brew install --cask orgstar
21#+END_SRC
22
23** As a download
24
25Download =orgstar-<version>.dmg= from the [[https://gitbay.org/krz/orgstar/releases][releases page]], open it, and drag
26orgstar to Applications. The app is universal (Apple silicon and Intel), signed with a
27Developer ID and notarized by Apple, so it opens without warnings.
28
29** From source
30
16#+BEGIN_SRC sh 31#+BEGIN_SRC sh
17git clone https://gitbay.org/krz/orgstar.git 32git clone https://gitbay.org/krz/orgstar.git
18cd orgstar 33cd orgstar
@@ -52,7 +67,8 @@ See [[file:guide/14-ios.org][iPhone and iPad]] for what it does.
52 67
53* Updating 68* Updating
54 69
55Pull and build again: 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:
56 72
57#+BEGIN_SRC sh 73#+BEGIN_SRC sh
58git pull 74git pull
@@ -63,5 +79,6 @@ Your settings live in =~/.config/orgstar/= and survive rebuilds.
63 79
64* Uninstalling 80* Uninstalling
65 81
66Delete =orgstar.app=. To remove your settings as well, delete =~/.config/orgstar/=. 82Delete =orgstar.app=, or run =brew uninstall --cask orgstar=. To remove your settings as
83well, delete =~/.config/orgstar/= (=brew uninstall --zap --cask orgstar= does both).
67Your org files are never stored inside the app. 84Your org files are never stored inside the app.
packaging/orgstar.rb added +23
@@ -0,0 +1,23 @@
1# Template for krz/homebrew-tap's Casks/orgstar.rb; scripts/release-mac.sh fills in the version
2# and checksum. Install with:
3# brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git && brew install --cask orgstar
4
5cask "orgstar" do
6 version "@VERSION@"
7 sha256 "@SHA256@"
8
9 url "https://gitbay.org/krz/orgstar/releases/download/v#{version}/orgstar-#{version}.dmg"
10 name "orgstar"
11 desc "Native org-mode editor and agenda"
12 homepage "https://gitbay.org/krz/orgstar"
13
14 depends_on macos: ">= :tahoe"
15
16 app "orgstar.app"
17
18 zap trash: [
19 "~/.config/orgstar",
20 "~/Library/Application Support/Orgstar",
21 "~/Library/Preferences/sh.krz.orgstar.plist",
22 ]
23end
scripts/build-app.sh +41 −12
@@ -1,17 +1,33 @@
1#!/bin/sh 1#!/bin/sh
2# Builds orgstar.app in .build/app from the release binary, signed ad hoc for local use. The 2# Builds orgstar.app in .build/app from the release binary. The icon is drawn by
3# icon is drawn by scripts/make-icon.swift. 3# scripts/make-icon.swift.
4# Usage: scripts/build-app.sh [version] 4# Usage: scripts/build-app.sh [version] [build]
5# ORGSTAR_SIGN signing identity; ad hoc ("-") for local use by default. Any other
6# identity also turns on the hardened runtime and a secure timestamp.
7# ORGSTAR_ARCHS architectures, e.g. "arm64 x86_64" for a universal app; this Mac's by default.
5set -eu 8set -eu
6 9
7cd "$(dirname "$0")/.." 10cd "$(dirname "$0")/.."
8version="${1:-0.1.0}" 11version="${1:-0.1.0}"
12build="${2:-$version}"
13sign="${ORGSTAR_SIGN:--}"
9app=".build/app/orgstar.app" 14app=".build/app/orgstar.app"
15arch_flags=""
16for arch in ${ORGSTAR_ARCHS:-$(uname -m)}; do arch_flags="$arch_flags --arch $arch"; done
17if [ "$sign" = "-" ]; then
18 sign_flags=""
19else
20 sign_flags="--options runtime --timestamp"
21fi
10 22
11swift build -c release --product Orgstar 23# shellcheck disable=SC2086
12swift build -c release --product OrgstarQuickLook 24swift build -c release $arch_flags --product Orgstar
13swift build -c release --product OrgstarSpotlight 25# shellcheck disable=SC2086
14binary="$(swift build -c release --show-bin-path)/Orgstar" 26swift build -c release $arch_flags --product OrgstarQuickLook
27# shellcheck disable=SC2086
28swift build -c release $arch_flags --product OrgstarSpotlight
29# shellcheck disable=SC2086
30binary="$(swift build -c release $arch_flags --show-bin-path)/Orgstar"
15 31
16rm -rf "$app" 32rm -rf "$app"
17mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources" 33mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
@@ -89,7 +105,7 @@ cat > "$app/Contents/Info.plist" <<EOF
89 <key>CFBundleShortVersionString</key> 105 <key>CFBundleShortVersionString</key>
90 <string>${version}</string> 106 <string>${version}</string>
91 <key>CFBundleVersion</key> 107 <key>CFBundleVersion</key>
92 <string>${version}</string> 108 <string>${build}</string>
93 <key>LSMinimumSystemVersion</key> 109 <key>LSMinimumSystemVersion</key>
94 <string>26.0</string> 110 <string>26.0</string>
95 <key>LSApplicationCategoryType</key> 111 <key>LSApplicationCategoryType</key>
@@ -138,7 +154,7 @@ appex() { # name, extension point, principal class, attributes
138 <key>CFBundleShortVersionString</key> 154 <key>CFBundleShortVersionString</key>
139 <string>${version}</string> 155 <string>${version}</string>
140 <key>CFBundleVersion</key> 156 <key>CFBundleVersion</key>
141 <string>${version}</string> 157 <string>${build}</string>
142 <key>LSMinimumSystemVersion</key> 158 <key>LSMinimumSystemVersion</key>
143 <string>26.0</string> 159 <string>26.0</string>
144 <key>NSExtension</key> 160 <key>NSExtension</key>
@@ -163,14 +179,27 @@ PLIST
163</dict> 179</dict>
164</plist> 180</plist>
165PLIST 181PLIST
166 codesign --force --sign - --entitlements "$work/sandbox.entitlements" "$app/Contents/PlugIns/$1.appex" 182 # shellcheck disable=SC2086
183 codesign --force --sign "$sign" $sign_flags --entitlements "$work/sandbox.entitlements" "$app/Contents/PlugIns/$1.appex"
167} 184}
168work="$(mktemp -d)" 185work="$(mktemp -d)"
169appex OrgstarQuickLook com.apple.quicklook.preview PreviewProvider \ 186appex OrgstarQuickLook com.apple.quicklook.preview PreviewProvider \
170 "<key>QLSupportedContentTypes</key><array><string>org.orgmode.org</string></array><key>QLIsDataBasedPreview</key><true/>" 187 "<key>QLSupportedContentTypes</key><array><string>org.orgmode.org</string></array><key>QLIsDataBasedPreview</key><true/>"
171appex OrgstarSpotlight com.apple.spotlight.import ImportExtension \ 188appex OrgstarSpotlight com.apple.spotlight.import ImportExtension \
172 "<key>CSSupportedContentTypes</key><array><string>org.orgmode.org</string></array>" 189 "<key>CSSupportedContentTypes</key><array><string>org.orgmode.org</string></array>"
173rm -rf "$work"
174 190
175codesign --force --sign - "$app" 191# The hardened runtime needs Calendar access declared for the agenda's events.
192cat > "$work/app.entitlements" <<PLIST
193<?xml version="1.0" encoding="UTF-8"?>
194<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
195<plist version="1.0">
196<dict>
197 <key>com.apple.security.personal-information.calendars</key>
198 <true/>
199</dict>
200</plist>
201PLIST
202# shellcheck disable=SC2086
203codesign --force --sign "$sign" $sign_flags --entitlements "$work/app.entitlements" "$app"
204rm -rf "$work"
176echo "$app" 205echo "$app"
scripts/release-mac.sh added +60
@@ -0,0 +1,60 @@
1#!/bin/sh
2# Builds, signs, notarizes and publishes a Mac release: a universal orgstar.app in a DMG,
3# uploaded to the tag's gitbay release, and the cask in krz/homebrew-tap updated.
4# Usage: scripts/release-mac.sh <version> e.g. 0.2.0, for the tag v0.2.0 on HEAD
5# ORGSTAR_SIGN Developer ID Application identity (default: the keychain's only one)
6# ORGSTAR_NOTARY notarytool keychain profile (default: orgstar)
7# ORGSTAR_TAP the homebrew-tap checkout (default: ../homebrew-tap)
8# ORGSTAR_PUBLISH 0 builds and notarizes without tagging, uploading or touching the tap
9set -eu
10
11cd "$(dirname "$0")/.."
12version="${1:?usage: scripts/release-mac.sh <version>}"
13tag="v$version"
14notary="${ORGSTAR_NOTARY:-orgstar}"
15tap="${ORGSTAR_TAP:-../homebrew-tap}"
16publish="${ORGSTAR_PUBLISH:-1}"
17sign="${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; }
19
20if [ "$publish" != 0 ]; then
21 [ -z "$(git status --porcelain)" ] || { echo "The working tree has changes." >&2; exit 1; }
22 [ "$(git branch --show-current)" = main ] || { echo "Release from main." >&2; exit 1; }
23fi
24
25# The build number counts commits, so each release's is higher than the last's.
26build="$(git rev-list --count HEAD)"
27ORGSTAR_SIGN="$sign" ORGSTAR_ARCHS="arm64 x86_64" sh scripts/build-app.sh "$version" "$build" > /dev/null
28app=".build/app/orgstar.app"
29codesign --verify --strict --deep "$app"
30
31out=".build/release"
32dmg="$out/orgstar-$version.dmg"
33rm -rf "${out:?}"
34mkdir -p "$out/dmg"
35ditto "$app" "$out/dmg/orgstar.app"
36ln -s /Applications "$out/dmg/Applications"
37hdiutil create -quiet -volname "orgstar $version" -srcfolder "$out/dmg" -format UDZO -fs HFS+ "$dmg"
38codesign --sign "$sign" --timestamp "$dmg"
39
40# Notarizing the DMG covers the app inside it; stapling both lets them open offline.
41xcrun notarytool submit "$dmg" --keychain-profile "$notary" --wait
42xcrun stapler staple "$dmg"
43xcrun stapler staple "$app"
44spctl --assess --type open --context context:primary-signature -v "$dmg"
45sha="$(shasum -a 256 "$dmg" | cut -d' ' -f1)"
46echo "$dmg $sha"
47
48[ "$publish" != 0 ] || exit 0
49
50git tag -s "$tag" -m "orgstar $version"
51git push origin "$tag"
52gitbay release create krz/orgstar "$tag" --title "orgstar $version" --notes "Universal (Apple silicon and Intel), macOS 26 or later. Notarized."
53gitbay release asset add krz/orgstar "$tag" "orgstar-$version.dmg" < "$dmg"
54
55cask="$tap/Casks/orgstar.rb"
56sed -e "s/@VERSION@/$version/" -e "s/@SHA256@/$sha/" packaging/orgstar.rb > "$cask"
57git -C "$tap" add Casks/orgstar.rb
58git -C "$tap" commit -q -m "orgstar $version"
59git -C "$tap" push -q origin HEAD
60echo "Released $tag; cask updated in $tap"