-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathMakefile
More file actions
180 lines (167 loc) · 8.45 KB
/
Makefile
File metadata and controls
180 lines (167 loc) · 8.45 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
# rv1106-system Makefile
#
# Targets:
# build - Build rv1106-system image
# flash - Flash system image to device (depends on build)
# test - Run E2E tests (depends on flash)
# dev_release - Dev release (prerelease) with testing
# release - Production release with testing
# bump-version - Bump version for next release cycle
VERSION := $(shell cat VERSION 2>/dev/null || echo "0.0.0")
VERSION_DEV := $(VERSION)-dev$(shell date -u +%Y%m%d%H%M)
DEVICE_IP ?= 192.168.1.77
R2_PATH := r2://jetkvm-update/system
.PHONY: build flash test dev_release release bump-version git_check_dev clean check_device check_remote
# -----------------------------------------------------------------------------
# Git checks
# -----------------------------------------------------------------------------
git_check_dev:
@if [ -n "$$(git status --porcelain)" ]; then \
echo "Error: Working tree is dirty. Commit or stash changes."; exit 1; \
fi
@command -v gh >/dev/null 2>&1 || { echo "Error: gh CLI not installed"; exit 1; }
@gh auth status >/dev/null 2>&1 || { echo "Error: gh CLI not authenticated. Run 'gh auth login'"; exit 1; }
@command -v rclone >/dev/null 2>&1 || { echo "Error: rclone not installed"; exit 1; }
@current_branch="$$(git rev-parse --abbrev-ref HEAD)"; \
current_commit="$$(git rev-parse HEAD)"; \
current_short="$$(git rev-parse --short HEAD)"; \
current_subject="$$(git log -1 --pretty=%s)"; \
current_version="$$(cat VERSION 2>/dev/null || echo unknown)"; \
git fetch origin dev; \
origin_commit="$$(git rev-parse origin/dev)"; \
origin_short="$$(git rev-parse --short origin/dev)"; \
if [ "$$current_branch" = "dev" ] && [ "$$current_commit" = "$$origin_commit" ]; then \
exit 0; \
fi; \
echo ""; \
echo "WARNING: Releasing from the current checkout instead of latest origin/dev"; \
echo " Ref: $$current_branch"; \
echo " Commit: $$current_short"; \
echo " Subject: $$current_subject"; \
echo " Version: $$current_version"; \
echo " origin/dev: $$origin_short"; \
echo ""; \
read -p "Continue with this checkout? [y/N] " confirm; \
[ "$$confirm" = "y" ] || exit 1
# -----------------------------------------------------------------------------
# Build / Flash / Test (dependency chain)
# -----------------------------------------------------------------------------
build: clean
./scripts/build_system.sh
check_device:
@echo "Checking device connectivity ($(DEVICE_IP))..."
@ping -c 1 -W 5 $(DEVICE_IP) > /dev/null 2>&1 || { echo "Error: Cannot reach device at $(DEVICE_IP)"; exit 1; }
@ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10 root@$(DEVICE_IP) "echo ok" > /dev/null 2>&1 || { echo "Error: SSH failed to root@$(DEVICE_IP)"; exit 1; }
@echo "OK: Device reachable"
check_remote:
@echo "Checking remote host connectivity ($(JETKVM_REMOTE_HOST))..."
@ping -c 1 -W 5 $(shell echo $(JETKVM_REMOTE_HOST) | sed 's/.*@//') > /dev/null 2>&1 || { echo "Error: Cannot reach remote host at $(JETKVM_REMOTE_HOST)"; exit 1; }
@ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10 $(JETKVM_REMOTE_HOST) "echo ok" > /dev/null 2>&1 || { echo "Error: SSH failed to $(JETKVM_REMOTE_HOST)"; exit 1; }
@echo "OK: Remote host reachable"
flash:
$(MAKE) check_device
ifndef SKIP_BUILD
$(MAKE) build
endif
./scripts/flash_system.sh -r $(DEVICE_IP)
test:
$(MAKE) check_device
$(MAKE) check_remote
ifndef SKIP_BUILD
$(MAKE) flash
else
$(MAKE) flash SKIP_BUILD=1
endif
./scripts/run_e2e_tests.sh -r $(DEVICE_IP) --remote-host $(JETKVM_REMOTE_HOST) $(if $(KVM_DIR),--kvm-dir $(KVM_DIR))
# -----------------------------------------------------------------------------
# Dev Release - Prerelease for testing
# -----------------------------------------------------------------------------
dev_release: export BUILD_VERSION := $(VERSION_DEV)
dev_release: git_check_dev test
@if rclone lsf $(R2_PATH)/$(VERSION_DEV)/ 2>/dev/null | grep -q .; then \
echo "Error: Version $(VERSION_DEV) already exists in R2"; exit 1; \
fi
@if gh release view "release/v$(VERSION_DEV)" --repo jetkvm/rv1106-system >/dev/null 2>&1; then \
echo "Error: GitHub release release/v$(VERSION_DEV) already exists"; exit 1; \
fi
@echo "═══════════════════════════════════════════════════════"
@echo " DEV Release (Pre-release)"
@echo "═══════════════════════════════════════════════════════"
@echo " Version: $(VERSION_DEV)"
@echo " Tag: release/v$(VERSION_DEV)"
@echo " Branch: $$(git rev-parse --abbrev-ref HEAD)"
@echo " Commit: $$(git rev-parse --short HEAD)"
@echo " Subject: $$(git log -1 --pretty=%s)"
@echo " Time: $$(date -u +%FT%T%z)"
@echo "═══════════════════════════════════════════════════════"
@echo ""
@read -p "Proceed? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1
./scripts/release_r2.sh --version $(VERSION_DEV)
./scripts/release_github.sh --version $(VERSION_DEV) --prerelease
@echo ""
@echo "OK: Dev release complete: release/v$(VERSION_DEV)"
# -----------------------------------------------------------------------------
# Production Release
# -----------------------------------------------------------------------------
release: export BUILD_VERSION := $(VERSION)
release: git_check_dev test
@if rclone lsf $(R2_PATH)/$(VERSION)/ 2>/dev/null | grep -q .; then \
echo "Error: Version $(VERSION) already exists in R2"; exit 1; \
fi
@if gh release view "release/v$(VERSION)" --repo jetkvm/rv1106-system >/dev/null 2>&1; then \
echo "Error: GitHub release release/v$(VERSION) already exists"; exit 1; \
fi
@latest_dev=$$(gh release list --repo jetkvm/rv1106-system --limit 10 --json tagName --jq '.[].tagName' | grep "^release/v$(VERSION)-dev" | head -1); \
if [ -z "$$latest_dev" ]; then \
echo ""; \
echo "WARNING: No dev release found for $(VERSION)"; \
echo ""; \
read -p "Release production without prior dev release? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1; \
else \
echo "OK: Found prior dev release: $$latest_dev"; \
fi
@echo ""
@echo "═══════════════════════════════════════════════════════"
@echo " PRODUCTION Release"
@echo "═══════════════════════════════════════════════════════"
@echo " Version: $(VERSION)"
@echo " Tag: release/v$(VERSION)"
@echo " Branch: $$(git rev-parse --abbrev-ref HEAD)"
@echo " Commit: $$(git rev-parse --short HEAD)"
@echo " Subject: $$(git log -1 --pretty=%s)"
@echo " Time: $$(date -u +%FT%T%z)"
@echo "═══════════════════════════════════════════════════════"
@echo ""
@read -p "Proceed with PRODUCTION release? [y/N] " confirm && [ "$$confirm" = "y" ] || exit 1
./scripts/release_r2.sh --version $(VERSION)
./scripts/release_github.sh --version $(VERSION)
@echo ""
@echo "OK: Production release complete: release/v$(VERSION)"
@echo ""
@echo "Next: Run 'make bump-version' to prepare for next release cycle"
# -----------------------------------------------------------------------------
# Bump Version
# -----------------------------------------------------------------------------
bump-version:
@next_default=$$(echo $(VERSION) | awk -F. '{print $$1"."$$2"."$$3+1}'); \
echo "Current version: $(VERSION)"; \
read -p "Next version [$$next_default]: " next_ver; \
next_ver=$${next_ver:-$$next_default}; \
if ! echo "$$next_ver" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$$'; then \
echo "Error: Invalid version '$$next_ver'. Must be semver format (e.g., 1.2.3)"; \
exit 1; \
fi; \
echo "$$next_ver" > VERSION && \
git add VERSION && \
git commit -m "Bump version to $$next_ver" && \
git push && \
echo "OK: Version bumped to $$next_ver"
# -----------------------------------------------------------------------------
# Clean build artifacts
# -----------------------------------------------------------------------------
clean:
@echo "Cleaning build artifacts..."
sudo rm -rf output/
./build.sh clean
rm -f buildkit.tar.zst
@echo "OK: Clean complete"