Files
BackupX/Makefile
Wu Qing 9080a47703 chore(repo): 完善仓库维护与自动化 (#108)
统一 Node.js 24 LTS、CI、文档和发布工作流配置。

完善仓库维护规范、Dependabot 与贡献文档,清理生成产物并统一既有 Go 代码格式。
2026-08-09 21:18:19 +08:00

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