forked from Jaysce/Spaceman
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
179 lines (139 loc) · 7.06 KB
/
Copy pathMakefile
File metadata and controls
179 lines (139 loc) · 7.06 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
SHELL = /bin/bash
PROJECT = Spaceman
APPNAME = $(PROJECT).app
BUILDDIR = build
ARCHIVE = $(BUILDDIR)/$(PROJECT).xcarchive
IMAGEDIR = $(BUILDDIR)/diskimage
APPFILE = $(IMAGEDIR)/$(APPNAME)
PBXPROJ = $(PROJECT).xcodeproj/project.pbxproj
VERSION = $(shell awk -F'["; ]*' '/MARKETING_VERSION/ { print $$3; exit }' $(PBXPROJ))
IMAGE = $(BUILDDIR)/$(PROJECT)-$(VERSION).dmg
RCDIR = ~/.spaceman
AUTHOR = ruittenb
DOMAIN = dev.$(AUTHOR).$(PROJECT)
BREWDIR = $(shell brew --repo $(AUTHOR)/tap)
DATE := $(shell date +"%Y-%m-%dT%H:%M:%S%z")
.DEFAULT_GOAL := help
.PHONY: help # See https://tinyurl.com/makefile-autohelp
help: ## Print help for each target
@awk -v tab=17 'BEGIN{FS="(:.*## |##@ |@## )";c="\033[36m";m="\033[0m";y=" ";a=2;h()}function t(s){gsub(/[ \t]+$$/,"",s);gsub(/^[ \t]+/,"",s);return s}function u(g,d){split(t(g),f," ");for(j in f)printf"%s%s%-"tab"s%s%s\n",y,c,t(f[j]),m,d}function h(){printf"\nUsage:\n%smake %s<target>%s\n\nRecognized targets:\n",y,c,m}/\\$$/{gsub(/\\$$/,"");b=b$$0;next}b{$$0=b$$0;b=""}/^[-a-zA-Z0-9*\/%_. ]+:.*## /{p=sprintf("\n%"(tab+a)"s"y,"");gsub(/\\n/,p);if($$1~/%/&&$$2~/^%:/){n=split($$2,q,/%:|:% */);for(i=2;i<n;i+=2){g=$$1;sub(/%/,q[i],g);u(g,q[i+1])}}else if($$1~/%/&&$$2~/%:[^%]+:[^%]+:%/){d=$$2;sub(/^.*%:/,"",d);sub(/:%.*/,"",d);n=split(d,q,/:/);for(i=1;i<=n;i++){g=$$1;d=$$2;sub(/%/,q[i],g);sub(/%:[^%]+:%/,q[i],d);u(g,d)}}else u($$1,$$2)}/^##@ /{gsub(/\\n/,"\n");if(NF==3)tab=$$2;printf"\n%s\n",$$NF}END{print""}' $(MAKEFILE_LIST) # v1.62
.PHONY: translations
translations: ## Update and complete all translations
claude -p "Bring the .xcstrings file up to date, if necessary. Use the skill file .claude/skills/translations.md"
.PHONY: test
test: ## Run unit tests
set -o pipefail && \
xcodebuild test -project $(PROJECT).xcodeproj -scheme $(PROJECT) -destination platform=macOS | \
xcbeautify --quiet
.PHONY: lint
lint: ## Check source code style
swiftlint lint Spaceman --no-cache
.PHONY: build
build: $(ARCHIVE) ## Make the archive file
$(ARCHIVE): $(PBXPROJ)
set -o pipefail && \
xcodebuild -project $(PROJECT).xcodeproj -scheme $(PROJECT) -configuration Release clean archive -archivePath $(ARCHIVE) | \
xcbeautify
.PHONY: run
run: ## Start the most recently compiled application bundle
open ~/Library/Developer/Xcode/DerivedData/$(PROJECT)-*/Build/Products/Debug/$(PROJECT).app || \
open /Applications/$(PROJECT).app
.PHONY: export
export: $(APPFILE) ## Make the app file
$(APPFILE): $(ARCHIVE)
xcodebuild -exportArchive -archivePath $(ARCHIVE) -exportOptionsPlist $(PROJECT)/exportOptions.plist -exportPath $(IMAGEDIR)
@test -d "$(APPFILE)" || { echo $$'\nExport failed: "$(APPFILE)" not found. Check code signing or exportOptions.plist.'; exit 1; }
.PHONY: image
image: $(IMAGE) ## Make the dmg image file
$(IMAGE): $(APPFILE)
create-dmg \
--volname "Spaceman Installer" \
--volicon $(IMAGEDIR)/.VolumeIcon.icns \
--background $(IMAGEDIR)/.background/folder-background.png \
--window-pos 200 120 \
--window-size 640 440 \
--icon-size 128 \
--icon Spaceman.app 150 170 \
--icon Applications 490 170 \
--hide-extension Spaceman.app \
--app-drop-link 490 170 \
--no-internet-enable \
$(IMAGE) \
$(IMAGEDIR) # source folder
.PHONY: all
all: image ## Make all of the above
##@ Publishing:
.PHONY: tag
tag: ## Tag the current HEAD with the version from the XCode project
git tag v$(VERSION)
git push --tags
.PHONY: release
release: ## Open Github webpage for creating a release
open https://github.com/ruittenb/Spaceman/releases/new
.PHONY: appcast
appcast: ## Prepare appcast for publishing
@echo 'Make sure to create a release on github first!'
git checkout main
$(BUILDDIR)/make-appcast.sh > website/appcast.xml
git add website/appcast.xml
@printf "\nCreated appcast.xml, now please commit it\n"
.PHONY: publish
publish: ## Publish the main branch appcast on Github Pages
git subtree push --prefix website origin main:github-pages
.PHONY: publish-force
# git subtree split --prefix website -b github-pages # create a local github-pages branch containing the splitted output folder
# git push -f origin github-pages:github-pages # force push the github-pages branch to origin
publish-force: ## Publish the main branch appcast on Github Pages (force push)
git checkout main
git push --force-with-lease origin `git subtree split --prefix website main`:github-pages
##@ Homebrew:
.PHONY: brew-update
brew-update: ## Update the spaceman.rb file with the correct version
@cd $(BREWDIR)/Casks && \
awk -v version=$(VERSION) -v shaout="$(shell shasum -a 256 $(IMAGE))" ' \
/version "[-0-9.alph]*"/ { \
print " version \"" version "\""; next \
} \
/sha256/ { \
split(shaout, sha); \
print " sha256 \"" sha[1] "\""; next \
} { \
print \
}' < spaceman.rb | tee /dev/tty > spaceman.rb.new && \
mv spaceman.rb.new spaceman.rb
@echo "Please verify the file spaceman.rb and run 'make brew-publish'"
.PHONY: brew-publish
brew-publish: ## Publish the new spaceman.rb so that homebrew can find it
cd $(BREWDIR) && \
git commit Casks -m "Version $(VERSION)" && \
git push
##@ Continuous Integration:
.PHONY: test-ci
test-ci: ## Run unit tests (on GitHub)
set -o pipefail && \
xcodebuild test -project $(PROJECT).xcodeproj -scheme $(PROJECT) -destination platform=macOS \
CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" | \
xcbeautify --quiet
.PHONY: lint-ci
lint-ci: ## Check source code style (on GitHub)
swiftlint lint Spaceman --reporter github-actions-logging --no-cache
##@ Documentation:
.PHONY: setup-pillow
setup-pillow: ## Install Pillow, requirement for scripts/add-background.py
pip3 install Pillow
##@ Defaults:
.PHONY: defaults-clear
defaults-clear: ## Clear app defaults
defaults delete $(DOMAIN)
.PHONY: defaults-get
defaults-get: ## Show stored app defaults
@defaults read $(DOMAIN) # spaceNameCache
@swift scripts/show-space-defaults.swift
.PHONY: defaults-export
defaults-export: ## Backup app defaults to xml file
mkdir -p $(RCDIR)
defaults export $(DOMAIN) - > $(RCDIR)/app-defaults.xml
cp $(RCDIR)/app-defaults.xml $(RCDIR)/app-defaults-$(DATE).xml
.PHONY: defaults-import
defaults-import: ## Restore app defaults from xml file
defaults import $(DOMAIN) - < $(RCDIR)/app-defaults.xml