scripts/release-macos.sh

213799f3f0792831bdbd707d1f85cb19b614f39f
orgstar/scripts/release-macos.sh

63 lines · 3580 bytes · executable

 1#!/bin/sh
 2# Archives the Mac App Store app (with its widgets, Quick Look and Spotlight extensions) and uploads
 3# it to App Store Connect. The version is the project's MARKETING_VERSION; the build number is the
 4# commit count. The Developer ID app is released by scripts/release-mac.sh instead. The work is done
 5# by appstore-kit, checked out beside this repository or at $APPSTORE_KIT.
 6# Usage: scripts/release-macos.sh
 7#   ORGSTAR_PUBLISH  0 archives and exports the .pkg to .build/macos-release without uploading
 8PUBLISH="${ORGSTAR_PUBLISH:-1}"
 9name=orgstar
10project=ios/Orgstar.xcodeproj
11scheme="Orgstar macOS"
12platform=macos
13configuration=Release
14
15# Runs before the archive, so it can only check build settings.
16preflight() {
17    settings="$(command xcodebuild -project "$project" -scheme "$scheme" -configuration "$configuration" \
18        -destination 'generic/platform=macOS' -showBuildSettings 2>/dev/null)" || fail "can't read the build settings of $scheme"
19    value() {
20        printf '%s\n' "$settings" | sed -n "s/^ *$1 = //p" | head -1
21    }
22    case " $(value SWIFT_ACTIVE_COMPILATION_CONDITIONS) " in
23        *" APPSTORE "*) ;;
24        *) fail "SWIFT_ACTIVE_COMPILATION_CONDITIONS of $scheme ($configuration) lacks APPSTORE" ;;
25    esac
26    [ "$(value PRODUCT_BUNDLE_IDENTIFIER)" = sh.krz.orgstar ] || fail "$scheme's bundle ID is $(value PRODUCT_BUNDLE_IDENTIFIER), not sh.krz.orgstar"
27    for entitlements in ios/OrgstarMac/*.entitlements ios/OrgstarWidgets/*-macOS.entitlements \
28        ios/OrgstarQuickLook/*-macOS.entitlements ios/OrgstarSpotlight/*.entitlements; do
29        ! grep -q temporary-exception "$entitlements" || fail "$entitlements has a temporary exception"
30    done
31}
32
33# Checks the built app: no Sparkle, no updater keys, no process launching, no temporary exceptions,
34# and a provisioning profile in the app and in each extension.
35check_archive() {
36    set -- "$1"/Products/Applications/*.app
37    [ -d "$1" ] || fail "no app in the archive"
38    app="$1"
39    [ -z "$(find "$app" -iname '*sparkle*' | head -1)" ] || fail "the archive contains Sparkle: $(find "$app" -iname '*sparkle*' | head -1)"
40    keys="$(plutil -convert json -o - "$app/Contents/Info.plist" \
41        | python3 -c 'import json, sys; print(" ".join(k for k in json.load(sys.stdin) if k.startswith("SU")))')"
42    [ -z "$keys" ] || fail "Info.plist has Sparkle keys: $keys"
43    for bundle in "$app" "$app"/Contents/PlugIns/*.appex "$app"/Contents/Extensions/*.appex; do
44        [ -d "$bundle" ] || continue
45        executable="$bundle/Contents/MacOS/$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$bundle/Contents/Info.plist")"
46        symbols="$(nm -u "$executable" | grep -E '_OBJC_CLASS_\$_NSTask$|_posix_spawnp?$' | sort -u | tr '\n' ' ')"
47        [ -z "$symbols" ] || fail "$(basename "$bundle") launches processes: $symbols"
48        entitlements="$(codesign -d --entitlements - --xml "$bundle" 2>/dev/null)" || fail "$(basename "$bundle") isn't signed"
49        case "$entitlements" in
50            *temporary-exception*) fail "$(basename "$bundle") has a temporary-exception entitlement" ;;
51        esac
52        [ -f "$bundle/Contents/embedded.provisionprofile" ] || fail "$(basename "$bundle") has no embedded.provisionprofile"
53    done
54}
55
56# appstore-kit has no step between archiving and exporting, so its export call checks the archive first.
57xcodebuild() {
58    if [ "$1" = -exportArchive ] && [ "$2" = -archivePath ]; then
59        check_archive "$3"
60    fi
61    command xcodebuild "$@"
62}
63. "${APPSTORE_KIT:-$(dirname "$0")/../../appstore-kit}/release-ios.sh"
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form