feat: CLI-Skeleton mit version/serve/check und Makefile

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NBHF4R9EAejDJUMdwr6C68
This commit is contained in:
Carsten Abele 2026-08-14 09:03:31 +02:00
parent bb84607bf8
commit fbfff90b38
8 changed files with 196 additions and 0 deletions

44
Makefile Normal file
View file

@ -0,0 +1,44 @@
BINARY := vpnportal
PKG := git.ravensburg.dev/cabele/opnsense-portal/cmd/vpnportal
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
# sha256sum gibt es auf macOS nicht; shasum ist dort das Äquivalent.
SHA256 := $(shell command -v sha256sum >/dev/null 2>&1 && echo sha256sum || echo "shasum -a 256")
export CGO_ENABLED := 0
.PHONY: all build test race vet lint release clean
all: vet test build
build:
go build -trimpath -ldflags '$(LDFLAGS)' -o dist/$(BINARY) $(PKG)
test:
go test ./...
race:
go test -race ./...
vet:
go vet ./...
lint: vet
@test -z "$$(gofmt -l . | tee /dev/stderr)" || (echo "gofmt-Fehler: bitte 'gofmt -w .' ausführen" && exit 1)
release: clean
@set -e; for arch in amd64 arm64; do \
echo "==> linux/$$arch"; \
mkdir -p dist/linux-$$arch; \
GOOS=linux GOARCH=$$arch go build -trimpath -ldflags '$(LDFLAGS)' \
-o dist/linux-$$arch/$(BINARY) $(PKG); \
cp deploy/config.example.yaml deploy/vpnportal.service README.md dist/linux-$$arch/; \
tar -czf dist/$(BINARY)-$(VERSION)-linux-$$arch.tar.gz -C dist/linux-$$arch .; \
done
cd dist && $(SHA256) *.tar.gz > SHA256SUMS
clean:
rm -rf dist