-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (94 loc) · 3.13 KB
/
Makefile
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
# 📜 https://forums.swift.org/t/how-to-distribute-a-swiftpm-executable-on-macos/47127/5
# 📜 https://developer.apple.com/developer-id/
VERSION = 1.2.0
PRODUCT = pomodoro-cli
BINARY = .build/apple/Products/Release/${PRODUCT}
PKG_ROOT = ./pkg/${PRODUCT}-${VERSION}
PKG_DIR = ${PKG_ROOT}/usr/local/bin
PKG_DMG = ./pkg/${PRODUCT}-${VERSION}.dmg
PKG_DMG_ROOT = ./pkg/out
PKG = ${PKG_DMG_ROOT}/${PRODUCT}-${VERSION}.pkg
BUNDLE_ID = ${REVERSED_DOMAIN}.${PRODUCT}
# Load secrets
$(shell touch .env)
include .env
export $(shell sed 's/=.*//' .env)
prefix ?= /usr/local
bindir = $(prefix)/bin
# --- The Everyday Tasks ---
.PHONY: docs
install:
swift package update
open:
open Package.swift
build:
swift build --skip-update
format:
swiftformat --verbose .
swiftlint lint --autocorrect .
lint:
swiftformat --lint .
swiftlint lint .
shellcheck Resources/SampleHooks/sample-pomodoro-finish.sh
shellcheck Resources/SampleHooks/sample-pomodoro-start.sh
shellcheck Resources/SampleHooks/mickf-pomodoro-finish.sh
shellcheck Resources/SampleHooks/mickf-pomodoro-start.sh
run-test: build
.build/debug/${PRODUCT} --duration 5
deploy:
swift build -c release --disable-sandbox
sudo install ".build/release/${PRODUCT}" "$(bindir)/pomodoro-cli"
mkdir -p "$(HOME)/.pomodoro-cli"
touch "$(HOME)/.pomodoro-cli/journal.yml"
cp Resources/SampleHooks/sample-pomodoro-finish.sh "$(HOME)/.pomodoro-cli/pomodoro-finish.sh"
cp Resources/SampleHooks/sample-pomodoro-start.sh "$(HOME)/.pomodoro-cli/pomodoro-start.sh"
deploy-my-hooks:
cp Resources/SampleHooks/mickf-pomodoro-finish.sh "$(HOME)/.pomodoro-cli/pomodoro-finish.sh"
cp Resources/SampleHooks/mickf-pomodoro-start.sh "$(HOME)/.pomodoro-cli/pomodoro-start.sh"
cp Resources/SampleHooks/notify.js "$(HOME)/.pomodoro-cli/notify.js"
docs:
xcodebuild docbuild -scheme "Pomodoro" -derivedDataPath tmp/derivedDataPath -destination platform=macOS
rsync -r tmp/derivedDataPath/Build/Products/Debug/Pomodoro.doccarchive/ .Pomodoro.doccarchive
rm -rf tmp/
clean:
rm -rf .build/ .swiftpm/ pkg/
serve-docs:
serve --single .Pomodoro.doccarchive
# --- The Distribution Tasks ---
${BINARY}:
swift build -c release --product ${PRODUCT} --arch arm64 --arch x86_64
xcrun codesign -s ${CODESIGN_IDENTITY} \
--options=runtime \
--timestamp \
${BINARY}
${PKG}: ${BINARY}
rm -rf "${PKG_ROOT}" || true
rm -rf "${PKG_DMG_ROOT}" || true
mkdir -p ${PKG_DIR}
mkdir -p ${PKG_DMG_ROOT}
cp ${BINARY} ${PKG_DIR}
xcrun pkgbuild --root ${PKG_ROOT} \
--identifier "${BUNDLE_ID}" \
--version "${VERSION}" \
--install-location "/" \
--sign ${PKG_CODESIGN_IDENTITY} \
${PKG}
${PKG_DMG}: ${PKG} staple
hdiutil create -volname "${PRODUCT}" -srcfolder "${PKG_DMG_ROOT}" -ov -format UDZO "${PKG_DMG}"
.PHONY: build
build: ${BINARY}
.PHONY: package
package: ${PKG}
.PHONY: notarize
notarize: ${PKG}
xcrun notarytool submit \
--apple-id "${USERNAME}" \
--password "${PASSWORD_ID}" \
--team-id "${TEAM_ID}" \
--wait \
"${PKG}"
.PHONY: staple
staple:
xcrun stapler staple "${PKG}"
.PHONY: image
image: ${PKG_DMG}