scripts/build-app.sh

30f6716c5b85f009c8cee977f3e5e4e4b5df3d09
orgstar/scripts/build-app.sh

117 lines · 4360 bytes · executable

  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]
  5set -eu
  6
  7cd "$(dirname "$0")/.."
  8version="${1:-0.1.0}"
  9app=".build/app/Orgstar.app"
 10
 11swift build -c release --product Orgstar
 12binary="$(swift build -c release --show-bin-path)/Orgstar"
 13
 14rm -rf "$app"
 15mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
 16cp "$binary" "$app/Contents/MacOS/Orgstar"
 17iconset="$(mktemp -d)/AppIcon.iconset"
 18swift scripts/make-icon.swift "$iconset"
 19iconutil -c icns "$iconset" -o "$app/Contents/Resources/AppIcon.icns"
 20rm -rf "$(dirname "$iconset")"
 21
 22cat > "$app/Contents/Info.plist" <<EOF
 23<?xml version="1.0" encoding="UTF-8"?>
 24<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 25<plist version="1.0">
 26<dict>
 27    <key>CFBundleIdentifier</key>
 28    <string>sh.krz.orgstar</string>
 29    <key>CFBundleName</key>
 30    <string>Orgstar</string>
 31    <key>CFBundleDisplayName</key>
 32    <string>Orgstar</string>
 33    <key>CFBundleExecutable</key>
 34    <string>Orgstar</string>
 35    <key>CFBundlePackageType</key>
 36    <string>APPL</string>
 37    <key>CFBundleIconFile</key>
 38    <string>AppIcon</string>
 39    <key>UTImportedTypeDeclarations</key>
 40    <array>
 41        <dict>
 42            <key>UTTypeIdentifier</key>
 43            <string>org.orgmode.org</string>
 44            <key>UTTypeDescription</key>
 45            <string>Org document</string>
 46            <key>UTTypeConformsTo</key>
 47            <array><string>public.plain-text</string></array>
 48            <key>UTTypeTagSpecification</key>
 49            <dict>
 50                <key>public.filename-extension</key>
 51                <array><string>org</string><string>org_archive</string></array>
 52            </dict>
 53        </dict>
 54    </array>
 55    <key>CFBundleDocumentTypes</key>
 56    <array>
 57        <dict>
 58            <key>CFBundleTypeName</key>
 59            <string>Org document</string>
 60            <key>CFBundleTypeRole</key>
 61            <string>Editor</string>
 62            <key>LSHandlerRank</key>
 63            <string>Default</string>
 64            <key>LSItemContentTypes</key>
 65            <array><string>org.orgmode.org</string></array>
 66        </dict>
 67        <dict>
 68            <key>CFBundleTypeName</key>
 69            <string>Text</string>
 70            <key>CFBundleTypeRole</key>
 71            <string>Editor</string>
 72            <key>LSHandlerRank</key>
 73            <string>Alternate</string>
 74            <key>LSItemContentTypes</key>
 75            <array><string>public.plain-text</string></array>
 76        </dict>
 77    </array>
 78    <key>CFBundleURLTypes</key>
 79    <array>
 80        <dict>
 81            <key>CFBundleURLName</key>
 82            <string>org-protocol</string>
 83            <key>CFBundleURLSchemes</key>
 84            <array><string>org-protocol</string></array>
 85        </dict>
 86    </array>
 87    <key>CFBundleShortVersionString</key>
 88    <string>${version}</string>
 89    <key>CFBundleVersion</key>
 90    <string>${version}</string>
 91    <key>LSMinimumSystemVersion</key>
 92    <string>26.0</string>
 93    <key>LSApplicationCategoryType</key>
 94    <string>public.app-category.productivity</string>
 95    <key>NSHighResolutionCapable</key>
 96    <true/>
 97    <key>NSPrincipalClass</key>
 98    <string>NSApplication</string>
 99</dict>
100</plist>
101EOF
102
103# App Intents metadata for Shortcuts, from the constant values Swift Build extracted; SwiftPM
104# doesn't run this step itself.
105toolchain="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain"
106objects=".build/out/Intermediates.noindex/Orgstar.build/Release/Orgstar-p.build/Objects-normal/$(uname -m)"
107work="$(mktemp -d)"
108echo "$PWD/$objects/Orgstar-primary.swiftconstvalues" > "$work/constvalues.txt"
109"$toolchain/usr/bin/appintentsmetadataprocessor" --toolchain-dir "$toolchain" --module-name Orgstar \
110    --sdk-root "$(xcrun --sdk macosx --show-sdk-path)" --xcode-version "$(xcodebuild -version | awk '/Build version/ {print $3}')" \
111    --platform-family macOS --deployment-target 26.0 --bundle-identifier sh.krz.orgstar \
112    --target-triple "$(uname -m)-apple-macos26.0" --binary-file "$binary" --source-file-list "$objects/Orgstar.SwiftFileList" \
113    --swift-const-vals-list "$work/constvalues.txt" --output "$app/Contents/Resources" --force > /dev/null 2>&1
114rm -rf "$work"
115
116codesign --force --sign - "$app"
117echo "$app"
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