-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (63 loc) · 3.24 KB
/
Makefile
File metadata and controls
70 lines (63 loc) · 3.24 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
.PHONY: build test lint run clean release marketplace-sync
build:
go build -o visor ./cmd/visor
test:
go test ./...
lint:
golangci-lint run
run:
go run ./cmd/visor
clean:
rm -f visor
release: # macOS only (sed -i '' syntax)
ifndef VERSION
$(error VERSION is required. Usage: make release VERSION=x.y.z)
endif
@echo "$(VERSION)" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$$' || \
(echo "Error: VERSION must be SemVer (X.Y.Z), got '$(VERSION)'" && exit 1)
@git diff --cached --quiet || (echo "Error: staged changes exist. Commit or reset first." && exit 1)
@PLUGIN_VER=$$(jq -r '.version' .claude-plugin/plugin.json); \
CHANGELOG_VER=$$(awk '/^## \[[0-9]/ {gsub(/[\[\]]/, "", $$2); print $$2; exit}' CHANGELOG.md); \
if [ "$$PLUGIN_VER" != "$$CHANGELOG_VER" ]; then \
echo "Error: version mismatch — plugin.json=$$PLUGIN_VER, CHANGELOG.md=$$CHANGELOG_VER"; exit 1; \
fi
@echo "==> Bumping version to $(VERSION)..."
@sed -i '' 's/"version": "[^"]*"/"version": "$(VERSION)"/' .claude-plugin/plugin.json
@PREV=$$(awk '/^\[Unreleased\]:/ { sub(/.*compare\/v/, ""); sub(/\.\.\.HEAD.*/, ""); print }' CHANGELOG.md); \
if [ -z "$$PREV" ]; then echo "Error: could not extract previous version from CHANGELOG.md"; exit 1; fi; \
sed -i '' "s|compare/v$$PREV\.\.\.HEAD|compare/v$(VERSION)...HEAD|" CHANGELOG.md; \
awk -v new="[$(VERSION)]: https://github.com/namyoungkim/visor/compare/v$$PREV...v$(VERSION)" \
'/^\[Unreleased\]:/ { print; print new; next } 1' CHANGELOG.md > CHANGELOG.md.tmp && \
mv CHANGELOG.md.tmp CHANGELOG.md
@git add .claude-plugin/plugin.json CHANGELOG.md
@git commit -m "chore: bump version to $(VERSION)"
@git tag -a "v$(VERSION)" -m "v$(VERSION)"
@echo ""
@echo "==> Done! Version $(VERSION) committed and tagged."
@echo "==> To publish, run:"
@echo " git push origin main && git push origin v$(VERSION)"
@$(MAKE) marketplace-sync VERSION=$(VERSION)
marketplace-sync: # Create PR in leo-claude-plugin to sync marketplace.json
ifndef VERSION
$(error VERSION is required. Usage: make marketplace-sync VERSION=x.y.z)
endif
@echo "==> Syncing marketplace..."
@gh api repos/namyoungkim/leo-claude-plugin/git/refs/heads/chore/bump-visor-v$(VERSION) -X DELETE 2>/dev/null || true
@MARKET_SHA=$$(gh api repos/namyoungkim/leo-claude-plugin/contents/.claude-plugin/marketplace.json --jq '.sha'); \
MAIN_SHA=$$(gh api repos/namyoungkim/leo-claude-plugin/git/ref/heads/main --jq '.object.sha'); \
gh api repos/namyoungkim/leo-claude-plugin/git/refs -X POST \
-f ref="refs/heads/chore/bump-visor-v$(VERSION)" \
-f sha="$$MAIN_SHA" > /dev/null; \
UPDATED=$$(gh api repos/namyoungkim/leo-claude-plugin/contents/.claude-plugin/marketplace.json \
--jq '.content' | base64 -d | \
jq --arg v "$(VERSION)" '(.plugins[] | select(.name == "visor")).version = $$v' | base64 -b 0); \
gh api repos/namyoungkim/leo-claude-plugin/contents/.claude-plugin/marketplace.json -X PUT \
-f message="chore: bump visor to v$(VERSION)" \
-f content="$$UPDATED" \
-f sha="$$MARKET_SHA" \
-f branch="chore/bump-visor-v$(VERSION)" > /dev/null; \
gh pr create --repo namyoungkim/leo-claude-plugin \
--head "chore/bump-visor-v$(VERSION)" \
--title "chore: bump visor to v$(VERSION)" \
--body "Automated version sync from visor release."
@echo "==> Marketplace PR created."