-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
46 lines (37 loc) · 1.49 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
SHELL = /bin/sh
dir := $(notdir $(CURDIR))
dist_files := $(wildcard classes controllers css/*.* js/*.* LICENSE translations views *.php *.png)
.PHONY: help test lint publish
help:
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-15s\033[0m %s\n", $$1, $$2}' \
| sed -e 's/\[32m##/[33m/'
test: ## Run tests.
#composer validate --strict
find . classes -maxdepth 1 -name \*.php -type f -exec php -l '{}' \;
vendor/bin/phpunit --log-junit phpunit/junit.xml tests
npm test
lint: ## Detect coding style errors (pass FIX=1 to fix them).
vendor/bin/php-cs-fixer fix --stop-on-violation $(if $(FIX),-n -q,-v --dry-run --diff)
npm run lint $(if $(FIX), '--fix',) js/src/
publish: $(dir).zip $(dir).tar.gz ## Publish new release on Github.
token=`cat .github-token` \
&& version=`git describe` \
&& upload_url=`curl \
-H "Authorization: token $$token" \
-d '{"tag_name": "'$$version'"}' \
https://api.github.com/repos/creativewave/ps-$(dir)/releases \
| grep -Po 'upload_url": "\K[^{]+'` \
&& curl --data-binary @$< \
-H "Authorization: token $$token" \
-H 'Content-Type: application/octet-stream' \
"$$upload_url?name=$<&label=$<" \
&& curl --data-binary @$(filter-out $<,$^) \
-H "Authorization: token $$token" \
-H 'Content-Type: application/octet-stream' \
"$$upload_url?name=$(filter-out $<,$^)&label=$(filter-out $<,$^)" \
&& rm -f $+
$(dir).zip: $(dist_files)
zip -r $@ $+
$(dir).tar.gz: $(dist_files)
tar -zcf $@ $+