-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (103 loc) · 3.97 KB
/
Makefile
File metadata and controls
113 lines (103 loc) · 3.97 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
.PHONY: help version-bump release build test clean prepare prepare-cleanup
# Extract version from command line if passed as argument
# Supports: make release 0.2.0 OR make release VERSION=0.2.0
ifeq ($(VERSION),)
VERSION := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(VERSION):;@:)
endif
help:
@echo "Scrob Makefile"
@echo ""
@echo "Usage:"
@echo " make version-bump 0.2.0 - Bump version in Cargo.toml and commit"
@echo " make release 0.2.0 - Bump version and push tag to trigger release"
@echo " make build - Build release binary"
@echo " make test - Run tests"
@echo " make clean - Clean build artifacts"
@echo " make prepare - Update sqlx query cache (uses local postgres)"
@echo " make prepare-cleanup - Stop and remove local postgres container"
@echo ""
@echo "Examples:"
@echo " make version-bump 0.2.0 - Creates branch and bumps version"
@echo " make release 0.2.0 - Full release (merge, tag, push)"
@echo ""
@echo "Note: VERSION prefix is optional:"
@echo " make release 20251221.1 - Creates tag v20251221.1"
@echo " make release v20251221.1 - Creates tag v20251221.1 (same)"
# Bump version in Cargo.toml and commit on a branch
version-bump:
ifeq ($(VERSION),)
$(error No version specified. Use: make version-bump 0.2.0)
endif
$(eval VERSION_CLEAN := $(patsubst v%,%,$(VERSION)))
@echo "Creating release branch for version $(VERSION_CLEAN)..."
@git checkout -b release/v$(VERSION_CLEAN)
@echo "Bumping version to $(VERSION_CLEAN)..."
@sed -i 's/^version = .*/version = "$(VERSION_CLEAN)"/' Cargo.toml
@echo "Updating Cargo.lock..."
@cargo check --quiet 2>/dev/null || true
@git add Cargo.toml Cargo.lock
@git commit -m "chore: bump version to $(VERSION_CLEAN)"
@echo ""
@echo "✓ Created branch release/v$(VERSION_CLEAN)"
@echo "✓ Version bumped to $(VERSION_CLEAN)"
@echo "✓ Commit created"
@echo ""
@echo "To merge, tag, and push:"
@echo " make release $(VERSION)"
# Merge to main, tag, and push to trigger GitHub Actions release
release: version-bump
$(eval VERSION_CLEAN := $(patsubst v%,%,$(VERSION)))
@echo "Merging into main..."
@git checkout main
@git moff release/v$(VERSION_CLEAN)
@echo "Creating tag v$(VERSION_CLEAN) on main..."
@git tag -a v$(VERSION_CLEAN) -m "Release v$(VERSION_CLEAN)"
@echo "Pushing to origin..."
@git push origin main
@git push origin v$(VERSION_CLEAN)
@echo ""
@echo "✓ Merged release/v$(VERSION_CLEAN) into main"
@echo "✓ Created tag v$(VERSION_CLEAN) on main"
@echo "✓ Pushed to main"
@echo "✓ Pushed tag v$(VERSION_CLEAN)"
@echo "✓ GitHub Actions will build release binaries"
# Build release binary
build:
cargo build --release
# Run tests
test:
cargo test
# Run clippy
clippy:
cargo clippy
# Clean build artifacts
clean:
cargo clean
# Update sqlx query cache using local postgres
prepare:
@echo "Starting local postgres container..."
@docker rm -f scrob-postgres 2>/dev/null || true
@docker run -d --name scrob-postgres \
-e POSTGRES_PASSWORD=scrob \
-e POSTGRES_USER=scrob \
-e POSTGRES_DB=scrob \
-p 5433:5432 \
postgres:16-alpine
@echo "Waiting for postgres to be ready..."
@sleep 3
@docker exec scrob-postgres pg_isready -U scrob || (sleep 2 && docker exec scrob-postgres pg_isready -U scrob)
@echo "Running migrations..."
@DATABASE_URL="postgres://scrob:scrob@localhost:5433/scrob" cargo sqlx migrate run
@echo "Preparing sqlx query cache..."
@DATABASE_URL="postgres://scrob:scrob@localhost:5433/scrob" cargo sqlx prepare
@echo "Stopping postgres container..."
@docker rm -f scrob-postgres
@echo ""
@echo "✓ Query cache updated in .sqlx/"
@echo "✓ Remember to commit the updated .sqlx files"
# Stop and remove local postgres container
prepare-cleanup:
@echo "Stopping and removing postgres container..."
@docker rm -f scrob-postgres 2>/dev/null || true
@echo "✓ Cleanup complete"