forked from pointfreeco/isowords
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
363 lines (291 loc) · 10.5 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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
ifeq (.private,$(wildcard .private))
PRIVATE = 1
endif
bootstrap: bootstrap-client bootstrap-server
homebrew: homebrew-client homebrew-server
test: test-client build-client-preview-apps test-server
clean: clean-client clean-server
# client
bootstrap-client: check-dependencies-client audio fonts words-import words-import-sqlite secrets
check-dependencies-client:
ifdef PRIVATE
@$(MAKE) homebrew-client
else
@echo " ⚠️ Checking for Git LFS..."
@command -v git-lfs >/dev/null || (echo "$$GITLFS_ERROR_INSTALL" && exit 1)
@command -v git config --get-regexp filter.lfs >/dev/null 2>&1 \
|| (echo "$$GITLFS_ERROR_INSTALL_2" && exit 1)
@echo " ✅ Git LFS is good to go!"
@git lfs pull
endif
PLATFORM_IOS = iOS Simulator,name=iPhone 13 Pro,OS=15.4
test-client:
@xcodebuild test \
-project App/isowords.xcodeproj \
-scheme isowords \
-destination platform="$(PLATFORM_IOS)"
build-client-preview-apps:
@xcodebuild \
-project App/isowords.xcodeproj \
-list
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme CubeCorePreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme CubePreviewPreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme GameOverPreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme HomeFeaturePreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme LeaderboardsPreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme OnboardingPreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme SettingsPreview \
-destination platform="$(PLATFORM_IOS)"
@xcodebuild \
-project App/isowords.xcodeproj \
-scheme UpgradeInterstitialPreview \
-destination platform="$(PLATFORM_IOS)"
clean-client: clean-audio
homebrew-client: homebrew-shared
@brew ls ffmpeg --versions || brew install ffmpeg
audio: audio-clean audio-touch audio-download audio-sounds audio-music
audio-clean:
@rm -rf Assets/Audio/
@rm -f Sources/AppAudioLibrary/Resources/*
@rm -f Sources/AppClipAudioLibrary/Resources/*
@mkdir -p Sources/AppAudioLibrary/Resources/
@mkdir -p Sources/AppClipAudioLibrary/Resources/
AUDIO_URL = $(shell heroku config:get AUDIO_URL -a isowords-staging)
audio-download:
ifdef PRIVATE
@curl -o Audio.zip $(AUDIO_URL)
@unzip Audio.zip -d Assets/
@rm Audio.zip
endif
audio-touch:
@touch Sources/AppAudioLibrary/Resources/empty.mp3
@touch Sources/AppClipAudioLibrary/Resources/empty.mp3
audio-sounds:
ifdef PRIVATE
@for file in Assets/Audio/Sounds/App/*.wav; \
do \
filename=`basename $$file .wav`; \
echo Converting $$filename...; \
ffmpeg -y -v 0 -i $$file -vn -ar 44100 -ac 2 -b:a 64k Sources/AppAudioLibrary/Resources/$${filename}.mp3; \
done
@for file in Assets/Audio/Sounds/Core/*.wav; \
do \
filename=`basename $$file .wav`; \
echo Converting $$filename...; \
ffmpeg -y -v 0 -i $$file -vn -ar 44100 -ac 2 -b:a 32k Sources/AppClipAudioLibrary/Resources/$${filename}.mp3; \
done
endif
audio-music:
ifdef PRIVATE
@for file in Assets/Audio/Music/App/*.wav; \
do \
filename=`basename $$file .wav`; \
echo Converting $$filename...; \
ffmpeg -y -v 0 -i $$file -vn -ar 44100 -ac 2 -b:a 64k Sources/AppAudioLibrary/Resources/$${filename}.mp3; \
done
@for file in Assets/Audio/Music/Core/*.wav; \
do \
filename=`basename $$file .wav`; \
echo Converting $$filename...; \
ffmpeg -y -v 0 -i $$file -vn -ar 44100 -ac 2 -b:a 32k Sources/AppClipAudioLibrary/Resources/$${filename}.mp3; \
done
endif
clean-audio:
@rm -f Sources/AppAudioLibrary/Resources/*.wav
@rm -f Sources/AppClipAudioLibrary/Resources/*.wav
@mkdir -p Sources/AppAudioLibrary/Resources/
@mkdir -p Sources/AppClipAudioLibrary/Resources/
FONTS_URL = $(shell heroku config:get FONTS_URL -a isowords-staging)
fonts:
ifdef PRIVATE
@rm -f Sources/Styleguide/Fonts/*
@curl -o fonts.zip $(FONTS_URL)
@unzip fonts.zip -d Sources/Styleguide/Fonts/
@rm -f fonts.zip
else
@touch Sources/Styleguide/Fonts/empty.otf
endif
DICTIONARY_URL = $(shell heroku config:get DICTIONARY_URL -a isowords-staging)
DICTIONARY_GZIP = Sources/DictionaryFileClient/Dictionaries/Words.en.txt.gz
words-import:
@rm -f $(DICTIONARY_GZIP)
ifdef PRIVATE
@curl -o $(DICTIONARY_GZIP) $(DICTIONARY_URL)
else
@echo -e "CUBES\nREMOVES" \
| cat - /usr/share/dict/words \
| tr a-z A-Z \
| sort -u \
| grep '^[A-Z]\{3,\}$$' \
| gzip > $(DICTIONARY_GZIP)
endif
DICTIONARY_DB = Sources/DictionarySqliteClient/Dictionaries/Words.en.db
words-import-sqlite: words-import
@rm -f $(DICTIONARY_DB)
@gunzip --stdout $(DICTIONARY_GZIP) \
| sqlite3 \
--init Bootstrap/sqlite-words-import.sql \
$(DICTIONARY_DB)
secrets:
ifdef PRIVATE
@echo "// This is generated by \`make secrets\`. Don't edit.\nlet secrets = \"$$(heroku config:get SECRETS -a isowords-staging)\"" > Sources/ApiClientLive/Secrets.swift
else
@cp Sources/ApiClientLive/Secrets.swift.example Sources/ApiClientLive/Secrets.swift
endif
# server
bootstrap-server: check-dependencies-server
check-dependencies-server:
ifdef PRIVATE
@$(MAKE) homebrew-server
else
@echo " ⚠️ Checking on PostgreSQL..."
@command -v psql >/dev/null || (echo "$$POSTGRES_ERROR_INSTALL" && exit 1)
@psql template1 --command '' 2>/dev/null || \
(echo "$$POSTGRES_ERROR_RUNNING" && exit 1)
@echo " ✅ PostgreSQL is up and running!"
@psql --dbname=isowords_development --username=isowords --command '' \
2>/dev/null || (echo "$$POSTGRES_WARNING" && $(MAKE) --quiet db)
endif
test-server:
@TEST_SERVER=1 swift test
run-server-linux:
@docker-compose \
--file Bootstrap/development-compose.yml \
--project-directory . \
up \
--build
test-server-linux:
docker run --rm -v "$(PWD):$(PWD)" -w "$(PWD)" swift:5.5 bash Bootstrap/test.sh
clean-server: clean-db
homebrew-server: homebrew-shared
@brew ls postgresql@12 --versions || brew install postgresql@12
@if test "$(PRIVATE)" != ""; then \
brew tap heroku/brew; \
brew ls heroku --versions || brew install heroku; \
fi
db:
@createuser --superuser isowords || true
@psql template1 -c "ALTER USER isowords PASSWORD 'isowords';"
@createdb --owner isowords isowords_development || true
@createdb --owner isowords isowords_test || true
clean-db:
@dropdb --username isowords isowords_development || true
@dropdb --username isowords isowords_test || true
@dropuser isowords || true
env-example:
@cp Bootstrap/iso-env-example .iso-env
# shared
homebrew-shared:
@brew ls git-lfs --versions || brew install git-lfs
# private
private: .private
.private:
touch .private
HEROKU_NAME = isowords-staging
HEROKU_VERSION = $(shell heroku releases -a isowords -n 1 | tail -1 | sed -n -e 's/\(v[0-9]*\).*/\1/p')
deploy-server: check-porcelain
@git fetch origin
@test "$$(git status --porcelain)" = "" \
|| (echo " 🛑 Can't deploy while the working tree is dirty" && exit 1)
@test "$$(git rev-parse @)" = "$$(git rev-parse origin/main)" \
&& test "$$(git rev-parse --abbrev-ref HEAD)" = "main" \
|| (echo " 🛑 Must deploy from an up-to-date origin/main" && exit 1)
@heroku container:login
@cd Bootstrap && heroku container:push web --context-path .. -a $(HEROKU_NAME)
@heroku container:release web -a $(HEROKU_NAME)
@git tag -a "$(HEROKU_NAME)-deploy-$(HEROKU_VERSION)" -m "Deploy"
@git push origin main
@git push origin "$(HEROKU_NAME)-deploy-$(HEROKU_VERSION)"
archive-marketing: check-porcelain set-marketing-version archive
archive: bootstrap-client
@$(MAKE) bump-build
@cd App && xcodebuild -project isowords.xcodeproj -scheme "isowords" archive \
|| (git checkout . && echo " 🛑 Failed to build archive" && exit 1)
@git add . && git commit -m "Bumped version to $$(cd App && agvtool what-version -terse)"
@git tag -a "archive-$$(cd App && agvtool what-version -terse)" -m "Archive"
@git tag -a "$$(cd App && agvtool what-marketing-version -terse1)" -f -m "Marketing Version"
@git push origin main
@git push origin "archive-$$(cd App && agvtool what-version -terse)"
@git push origin "$$(cd App && agvtool what-marketing-version -terse1)"
set-marketing-version:
@cd App && agvtool new-marketing-version $(VERSION)
bump-build:
@cd App && xcrun agvtool next-version -all
check-porcelain:
@test "$(PRIVATE)" != "" || exit 1
@git fetch origin
@test "$$(git status --porcelain)" = "" \
|| (echo " 🛑 Can't proceed while the working tree is dirty" && exit 1)
@test "$$(git rev-parse @)" = "$$(git rev-parse origin/main)" \
&& test "$$(git rev-parse --abbrev-ref HEAD)" = "main" \
|| (echo " 🛑 Can only proceed from an up-to-date origin/main" && exit 1)
app-preview-iphone:
ffmpeg -i $(MP4) -acodec copy -crf 12 -vf scale=886:1920,setsar=1:1,fps=30 iphone.mp4
app-preview-ipad:
ffmpeg -i $(MP4) -acodec copy -crf 12 -vf crop=1200:1600,setsar=1:1,fps=30 ipad.mp4
env-staging:
@heroku config --json -a isowords-staging > .iso-env
ngrok:
@ngrok http -hostname=pointfreeco-localhost.ngrok.io 9876
format:
@swift format \
--ignore-unparsable-files \
--in-place \
--recursive \
./App/ \
./Package.swift \
./Sources/
loc:
find . -name '*.swift' | xargs wc -l | sort -nr
export GITLFS_ERROR_INSTALL
define GITLFS_ERROR_INSTALL
🛑 Git LFS is not installed! isowords stores its assets in Git LFS.
Install it with your favorite package manager, e.g.:
$$ \033[1mbrew\033[0m \033[38;5;66minstall git-lfs\033[0m
And run the following command before proceeding:
$$ \033[1mgit\033[0m \033[38;5;66mlfs install\033[0m
endef
export GITLFS_ERROR_INSTALL_2
define GITLFS_ERROR_INSTALL_2
🛑 Git LFS is not configured! isowords cannot fetch its assets.
Run the following command before proceeding:
$$ \033[1mgit\033[0m \033[38;5;66mlfs install\033[0m
endef
define POSTGRES_ERROR_INSTALL
🛑 PostgreSQL not found! The isowords backend depends on this.
Install it with your favorite package manager, e.g.:
$$ \033[1mbrew\033[0m \033[38;5;66minstall postgresql\033[0m
endef
export POSTGRES_ERROR_INSTALL
define POSTGRES_ERROR_RUNNING
🛑 PostgreSQL isn't running! The isowords backend depends on this.
Make sure it's spawned by running, e.g., if installed via Homebrew::
$$ \033[1mpg_ctl\033[0m \033[38;5;66m-D /usr/local/var/postgres start\033[0m
endef
export POSTGRES_ERROR_RUNNING
define POSTGRES_WARNING
⚠️ Local databases aren't configured! Creating isowords user/databases...
Reset at any time with:
$$ \033[1mmake\033[0m \033[38;5;66mclean-db\033[0m
endef
export POSTGRES_WARNING