-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
112 lines (89 loc) · 2.58 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
MODULE_DIRS := $(wildcard modules/* )
SRC_DIR := .
BUILD_DIR := $(SRC_DIR)/build
DIST_DIR := $(BUILD_DIR)/dist
RELEASE_DIR := $(BUILD_DIR)/release
BUILD_ENV := 'dev'
RELEASE_VERSION := dev
# List all files in the source directory, including dot files
FILES := $(wildcard $(SRC_DIR)/*) $(wildcard $(SRC_DIR)/.[!.]*)
# Exclude the special entries . and .. from the list of files
FILES := $(filter-out $(SRC_DIR)/. $(SRC_DIR)/.., $(FILES))
# List files to exclude, including DIST_DIR
EXCLUDED_FILES := ./wordpress
EXCLUDED_FILES += $(BUILD_DIR)
# Exclude files listed in EXCLUDED_FILES from FILES
FILES := $(filter-out $(EXCLUDED_FILES), $(FILES))
.PHONY: all \
build \
install \
install-php \
i18n \
i18n-makepot \
qa \
scan \
test \
test-php \
$(MODULE_DIRS)
include .env
all: build
build: install
$(MAKE) build-modules
$(MAKE) i18n
wait
clean:
rm -rf $(DIST_DIR)
dist: copy_dist
$(MAKE) -C $(DIST_DIR) build BUILD_ENV=${BUILD_ENV}
release: BUILD_ENV := prod
release: dist
@mkdir -p $(RELEASE_DIR)
rm -r $(DIST_DIR)/.gitignore
git -C $(DIST_DIR) config user.email "[email protected]"; \
git -C $(DIST_DIR) config user.name "Automation"; \
RELEASE_VERSION=$(shell echo $(RELEASE_VERSION)); \
$$(git -C $(DIST_DIR) add --all); \
RELEASE_REF=$$(git -C $(DIST_DIR) stash create); \
RELEASE_REF=$$(echo "$${RELEASE_REF}" | cut -c 1-12); \
if [ -z "$${RELEASE_REF}" ]; then \
RELEASE_REF=$$(git -C $(DIST_DIR) rev-parse HEAD); \
RELEASE_REF=$${RELEASE_REF:0:12}; \
fi; \
TIMESTAMP=$$(date -u +"%Y-%m-%d-%H-%M-%S"); \
if [ -n "$${RELEASE_VERSION}" ]; then \
RELEASE_META=$${RELEASE_VERSION}+$${TIMESTAMP}_$${RELEASE_REF}; \
else \
RELEASE_META=$${TIMESTAMP}_$${RELEASE_REF}; \
fi; \
ARCHIVE_FILENAME=$(PLUGIN_NAME)-$${RELEASE_META}.zip; \
git -C $(DIST_DIR) archive --format=zip --prefix=$(PLUGIN_NAME)/ $$RELEASE_REF >$(RELEASE_DIR)/$${ARCHIVE_FILENAME}
copy_dist: clean
@mkdir -p $(DIST_DIR)
cp -r $(FILES) $(DIST_DIR)
build-modules: $(MODULE_DIRS)
$(MODULE_DIRS):
@if [ -f "$@/Makefile" ]; then echo "$@/Makefile exists!"; $(MAKE) -C $@ build BUILD_ENV=${BUILD_ENV}; fi
install:
$(MAKE) install-php
install-php: composer.lock
if [ "$(BUILD_ENV)" = "prod" ]; then \
composer install --no-dev --optimize-autoloader; \
else \
composer install; \
fi
i18n: i18n-makepot i18n-makemo
i18n-makepot:
wp i18n make-pot . $(LANGS_PATH)/strings.pot --allow-root
i18n-makemo:
wp i18n make-mo $(LANGS_PATH) --allow-root
qa:
$(MAKE) test
$(MAKE) scan
wait
test:
$(MAKE) test-php
test-php:
vendor/bin/phpunit
scan:
vendor/bin/psalm
vendor/bin/phpcs -s