-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (66 loc) · 2.23 KB
/
Makefile
File metadata and controls
73 lines (66 loc) · 2.23 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
.PHONY: version status check-ready-to-release release
# Read VERSION file
VERSION := $(shell cat VERSION 2>/dev/null | tr -d '[:space:]')
# Extract base version (remove -dev suffix) - uses shell parameter expansion
VERSION_BASE := $(shell v="$(VERSION)"; echo "$${v%-dev}")
# Get latest tag (remove 'v' prefix)
LATEST_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "0.0.0")
TAG := v$(VERSION_BASE)
# Show version status
status:
@echo "================================"
@echo "Version Status"
@echo "================================"
@echo "VERSION file: $(VERSION)"
@echo "Latest git tag: $(LATEST_TAG)"
@echo ""
@if [ "$(VERSION_BASE)" = "$(LATEST_TAG)" ]; then \
case "$(VERSION)" in \
*-dev) \
echo "Status: ⚠️ Development version matches released tag"; \
echo "Action: 🔖 Bump to next version"; \
;; \
*) \
echo "Status: ✅ At release (VERSION matches tag)"; \
echo "Action: 🔖 Tag this commit or bump to next dev version"; \
;; \
esac \
elif [ "$(VERSION_BASE)" \> "$(LATEST_TAG)" ]; then \
echo "Status: 📝 Development in progress"; \
echo "Action: 💻 Continue developing or prepare release"; \
else \
echo "Status: ❌ ERROR - VERSION behind tag!"; \
fi
@echo "================================"
# Check if ready to release
check-ready-to-release:
@case "$(VERSION)" in \
*-dev) \
echo "❌ VERSION contains -dev suffix: $(VERSION)"; \
echo "Remove -dev before releasing:"; \
echo " echo '$(VERSION_BASE)' > VERSION"; \
exit 1; \
;; \
esac
@if [ "$(VERSION_BASE)" = "$(LATEST_TAG)" ]; then \
echo "❌ VERSION $(VERSION) already released (tag v$(LATEST_TAG) exists)"; \
echo "Bump version first:"; \
echo " echo 'X.Y.Z' > VERSION"; \
exit 1; \
fi
@if git rev-parse "$(TAG)" >/dev/null 2>&1; then \
echo "❌ Tag $(TAG) already exists"; \
exit 1; \
fi
@echo "✅ Ready to release version $(VERSION)"
# Create release
release: check-ready-to-release
@echo "Creating release $(TAG)..."
@git tag -a "$(TAG)" -m "Release $(TAG)"
@echo "✅ Created tag: $(TAG)"
@echo ""
@echo "Push with:"
@echo " git push origin main --follow-tags"
@echo ""
@echo "After pushing, bump to next dev version:"
@echo " echo 'X.Y.Z-dev' > VERSION"