terraria-companion/Makefile
Felipe M. ec4aa66610
Some checks failed
CI / format (push) Has been cancelled
CI / goreleaser-lint (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / build (push) Has been cancelled
Give golangci-lint five minutes
CI runs on a fresh container with an empty Go build cache now, so the
first analysis compiles every dependency and runs past golangci-lint's
own one minute default. The run itself is unchanged.
2026-09-22 12:48:56 +02:00

92 lines
2.9 KiB
Makefile

PROJECT_NAME := terraria-companion
CGO_ENABLED ?= 0
PORT ?= 3000
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -X main.version=$(VERSION)
GOLANGCI_LINT_VERSION := v2.12.2
.DEFAULT_GOAL := help
## help: Display this help message
.PHONY: help
help:
@echo "Available targets:"
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /' | sort
# ── Build ────────────────────────────────────────────────────────
## build: Build the production binary (embeds data assets)
.PHONY: build
build:
CGO_ENABLED=$(CGO_ENABLED) go build -tags embed_data -ldflags "$(LDFLAGS)" -o $(PROJECT_NAME) .
## build-nodata: Build without embedded data (for CI/containers)
.PHONY: build-nodata
build-nodata:
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags "$(LDFLAGS)" -o $(PROJECT_NAME) .
## build-snapshot: Build all platforms locally via goreleaser (snapshot)
.PHONY: build-snapshot
build-snapshot:
goreleaser build --snapshot --clean
# ── Development ──────────────────────────────────────────────────
## dev: Run in dev mode (serves frontend from disk, hot-reloads data)
.PHONY: dev
dev:
DEV=1 go run .
## serve: Build and run the production server
.PHONY: serve
serve: build
./$(PROJECT_NAME)
# ── Data Fetching ────────────────────────────────────────────────
## fetch: Fetch/resume data from Terraria wiki (Go fetcher)
.PHONY: fetch
fetch:
go run . fetch
## fetch-reset: Reset fetch state and start fresh
.PHONY: fetch-reset
fetch-reset:
go run . fetch --reset
## fetch-only: Fetch a single phase (usage: make fetch-only PHASE=drops)
.PHONY: fetch-only
fetch-only:
go run . fetch --only=$(PHASE)
# ── Quality ──────────────────────────────────────────────────────
## format: Format code and tidy modules
.PHONY: format
format:
go fmt ./...
go mod tidy
## ci-lint: Run linter (auto-installs golangci-lint for CI)
.PHONY: ci-lint
ci-lint:
@which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
golangci-lint run --timeout=5m ./...
## lint: Run linters
.PHONY: lint
lint: ci-lint
# ── Cleanup ──────────────────────────────────────────────────────
## clean: Remove build artifacts
.PHONY: clean
clean:
rm -f $(PROJECT_NAME) $(PROJECT_NAME)-*
rm -rf dist/
## clean-data: Remove fetched data (keeps icons as cache)
.PHONY: clean-data
clean-data:
rm -rf data