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