-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (83 loc) · 3.37 KB
/
Copy pathMakefile
File metadata and controls
94 lines (83 loc) · 3.37 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
ARCH := $(shell uname -m)
GO_FILES := $(shell find . -name '*.go' -type f)
ACP_VERSION := $(file < ./schema/version)
GOCACHE ?= $(CURDIR)/.gocache
MDSH ?= mdsh
version: README.md schema/meta.json schema/schema.json schema/meta.unstable.json schema/schema.unstable.json
cd cmd/generate && env -u GOPATH -u GOMODCACHE go run .
gofumpt -w .
touch $@
echo $(ACP_VERSION) > $@
schema/meta.json: schema/version
curl -o $@ --fail -L https://github.com/agentclientprotocol/agent-client-protocol/releases/download/v$(ACP_VERSION)/meta.json
schema/schema.json: schema/version
curl -o $@ --fail -L https://github.com/agentclientprotocol/agent-client-protocol/releases/download/v$(ACP_VERSION)/schema.json
schema/meta.unstable.json: schema/version
@set -e; \
url=https://github.com/agentclientprotocol/agent-client-protocol/releases/download/v$(ACP_VERSION)/meta.unstable.json; \
tmp=$@.tmp; \
status=$$(curl -sS -L -o "$$tmp" -w '%{http_code}' "$$url") || { rm -f "$$tmp"; exit 1; }; \
if [ "$$status" = "200" ]; then \
mv "$$tmp" $@; \
elif [ "$$status" = "404" ]; then \
rm -f "$$tmp"; \
printf '%s\n' '{"agentMethods":{},"clientMethods":{},"protocolMethods":{}}' > $@; \
else \
rm -f "$$tmp"; \
echo "failed to download $$url (http $$status)" 1>&2; \
exit 1; \
fi
schema/schema.unstable.json: schema/version
@set -e; \
url=https://github.com/agentclientprotocol/agent-client-protocol/releases/download/v$(ACP_VERSION)/schema.unstable.json; \
tmp=$@.tmp; \
status=$$(curl -sS -L -o "$$tmp" -w '%{http_code}' "$$url") || { rm -f "$$tmp"; exit 1; }; \
if [ "$$status" = "200" ]; then \
mv "$$tmp" $@; \
elif [ "$$status" = "404" ]; then \
rm -f "$$tmp"; \
printf '%s\n' '{"$$defs":{}}' > $@; \
else \
rm -f "$$tmp"; \
echo "failed to download $$url (http $$status)" 1>&2; \
exit 1; \
fi
README.md: schema/version
@command -v $(MDSH) >/dev/null || { echo "mdsh not found; run 'mise install' or install it." 1>&2; exit 1; }
$(MDSH) --input README.md
.PHONY: fmt
fmt:
treefmt
# treefmt runs mdsh + mdformat over the markdown, which keeps README.md
# regenerated and in sync (replacing the old mdsh guard). mdsh and mdformat
# disagree on the blank line after an mdsh directive: mdsh strips it, mdformat
# re-adds it. The net result is a no-op (README is a fixpoint of the pair), but
# that intermediate churn trips treefmt's own --fail-on-change. So we format in
# place and let git confirm there's no net drift instead.
.PHONY: check
check:
treefmt
git diff --exit-code
.PHONY: test
test: $(GO_FILES)
GOFLAGS=$(GOFLAGS) GOCACHE=$(GOCACHE) go test ./...
GOFLAGS=$(GOFLAGS) GOCACHE=$(GOCACHE) go build ./example/...
.PHONY: clean
clean:
rm -f schema/meta.json schema/schema.json schema/meta.unstable.json schema/schema.unstable.json version
mdsh --clean --input README.md
touch schema/version # Touching the schema version file ensures that the README.md is regenerated on next make.
.PHONY: release
release:
@if [ -z "$(VERSION)" ]; then \
echo "VERSION is required (e.g. 'make release VERSION=0.4.4')" 1>&2; \
exit 1; \
fi
@printf '%s\n' "$(VERSION)" > schema/version
$(MAKE) version
$(MAKE) fmt
GOCACHE=$(GOCACHE) $(MAKE) test
$(MAKE) check
@cmp -s schema/version version || (echo "schema/version and version differ; rerun 'make version'" 1>&2; exit 1)
@echo
@echo "Release candidate for $(VERSION) is ready. Review changes, commit, then tag v$(VERSION)."