37 lines
1.1 KiB
Makefile
37 lines
1.1 KiB
Makefile
.PHONY: build frontend-build dev clean test patch minor major
|
|
|
|
LAST_TAG := $(shell git tag --sort=-v:refname | head -1)
|
|
MAJOR := $(shell echo $(LAST_TAG) | sed 's/^v//' | cut -d. -f1)
|
|
MINOR := $(shell echo $(LAST_TAG) | sed 's/^v//' | cut -d. -f2)
|
|
PATCH := $(shell echo $(LAST_TAG) | sed 's/^v//' | cut -d. -f3)
|
|
|
|
build: frontend-build
|
|
CGO_ENABLED=0 go build -ldflags "-X main.buildID=$$(git rev-parse --short HEAD)" -o turnpike .
|
|
|
|
frontend-build:
|
|
cd frontend && npm ci && BUILD_ID=$$(git rev-parse --short HEAD) npm run build
|
|
|
|
dev:
|
|
@echo "Run in two terminals:"
|
|
@echo " Terminal 1: go run . --db dev.db"
|
|
@echo " Terminal 2: cd frontend && npm run dev"
|
|
|
|
test:
|
|
go test ./...
|
|
cd frontend && npx vitest run
|
|
|
|
clean:
|
|
rm -f turnpike dev.db
|
|
rm -rf frontend/dist
|
|
|
|
patch:
|
|
git tag v$(MAJOR).$(MINOR).$(shell echo $$(($(PATCH)+1)))
|
|
@echo "Tagged v$(MAJOR).$(MINOR).$(shell echo $$(($(PATCH)+1)))"
|
|
|
|
minor:
|
|
git tag v$(MAJOR).$(shell echo $$(($(MINOR)+1))).0
|
|
@echo "Tagged v$(MAJOR).$(shell echo $$(($(MINOR)+1))).0"
|
|
|
|
major:
|
|
git tag v$(shell echo $$(($(MAJOR)+1))).0.0
|
|
@echo "Tagged v$(shell echo $$(($(MAJOR)+1))).0.0"
|