45 lines
970 B
Makefile
45 lines
970 B
Makefile
# Makefile for Go application
|
|
|
|
# Go parameters
|
|
GO ?= go
|
|
PKG := $(shell go list ./...)
|
|
BINARY_NAME = zurg
|
|
BUILD_DIR = ./cmd/$(BINARY_NAME)
|
|
VERSION ?= $(shell git describe --tags)
|
|
COMMIT ?= $(shell git rev-parse HEAD)
|
|
BUILT_AT ?= $(shell date +%Y-%m-%dT%H:%M:%SZ)
|
|
|
|
# Default target: build
|
|
all: build
|
|
|
|
# Build the project
|
|
build:
|
|
$(GO) build -ldflags "-X 'github.com/debridmediamanager/zurg/internal/version.BuiltAt=$(BUILT_AT)' -X 'github.com/debridmediamanager/zurg/internal/version.GitCommit=$(COMMIT)' -X 'github.com/debridmediamanager/zurg/internal/version.Version=$(VERSION)'" -o $(BINARY_NAME) $(BUILD_DIR)
|
|
|
|
# Run tests
|
|
test:
|
|
$(GO) test -v ./...
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo "Cleaning build artifacts..."
|
|
@rm -f $(BINARY_NAME)
|
|
|
|
# Run the application
|
|
run: build
|
|
./$(BINARY_NAME)
|
|
|
|
# Install dependencies
|
|
deps:
|
|
$(GO) mod tidy
|
|
|
|
# Format the code
|
|
fmt:
|
|
$(GO) fmt ./...
|
|
|
|
# Lint the code
|
|
lint:
|
|
$(GO) vet ./...
|
|
|
|
.PHONY: all build test clean run deps fmt lint
|