-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
234 lines (205 loc) · 8 KB
/
Copy pathMakefile
File metadata and controls
234 lines (205 loc) · 8 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
.PHONY: build ci-build release-build release-dist signing-install signing-github-secrets run qr clean deploy install launch-installed open kill logs help lint bump bump-version changelog setup ensure-deps check-tools brew-deps
# Project configuration
WORKSPACE = Vimac.xcworkspace
SCHEME = Vimac
BUILD_DIR = build
APP_NAME = Vimac
APP_PATH = $(BUILD_DIR)/Build/Products/Debug/$(APP_NAME).app
TEAM_ID = 5RV873WV4N
LAST_BUILD_FILE = .last_build_commit
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36mmake %-15s\033[0m %s\n", $$1, $$2}
# Check if build number needs to be incremented based on git commits
auto-bump:
@CURRENT_COMMIT=$$(git rev-parse HEAD) && \
LAST_COMMIT=$$(cat $(LAST_BUILD_FILE) 2>/dev/null || echo "") && \
if [ "$$CURRENT_COMMIT" != "$$LAST_COMMIT" ]; then \
echo "New commits detected, incrementing build number..."; \
BUILD=$$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ViMac-Swift/Info.plist) && \
NEXT=$$((BUILD + 1)) && \
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $$NEXT" ViMac-Swift/Info.plist && \
echo "$$CURRENT_COMMIT" > $(LAST_BUILD_FILE) && \
echo "Build number: $$BUILD → $$NEXT"; \
else \
echo "No new commits, build number unchanged"; \
fi
ensure-deps:
@$(MAKE) check-tools
@if [ ! -d Pods ] || [ ! -d Carthage/Build ]; then \
echo "Dependencies missing, running setup..."; \
$(MAKE) setup; \
fi
ifeq ($(CI),true)
BUILD_DEPS = ensure-deps
else
BUILD_DEPS = auto-bump ensure-deps
endif
XCODEBUILD_UNSIGNED = xcodebuild -workspace $(WORKSPACE) \
-scheme $(SCHEME) \
-derivedDataPath $(BUILD_DIR) \
-destination 'platform=macOS,arch=arm64' \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
DEVELOPMENT_TEAM="" \
BUILD_ENV=CI
build: $(BUILD_DEPS) ## Build the application (Debug, unsigned)
@echo "Building $(SCHEME)..."
@$(XCODEBUILD_UNSIGNED) \
-configuration Debug \
build
ci-build: ensure-deps ## CI build (Debug, unsigned; skips auto-bump)
@echo "Building $(SCHEME) for CI..."
@$(XCODEBUILD_UNSIGNED) \
-configuration Debug \
build
release-build: ensure-deps ## Release build (unsigned; local only)
@echo "Building $(SCHEME) (Release, unsigned)..."
@$(XCODEBUILD_UNSIGNED) \
-configuration Release \
build
signing-install: ## Install signing/developerID_application.cer (+ optional .p12) into keychain
@chmod +x scripts/signing-install.sh scripts/load-signing-env.sh
@./scripts/signing-install.sh
signing-github-secrets: ## Print base64 secret values for GitHub Actions
@chmod +x scripts/signing-github-secrets.sh scripts/load-signing-env.sh
@./scripts/signing-github-secrets.sh
release-dist: ensure-deps ## Signed Developer ID build + notarize (for GitHub Releases)
@chmod +x scripts/release-package.sh scripts/load-signing-env.sh
@./scripts/release-package.sh
lint: ## Quick compile check - shows only errors and warnings
@echo "Checking $(SCHEME) for errors..."
@xcodebuild -workspace $(WORKSPACE) \
-scheme $(SCHEME) \
-configuration Debug \
-derivedDataPath $(BUILD_DIR) \
-destination 'platform=macOS,arch=arm64' \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
DEVELOPMENT_TEAM="" \
BUILD_ONLY_ACTIVE_ARCH=YES \
build 2>&1 | grep -E '(error:|warning:)' || echo "✓ No errors or warnings"
run: ## Build and run the application
@make kill 2>/dev/null || true
@make build
@echo "Launching $(APP_NAME)..."
@open $(APP_PATH)
qr: ## Quick run without rebuilding
@make kill 2>/dev/null || true
@echo "Launching $(APP_NAME)..."
@open $(APP_PATH)
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
@xcodebuild -workspace $(WORKSPACE) \
-scheme $(SCHEME) \
clean
@if [ -d $(BUILD_DIR) ]; then /usr/bin/trash $(BUILD_DIR); fi
bump: ## Increment build number (in Info.plist)
@BUILD=$$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ViMac-Swift/Info.plist) && \
NEXT=$$((BUILD + 1)) && \
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $$NEXT" ViMac-Swift/Info.plist && \
echo "Build number: $$BUILD → $$NEXT"
bump-version: ## Increment marketing version (patch: 0.3.19 → 0.3.20)
@CURRENT=$$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ViMac-Swift/Info.plist) && \
NEXT=$$(echo $$CURRENT | awk -F. '{$$NF=$$NF+1; print}' OFS=.) && \
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $$NEXT" ViMac-Swift/Info.plist && \
echo "Version: $$CURRENT → $$NEXT"
deploy: ## Build, install to /Applications, and run
@make kill 2>/dev/null || true
@make build
@if [ -d /Applications/$(APP_NAME).app ]; then /usr/bin/trash /Applications/$(APP_NAME).app; fi
@cp -r $(APP_PATH) /Applications/
@echo "Launched $(APP_NAME) from /Applications"
@open /Applications/$(APP_NAME).app
install: ## Install already-built app to /Applications (no build)
@if [ ! -d "$(APP_PATH)" ]; then \
echo "ERROR: Built app not found at: $(APP_PATH)"; \
echo "Run: make build"; \
exit 2; \
fi
@if [ -d /Applications/$(APP_NAME).app ]; then /usr/bin/trash /Applications/$(APP_NAME).app; fi
@cp -r "$(APP_PATH)" /Applications/
@echo "Installed $(APP_NAME) to /Applications"
launch-installed: ## Launch /Applications/Vimac.app (no build/install)
@open /Applications/$(APP_NAME).app
archive: auto-bump ## Build a signed Release archive (Apple Development or Developer ID)
@echo "Archiving $(SCHEME)..."
@mkdir -p $(BUILD_DIR)
@xcodebuild -workspace $(WORKSPACE) \
-scheme $(SCHEME) \
-configuration Release \
-derivedDataPath $(BUILD_DIR) \
-destination 'generic/platform=macOS' \
CODE_SIGN_STYLE=Automatic \
DEVELOPMENT_TEAM=$(TEAM_ID) \
BUILD_ENV=CI \
-archivePath $(BUILD_DIR)/$(APP_NAME).xcarchive \
-allowProvisioningUpdates \
archive
@echo "Archive created at $(BUILD_DIR)/$(APP_NAME).xcarchive"
open: ## Open workspace in Xcode
@open $(WORKSPACE)
kill: ## Kill running instances of the app
@pkill -f $(APP_NAME) || true
logs: ## Tail application logs
@echo "Showing logs for $(APP_NAME)..."
@log stream --predicate 'processImagePath contains "$(APP_NAME)"' --level debug
changelog: ## Generate changelog from last tag to HEAD
@VERSION=$$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ViMac-Swift/Info.plist) && \
PREV_TAG=$$(git describe --tags --abbrev=0 2>/dev/null || echo "") && \
if [ -z "$$PREV_TAG" ]; then \
echo "No previous tag found. Using full history."; \
RANGE="HEAD"; \
FROM="initial"; \
else \
RANGE="$$PREV_TAG..HEAD"; \
FROM="$$PREV_TAG"; \
fi && \
mkdir -p changelogs && \
OUTFILE="changelogs/v$$VERSION.md" && \
echo "# v$$VERSION" > "$$OUTFILE" && \
echo "" >> "$$OUTFILE" && \
echo "Changes since $$FROM:" >> "$$OUTFILE" && \
echo "" >> "$$OUTFILE" && \
git log $$RANGE --no-merges --pretty=format:"- %s" >> "$$OUTFILE" && \
echo "" >> "$$OUTFILE" && \
echo "" >> "$$OUTFILE" && \
echo "Generated: $$(date +%Y-%m-%d)" >> "$$OUTFILE" && \
echo "Wrote $$OUTFILE"
setup: ## Install dependencies (CocoaPods + Carthage)
@echo "Installing CocoaPods dependencies..."
@pod install
@echo "Building Carthage dependencies..."
@carthage build
@echo "Setup complete! Run 'make build' to build the app."
check-tools: ## Verify required tools are installed
@missing=0; \
if ! command -v pod >/dev/null 2>&1; then \
echo ""; \
echo "ERROR: CocoaPods ('pod') is not installed."; \
echo ""; \
echo "Install (Ruby >= 3 recommended):"; \
echo " gem install cocoapods"; \
echo ""; \
echo "Notes:"; \
echo " - Avoid 'sudo gem ...' (often uses macOS system Ruby)."; \
echo " - If you use mise/asdf/etc, ensure that Ruby is activated in this shell."; \
missing=1; \
fi; \
if ! command -v carthage >/dev/null 2>&1; then \
echo ""; \
echo "ERROR: Carthage ('carthage') is not installed."; \
echo ""; \
echo "Install:"; \
echo " brew install carthage"; \
missing=1; \
fi; \
if [ $$missing -ne 0 ]; then \
echo ""; \
echo "Once installed, re-run: make setup (or make deploy)"; \
exit 2; \
fi
brew-deps: ## Install Homebrew deps via Brewfile (optional)
@brew bundle --file ./Brewfile