-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (138 loc) · 4.92 KB
/
Copy pathMakefile
File metadata and controls
155 lines (138 loc) · 4.92 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
# PanBar Makefile
#
# 本地开发: make run
# 在 Xcode 打开: make open
# 出包: make release-build VERSION=0.1.0
# 签名+公证: make notarize VERSION=0.1.0 (需要 .env 中的凭据,见 docs/RELEASING.md)
# 打 DMG: make dmg VERSION=0.1.0
SHELL := /bin/bash
PROJECT := PanBar.xcodeproj
SCHEME := PanBar
DERIVED := build/dd
APP_NAME := PanBar
# Debug 用独立 bundle ID + 独立文件名,可以和正式版并排装互不影响
DEV_APP_NAME := PanBar-Dev
DEV_BUNDLE_ID := app.panbar.PanBar.debug
DEV_APP_PATH := $(DERIVED)/Build/Products/Debug/$(DEV_APP_NAME).app
VERSION ?= 0.1.0
BUILD_DIR := build/Release
APP_PATH := $(BUILD_DIR)/$(APP_NAME).app
DMG_PATH := build/$(APP_NAME)-$(VERSION).dmg
ZIP_PATH := build/$(APP_NAME)-$(VERSION).zip
# 签名 / 公证凭据(放 .env,不入库)
-include .env
export
.PHONY: help
help:
@echo "PanBar build targets:"
@echo " make gen # 重新生成 Xcode 项目"
@echo " make build # Debug 构建(PanBar-Dev.app,独立 bundle ID 不影响正式版)"
@echo " make run # 构建并(重新)启动 PanBar-Dev"
@echo " make kill # 关掉正在跑的 PanBar-Dev"
@echo " make open # 在 Xcode 中打开"
@echo " make icons # 重新生成 AppIcon"
@echo " make release-build # Release 构建"
@echo " make sign # 用 Developer ID 签名(需 .env: DEV_ID)"
@echo " make notarize # 公证(需 .env: NOTARY_KEYCHAIN_PROFILE)"
@echo " make dmg # 打包成 DMG"
@echo " make zip # 打包成 ZIP(给 Sparkle 用)"
@echo " make appcast # 生成 appcast.xml 条目"
@echo " make clean # 清理产物"
.PHONY: gen
gen:
xcodegen generate
.PHONY: build
build: gen
xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration Debug -derivedDataPath $(DERIVED) \
CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="-" CODE_SIGN_INJECT_BASE_ENTITLEMENTS=YES \
build
.PHONY: run
run: build
@# 先把已经在跑的 dev 版关掉,否则 open 不会重启已有进程,改动看不到
@pkill -f "$(DEV_APP_NAME).app/Contents/MacOS" 2>/dev/null; true
open $(DEV_APP_PATH)
@echo "✓ Launched $(DEV_APP_NAME) ($(DEV_BUNDLE_ID))"
.PHONY: open
open: gen
open $(PROJECT)
.PHONY: kill
kill:
@pkill -f "$(DEV_APP_NAME).app/Contents/MacOS" && echo "✓ Killed $(DEV_APP_NAME)" || echo "(not running)"
.PHONY: icons
icons:
swift scripts/generate-icons.swift
.PHONY: release-build
release-build: gen
mkdir -p $(BUILD_DIR)
xcodebuild \
-project $(PROJECT) \
-scheme $(SCHEME) \
-configuration Release \
-derivedDataPath $(DERIVED) \
-archivePath build/$(APP_NAME).xcarchive \
MARKETING_VERSION=$(VERSION) \
CURRENT_PROJECT_VERSION=$(shell date +%s) \
archive
xcodebuild \
-exportArchive \
-archivePath build/$(APP_NAME).xcarchive \
-exportOptionsPlist scripts/export-options.plist \
-exportPath $(BUILD_DIR)
@echo "✓ Built $(APP_PATH)"
.PHONY: sign
sign:
@test -n "$(DEV_ID)" || (echo "✗ DEV_ID not set in .env" && exit 1)
codesign \
--force \
--options=runtime \
--timestamp \
--sign "$(DEV_ID)" \
--entitlements PanBar/Resources/PanBar.entitlements \
--deep \
$(APP_PATH)
codesign --verify --deep --strict --verbose=2 $(APP_PATH)
@echo "✓ Signed"
.PHONY: notarize
notarize: zip
@test -n "$(NOTARY_KEYCHAIN_PROFILE)" || (echo "✗ NOTARY_KEYCHAIN_PROFILE not set in .env" && exit 1)
xcrun notarytool submit $(ZIP_PATH) \
--keychain-profile "$(NOTARY_KEYCHAIN_PROFILE)" \
--wait
xcrun stapler staple $(APP_PATH)
xcrun stapler validate $(APP_PATH)
@echo "✓ Notarized & stapled"
.PHONY: zip
zip:
@test -d "$(APP_PATH)" || (echo "✗ $(APP_PATH) not found — run 'make release-build' first" && exit 1)
cd $(BUILD_DIR) && ditto -c -k --keepParent --sequesterRsrc $(APP_NAME).app ../$(APP_NAME)-$(VERSION).zip
@echo "✓ ZIP at $(ZIP_PATH)"
.PHONY: dmg
dmg:
@test -d "$(APP_PATH)" || (echo "✗ $(APP_PATH) not found — run 'make release-build' first" && exit 1)
@command -v create-dmg >/dev/null || (echo "✗ create-dmg not installed. brew install create-dmg" && exit 1)
rm -f $(DMG_PATH)
create-dmg \
--volname "$(APP_NAME) $(VERSION)" \
--window-pos 200 120 \
--window-size 540 380 \
--icon-size 100 \
--icon "$(APP_NAME).app" 140 190 \
--app-drop-link 400 190 \
--no-internet-enable \
$(DMG_PATH) \
$(APP_PATH)
@echo "✓ DMG at $(DMG_PATH)"
.PHONY: appcast
appcast:
@test -d build/sparkle-tools/Sparkle.app || (echo "Run: make install-sparkle-tools" && exit 1)
build/sparkle-tools/Sparkle.app/Contents/Resources/generate_appcast build/
.PHONY: install-sparkle-tools
install-sparkle-tools:
@mkdir -p build/sparkle-tools
@echo "Download Sparkle release tools from:"
@echo " https://github.com/sparkle-project/Sparkle/releases"
@echo "Extract Sparkle.app to build/sparkle-tools/"
.PHONY: clean
clean:
rm -rf build/ DerivedData/ $(DERIVED)
xcodebuild -project $(PROJECT) -scheme $(SCHEME) clean 2>/dev/null || true