Files
BackupX/Makefile
T

69 lines
1.7 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
.PHONY: build build-server build-web build-docs dev-server dev-web \
test test-server test-web check-docs format-check vet-server \
verify verify-server verify-web verify-docs clean docker docker-cn
# 自动获取版本号(从 git tag 或 commit hash
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
# ── 一键构建 ──
build: build-server build-web
build-server:
cd server && CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$(VERSION)" -o bin/backupx ./cmd/backupx
build-web:
cd web && npm run build
build-docs:
cd docs-site && npm run build
# ── 开发模式(分别在两个终端运行)──
dev-server:
cd server && go run ./cmd/backupx
dev-web:
cd web && npm run dev
# ── 测试 ──
test: test-server test-web
test-server:
cd server && go test ./...
test-web:
cd web && npm run test
check-docs:
cd docs-site && npm run typecheck && npm run build
format-check:
@unformatted="$$(gofmt -l server)"; \
if [ -n "$$unformatted" ]; then \
printf '%s\n' "$$unformatted"; \
exit 1; \
fi
vet-server:
cd server && go mod verify && go vet ./...
# ── 提交前完整验证 ──
verify: verify-server verify-web verify-docs
verify-server: format-check vet-server test-server build-server
verify-web: test-web build-web
verify-docs: check-docs
# ── Docker 构建 ──
docker:
docker build --build-arg VERSION=$(VERSION) -t backupx:$(VERSION) -t backupx:latest .
# 国内加速构建(使用国内镜像源)
docker-cn:
docker build --build-arg VERSION=$(VERSION) --build-arg USE_CHINA_MIRROR=true -t backupx:$(VERSION) -t backupx:latest .
# ── 清理 ──
clean:
rm -rf server/bin web/dist