-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (103 loc) · 3.66 KB
/
Makefile
File metadata and controls
122 lines (103 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
APP_NAME = OpenCodeMenuBar
BUNDLE_ID = com.opencode.taskbar
BUILD_DIR = build
APP_BUNDLE = $(BUILD_DIR)/$(APP_NAME).app
INSTALL_DIR = $(HOME)/Applications
SOURCES = $(wildcard Sources/*.swift)
# Code signing
SIGNING_IDENTITY = Developer ID Application: Chris Larson (9JCZHUAUEH)
TEAM_ID = 9JCZHUAUEH
# Notarization (override via env or CLI: make notarize NOTARY_KEY_ID=xxx)
NOTARY_KEY_ID ?= $(APP_STORE_KEY_ID)
NOTARY_ISSUER_ID ?= $(APP_STORE_ISSUER_ID)
NOTARY_KEY_PATH ?= $(wildcard AuthKey_*.p8)
.PHONY: all build clean sign notarize release install install-unsigned uninstall run
all: build
# --- Build ---
build: $(APP_BUNDLE)
$(APP_BUNDLE): $(SOURCES) Resources/Info.plist
@echo "==> Compiling Swift sources..."
@mkdir -p $(BUILD_DIR)
swiftc \
-o $(BUILD_DIR)/$(APP_NAME) \
-framework Cocoa \
-framework ServiceManagement \
-target arm64-apple-macosx13.0 \
-swift-version 5 \
-O \
$(SOURCES)
@echo "==> Creating app bundle..."
@mkdir -p $(APP_BUNDLE)/Contents/MacOS
@mkdir -p $(APP_BUNDLE)/Contents/Resources
@cp $(BUILD_DIR)/$(APP_NAME) $(APP_BUNDLE)/Contents/MacOS/$(APP_NAME)
@cp Resources/Info.plist $(APP_BUNDLE)/Contents/
@echo "==> Ad-hoc signing app bundle..."
codesign --force --deep --sign - $(APP_BUNDLE)
@echo "==> Build complete: $(APP_BUNDLE)"
clean:
@echo "==> Cleaning build directory..."
rm -rf $(BUILD_DIR)
@echo "==> Clean complete"
# --- Code Signing (Developer ID) ---
sign: build
@echo "==> Signing with Developer ID..."
codesign --force --deep \
--sign "$(SIGNING_IDENTITY)" \
--options runtime \
--timestamp \
$(APP_BUNDLE)
@echo "==> Verifying signature..."
codesign --verify --deep --strict --verbose=2 $(APP_BUNDLE)
@echo "==> Signature valid"
# --- Notarization ---
notarize: sign
@echo "==> Creating zip for notarization..."
@rm -f $(BUILD_DIR)/$(APP_NAME).zip
ditto -c -k --keepParent $(APP_BUNDLE) $(BUILD_DIR)/$(APP_NAME).zip
@echo "==> Submitting to Apple for notarization..."
xcrun notarytool submit $(BUILD_DIR)/$(APP_NAME).zip \
--key "$(NOTARY_KEY_PATH)" \
--key-id "$(NOTARY_KEY_ID)" \
--issuer "$(NOTARY_ISSUER_ID)" \
--wait
@echo "==> Stapling notarization ticket..."
xcrun stapler staple $(APP_BUNDLE)
@echo "==> Verifying notarization..."
spctl --assess --type execute --verbose=2 $(APP_BUNDLE)
@echo "==> Notarization complete"
@rm -f $(BUILD_DIR)/$(APP_NAME).zip
# --- Release (full pipeline) ---
release: notarize
@echo "==> Release build ready: $(APP_BUNDLE)"
@echo " Signed with: $(SIGNING_IDENTITY)"
@echo " Notarized and stapled"
# --- Install ---
install: release
@echo "==> Installing to $(INSTALL_DIR)..."
@mkdir -p $(INSTALL_DIR)
@-pkill -f "$(APP_NAME).app/Contents/MacOS/$(APP_NAME)" 2>/dev/null || true
@sleep 0.5
@rm -rf "$(INSTALL_DIR)/$(APP_NAME).app"
@cp -R $(APP_BUNDLE) "$(INSTALL_DIR)/$(APP_NAME).app"
@echo "==> Installed: $(INSTALL_DIR)/$(APP_NAME).app"
@echo "==> Launching $(APP_NAME)..."
@open "$(INSTALL_DIR)/$(APP_NAME).app"
install-unsigned: build
@echo "==> Installing (unsigned) to $(INSTALL_DIR)..."
@mkdir -p $(INSTALL_DIR)
@-pkill -f "$(APP_NAME).app/Contents/MacOS/$(APP_NAME)" 2>/dev/null || true
@sleep 0.5
@rm -rf "$(INSTALL_DIR)/$(APP_NAME).app"
@cp -R $(APP_BUNDLE) "$(INSTALL_DIR)/$(APP_NAME).app"
@echo "==> Installed: $(INSTALL_DIR)/$(APP_NAME).app"
@echo "==> Launching $(APP_NAME)..."
@open "$(INSTALL_DIR)/$(APP_NAME).app"
uninstall:
@echo "==> Stopping $(APP_NAME) if running..."
@-pkill -f "$(APP_NAME).app/Contents/MacOS/$(APP_NAME)" 2>/dev/null || true
@echo "==> Removing from $(INSTALL_DIR)..."
@rm -rf "$(INSTALL_DIR)/$(APP_NAME).app"
@echo "==> Uninstall complete"
run: build
@echo "==> Running $(APP_NAME)..."
@open $(APP_BUNDLE)