-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (39 loc) · 1.47 KB
/
Makefile
File metadata and controls
50 lines (39 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
.PHONY: all build install test benchmark clean version release release-snapshot
GO ?= go
PKG := github.com/AlexanderGrooff/spage
BINARY := spage
BIN_DIR := dist
GIT_COMMIT := $(shell git rev-parse HEAD 2>/dev/null || echo unknown)
BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X $(PKG)/cmd.Version=$(VERSION) -X $(PKG)/cmd.GitCommit=$(GIT_COMMIT) -X $(PKG)/cmd.BuildDate=$(BUILD_DATE)
all: build
build:
@mkdir -p $(BIN_DIR)
$(GO) build -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(BINARY) .
install:
$(GO) install -ldflags "$(LDFLAGS)" .
test:
$(GO) test -v -race -cover -count=1 ./...
benchmark:
$(GO) test -run=^$$ -bench=. -benchmem -count=3 ./...
clean:
rm -rf $(BIN_DIR)
version:
@echo "Version: $(VERSION)"
@echo "Git commit: $(GIT_COMMIT)"
@echo "Build date: $(BUILD_DATE)"
release:
@if [ -z "$(TAG)" ]; then \
echo "Error: TAG is required. Usage: make release TAG=v1.0.0"; \
exit 1; \
fi
@echo "Creating release $(TAG)..."
git tag $(TAG)
git push origin $(TAG)
@echo "Release $(TAG) created and pushed. GitHub Actions will handle the build and release."
release-snapshot:
@echo "Building release snapshot with goreleaser..."
@command -v goreleaser >/dev/null 2>&1 || { echo "goreleaser is required but not installed. Install it from https://goreleaser.com/install/"; exit 1; }
goreleaser release --snapshot --clean
@echo "Snapshot release built in dist/ directory"