krz/octosentry

macOS menu bar app to monitor GitHub security alerts

clone: git clone https://gitbay.org/krz/octosentry.git

1.0.0: scripts/build-dmg.sh · raw

 1#!/bin/bash
 2#
 3# build-dmg.sh
 4#
 5# Builds a notarized, Developer-ID-signed DMG for direct distribution
 6# (spec §9: DMG/Homebrew channel). Requires local one-time setup this
 7# script does NOT do for you:
 8#
 9#   1. A "Developer ID Application" certificate in your keychain, tied to
10#      an active Apple Developer Program membership. Xcode > Settings >
11#      Accounts > Manage Certificates > + > Developer ID Application.
12#   2. Notarization credentials stored once via:
13#        xcrun notarytool store-credentials "octosentry-notary" \
14#          --apple-id "you@example.com" \
15#          --team-id "YOUR_TEAM_ID" \
16#          --password "an-app-specific-password"
17#      (App-specific password from appleid.apple.com, not your main
18#      Apple ID password.)
19#
20# Usage: scripts/build-dmg.sh [version]
21# Output: build/octosentry-<version>.dmg
22
23set -euo pipefail
24
25VERSION="${1:-dev}"
26PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
27BUILD_DIR="$PROJECT_DIR/build"
28ARCHIVE_PATH="$BUILD_DIR/octosentry.xcarchive"
29EXPORT_PATH="$BUILD_DIR/export"
30EXPORT_OPTIONS_PLIST="$BUILD_DIR/export-options.plist"
31DMG_PATH="$BUILD_DIR/octosentry-$VERSION.dmg"
32NOTARY_PROFILE="octosentry-notary"
33
34rm -rf "$BUILD_DIR"
35mkdir -p "$BUILD_DIR"
36
37echo "==> Archiving (Release configuration)"
38xcodebuild archive \
39  -project "$PROJECT_DIR/octosentry.xcodeproj" \
40  -scheme octosentry \
41  -configuration Release \
42  -archivePath "$ARCHIVE_PATH"
43
44cat > "$EXPORT_OPTIONS_PLIST" <<PLIST
45<?xml version="1.0" encoding="UTF-8"?>
46<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
47<plist version="1.0">
48<dict>
49	<key>method</key>
50	<string>developer-id</string>
51</dict>
52</plist>
53PLIST
54
55echo "==> Exporting (Developer ID)"
56xcodebuild -exportArchive \
57  -archivePath "$ARCHIVE_PATH" \
58  -exportPath "$EXPORT_PATH" \
59  -exportOptionsPlist "$EXPORT_OPTIONS_PLIST"
60
61APP_PATH="$EXPORT_PATH/octosentry.app"
62
63echo "==> Notarizing"
64DMG_STAGING="$BUILD_DIR/staging"
65mkdir -p "$DMG_STAGING"
66cp -R "$APP_PATH" "$DMG_STAGING/"
67ln -s /Applications "$DMG_STAGING/Applications"
68
69hdiutil create -volname "octosentry" -srcfolder "$DMG_STAGING" -ov -format UDZO "$DMG_PATH"
70
71xcrun notarytool submit "$DMG_PATH" --keychain-profile "$NOTARY_PROFILE" --wait
72
73echo "==> Stapling notarization ticket"
74xcrun stapler staple "$DMG_PATH"
75
76echo "==> Done: $DMG_PATH"