-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
64 lines (51 loc) · 1.83 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
# Zip distribution
ADDONS_DIR = addons/lua-gdextension
ADDONS_SRC = $(shell find $(ADDONS_DIR) -type f)
COPIED_FILES = LICENSE
# Testing
GODOT_BIN ?= godot
# Download releases
GITHUB_CLI_BIN ?= gh
GITHUB_REPO ?= gilzoide/lua-gdextension
RUN_ID ?=
# Update version
define UPDATE_CHANGELOG_VERSION_SED_SCRIPT
/Unreleased/ {
s/Unreleased/$(VERSION)/
s/compare[^)]*/releases\/tag\/$(VERSION)/
i \#\# [Unreleased](https://github.com/gilzoide/lua-gdextension/compare/$(VERSION)...HEAD)
i
i
}
endef
define UPDATE_README_VERSION_SED_SCRIPT
/logo=godotengine/ {
s/message=[^)]*/message=$(VERSION)/
}
endef
$(ADDONS_DIR)/%: %
cp $< $@
build:
mkdir -p $@
build/lua-gdextension.zip: $(ADDONS_SRC) $(addprefix $(ADDONS_DIR)/,$(COPIED_FILES)) | build
zip $@ $^
build/update_changelog_version.sed:
@if [[ -z "$(VERSION)" ]]; then echo "Error: please set the VERSION variable"; false; fi
$(file > $@,$(UPDATE_CHANGELOG_VERSION_SED_SCRIPT))
build/update_readme_version.sed:
@if [[ -z "$(VERSION)" ]]; then echo "Error: please set the VERSION variable"; false; fi
$(file > $@,$(UPDATE_README_VERSION_SED_SCRIPT))
test/.godot:
$(GODOT_BIN) --headless --quit --path test --editor || true
.PHONY: zip test download-latest-build bump-version build/update_changelog_version.sed
zip: build/lua-gdextension.zip
test: test/.godot
$(GODOT_BIN) --headless --quit --path test --script test_entrypoint.gd
download-latest-build:
$(eval TMPDIR := $(shell mktemp -d))
$(GITHUB_CLI_BIN) run download $(RUN_ID) --repo $(GITHUB_REPO) -n lua-gdextension -D $(TMPDIR)
cp $(TMPDIR)/addons/lua-gdextension/build/libluagdextension* addons/lua-gdextension/build
$(RM) -r $(TMPDIR)
bump-version: build/update_changelog_version.sed build/update_readme_version.sed
sed -i CHANGELOG.md -f build/update_changelog_version.sed
sed -i README.md -f build/update_readme_version.sed