-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
221 lines (200 loc) · 8.52 KB
/
Copy pathMakefile
File metadata and controls
221 lines (200 loc) · 8.52 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
CARGO_TOML := Cargo.toml
# Extract version from Cargo.toml
define get_version
$(shell grep -m1 '^version' $(CARGO_TOML) | sed 's/.*"\(.*\)".*/\1/')
endef
# Update version in Cargo.toml
define update_version
sed -i 's/^version = ".*"/version = "$(1)"/' $(CARGO_TOML)
endef
.PHONY: create_tag update-patch update-minor update-major prepare-release release release-patch release-minor release-major explorer build check clippy fmt-check test e2e
# Build the React/Vite Explorer SPA bundle. The served index.html is
# this bundle; crates/reqvire-core/build.rs embeds explorer/dist at compile time, so this must
# run before `cargo build` for the real bundle to be embedded.
explorer:
@echo "Building Explorer SPA bundle..."
cd explorer && npm ci && npm run build
# Build the Explorer bundle, then the Rust workspace (so the bundle is embedded).
build: explorer
cargo build
# Run cargo check across the workspace.
check:
cargo check --workspace
# Run clippy with workspace lint configuration.
clippy:
cargo clippy --workspace --all-targets
# Check formatting without modifying files.
fmt-check:
cargo fmt --all -- --check
# Run the Rust test suite.
test:
cargo test --workspace
# Run end-to-end shell-based test suite.
e2e:
bash tests/run_all.sh
# Version update targets
update-patch:
@echo "Updating patch version..."
$(eval CURRENT_VERSION := $(call get_version))
$(eval NEW_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$3=$$3+1} 1' OFS=.))
$(call update_version,$(NEW_VERSION))
@echo "Version updated from $(CURRENT_VERSION) to $(NEW_VERSION)"
update-minor:
@echo "Updating minor version..."
$(eval CURRENT_VERSION := $(call get_version))
$(eval NEW_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$2=$$2+1; $$3=0} 1' OFS=.))
$(call update_version,$(NEW_VERSION))
@echo "Version updated from $(CURRENT_VERSION) to $(NEW_VERSION)"
update-major:
@echo "Updating major version..."
$(eval CURRENT_VERSION := $(call get_version))
$(eval NEW_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$1=$$1+1; $$2=0; $$3=0} 1' OFS=.))
$(call update_version,$(NEW_VERSION))
@echo "Version updated from $(CURRENT_VERSION) to $(NEW_VERSION)"
# Prepare release: update Cargo.lock without --locked flag
prepare-release:
@echo "Preparing release..."
$(eval VERSION := $(call get_version))
@echo "Current version: $(VERSION)"
@echo "Updating Cargo.lock..."
cargo update
@echo "Building Explorer bundle and project to verify changes..."
$(MAKE) explorer
cargo build
@echo "Running tests to ensure stability..."
cargo test
@echo "Release preparation complete for version $(VERSION)"
# Prepare version update (on feature branch)
version-commit: prepare-release
@echo "Committing version changes..."
$(eval VERSION := $(call get_version))
$(eval BRANCH := $(shell git branch --show-current))
git add Cargo.toml Cargo.lock
git commit -m "Update version to $(VERSION)"
git push origin $(BRANCH)
@echo "✅ Version $(VERSION) committed to branch $(BRANCH)"
@echo "📝 Next steps:"
@echo " 1. Create PR: $(BRANCH) → main"
@echo " 2. Merge PR to get version into main"
@echo " 3. Run 'make release' to trigger auto-tagging"
# Release: create tag directly from main (simplified workflow)
release:
@echo "Creating release from main branch..."
$(eval VERSION := $(call get_version))
$(eval CURRENT_BRANCH := $(shell git branch --show-current))
@if [ "$(CURRENT_BRANCH)" != "main" ]; then \
echo "ERROR: Release must be run from main branch. Current branch: $(CURRENT_BRANCH)"; \
echo "Switch to main: git checkout main && git pull origin main"; \
exit 1; \
fi
@echo "Checking if working directory is clean..."
@if ! git diff-index --quiet HEAD --; then \
echo "ERROR: Working directory has uncommitted changes. Please commit or stash them."; \
exit 1; \
fi
@echo "Verifying version $(VERSION) is ready for release..."
@echo "Building and testing to ensure stability..."
$(MAKE) explorer
cargo build --release
cargo test
@echo "Creating release tag v$(VERSION)..."
git tag -a v$(VERSION) -m "Release version v$(VERSION)"
git push origin v$(VERSION)
@echo "✅ Release v$(VERSION) completed!"
@echo "🚀 GitHub Actions will build and publish the release"
@echo "📝 View release: https://github.com/Reqvire/reqvire/releases/tag/v$(VERSION)"
# Manual tag creation (backup method)
release-tag:
@echo "Manual tag creation (backup method)..."
$(eval VERSION := $(call get_version))
$(eval BRANCH := $(shell git branch --show-current))
@if [ "$(BRANCH)" != "releases" ]; then \
echo "ERROR: Tags should be created from releases branch. Current branch: $(BRANCH)"; \
echo "Switch to releases: git checkout releases"; \
exit 1; \
fi
git tag -a v$(VERSION) -m "Release version v$(VERSION)"
git push origin v$(VERSION)
@echo "Release v$(VERSION) tagged and pushed from releases!"
create_tag:
@echo "Creating tag..."
$(eval VERSION := $(call get_version))
@echo "New version: $(VERSION)"
git tag -a v$(VERSION) -m "Release version v$(VERSION)"
git push origin v$(VERSION)
# Automated release preparation (creates branch, updates version, commits, creates PR)
release-patch:
@echo "🚀 Starting automated patch release process..."
$(eval CURRENT_VERSION := $(call get_version))
$(eval NEW_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$3=$$3+1} 1' OFS=.))
$(eval BRANCH_NAME := release/v$(NEW_VERSION))
@echo "Creating release branch: $(BRANCH_NAME)"
git checkout -b $(BRANCH_NAME)
@echo "Updating version from $(CURRENT_VERSION) to $(NEW_VERSION)..."
$(call update_version,$(NEW_VERSION))
@$(MAKE) version-commit
@echo "Creating pull request..."
@if command -v gh >/dev/null 2>&1; then \
gh pr create --base main --head $(BRANCH_NAME) \
--title "Update version to v$(NEW_VERSION)" \
--body "Automated version bump for release v$(NEW_VERSION)"; \
echo "✅ Pull request created successfully!"; \
echo "📝 Next steps:"; \
echo " 1. Review and merge the PR"; \
echo " 2. Run 'git checkout main && git pull origin main'"; \
echo " 3. Run 'make release' to create the tag and trigger automated release"; \
else \
echo "⚠️ GitHub CLI (gh) not found. Please create PR manually:"; \
echo " Branch: $(BRANCH_NAME) → main"; \
echo " Title: Update version to v$(NEW_VERSION)"; \
fi
release-minor:
@echo "🚀 Starting automated minor release process..."
$(eval CURRENT_VERSION := $(call get_version))
$(eval NEW_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$2=$$2+1; $$3=0} 1' OFS=.))
$(eval BRANCH_NAME := release/v$(NEW_VERSION))
@echo "Creating release branch: $(BRANCH_NAME)"
git checkout -b $(BRANCH_NAME)
@echo "Updating version from $(CURRENT_VERSION) to $(NEW_VERSION)..."
$(call update_version,$(NEW_VERSION))
@$(MAKE) version-commit
@echo "Creating pull request..."
@if command -v gh >/dev/null 2>&1; then \
gh pr create --base main --head $(BRANCH_NAME) \
--title "Update version to v$(NEW_VERSION)" \
--body "Automated version bump for release v$(NEW_VERSION)"; \
echo "✅ Pull request created successfully!"; \
echo "📝 Next steps:"; \
echo " 1. Review and merge the PR"; \
echo " 2. Run 'git checkout main && git pull origin main'"; \
echo " 3. Run 'make release' to create the tag and trigger automated release"; \
else \
echo "⚠️ GitHub CLI (gh) not found. Please create PR manually:"; \
echo " Branch: $(BRANCH_NAME) → main"; \
echo " Title: Update version to v$(NEW_VERSION)"; \
fi
release-major:
@echo "🚀 Starting automated major release process..."
$(eval CURRENT_VERSION := $(call get_version))
$(eval NEW_VERSION := $(shell echo $(CURRENT_VERSION) | awk -F. '{$$1=$$1+1; $$2=0; $$3=0} 1' OFS=.))
$(eval BRANCH_NAME := release/v$(NEW_VERSION))
@echo "Creating release branch: $(BRANCH_NAME)"
git checkout -b $(BRANCH_NAME)
@echo "Updating version from $(CURRENT_VERSION) to $(NEW_VERSION)..."
$(call update_version,$(NEW_VERSION))
@$(MAKE) version-commit
@echo "Creating pull request..."
@if command -v gh >/dev/null 2>&1; then \
gh pr create --base main --head $(BRANCH_NAME) \
--title "Update version to v$(NEW_VERSION)" \
--body "Automated version bump for release v$(NEW_VERSION)"; \
echo "✅ Pull request created successfully!"; \
echo "📝 Next steps:"; \
echo " 1. Review and merge the PR"; \
echo " 2. Run 'git checkout main && git pull origin main'"; \
echo " 3. Run 'make release' to create the tag and trigger automated release"; \
else \
echo "⚠️ GitHub CLI (gh) not found. Please create PR manually:"; \
echo " Branch: $(BRANCH_NAME) → main"; \
echo " Title: Update version to v$(NEW_VERSION)"; \
fi