+39
Makefile
+39
Makefile
···
1
+
.PHONY: clean test release
2
+
3
+
# Clean all build artifacts
4
+
clean:
5
+
go clean ./...
6
+
7
+
# Run tests
8
+
test:
9
+
go test -v ./...
10
+
11
+
# Create a new release
12
+
# - Ensures main branch has no uncommitted changes
13
+
# - Pushes main to origin if needed
14
+
# - Tags with version from svu next
15
+
# - Pushes tags to origin
16
+
release:
17
+
@# Ensure we're on main branch
18
+
@if [ "$$(git branch --show-current)" != "main" ]; then \
19
+
echo "Error: must be on main branch to release"; \
20
+
exit 1; \
21
+
fi
22
+
@# Ensure no uncommitted changes
23
+
@if [ -n "$$(git status --porcelain)" ]; then \
24
+
echo "Error: uncommitted changes present on main branch"; \
25
+
exit 1; \
26
+
fi
27
+
@# Push main to origin if needed
28
+
@if [ -n "$$(git log origin/main..main 2>/dev/null)" ]; then \
29
+
echo "Pushing main to origin..."; \
30
+
git push origin main; \
31
+
fi
32
+
@# Get new version from svu
33
+
$(eval VERSION := $(shell svu next))
34
+
@echo "Creating release $(VERSION)..."
35
+
@# Tag the current commit
36
+
git tag -a $(VERSION) -m "Release $(VERSION)"
37
+
@# Push the tag to origin
38
+
git push origin $(VERSION)
39
+
@echo "Released $(VERSION)"