-
-
Notifications
You must be signed in to change notification settings - Fork 179
Expand file tree
/
Copy pathMakefile
More file actions
65 lines (52 loc) · 2.7 KB
/
Copy pathMakefile
File metadata and controls
65 lines (52 loc) · 2.7 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
BINARY := metabigor
MODULE := github.com/j3ssie/metabigor
VERSION := $(shell cat internal/core/constants.go | grep 'VERSION =' | cut -d '"' -f 2)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
BUILDDATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -s -w -X 'main.version=$(VERSION)' -X 'main.commit=$(COMMIT)' -X 'main.buildDate=$(BUILDDATE)'
GOFLAGS := -trimpath
GOBIN_PATH := $(shell go env GOPATH)/bin
.PHONY: build test clean install build-all fmt vet lint e2e update release snapshot
build:
@mkdir -p bin
go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/$(BINARY) ./cmd/metabigor
@cp bin/$(BINARY) $(GOBIN_PATH)/$(BINARY)
install:
go install $(GOFLAGS) -ldflags '$(LDFLAGS)' ./cmd/metabigor
test:
go test -race -count=1 ./...
fmt:
gofmt -w -s .
vet:
go vet ./...
lint:
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci-lint not installed. Install: https://golangci-lint.run/usage/install/"; exit 1; }
golangci-lint run ./...
e2e: build
@echo "Running end-to-end tests..."
@cd test && ./run-e2e.sh
update:
@echo "Updating embedded databases..."
@wget -O public/ip-to-asn.csv.zip https://github.com/iplocate/ip-address-databases/raw/refs/heads/main/ip-to-asn/ip-to-asn.csv.zip
@echo "ASN database updated at public/ip-to-asn.csv.zip"
@wget -O public/ip-to-country.csv.zip https://github.com/iplocate/ip-address-databases/raw/refs/heads/main/ip-to-country/ip-to-country.csv.zip
@echo "Country database updated at public/ip-to-country.csv.zip"
@echo "All databases updated successfully"
clean:
rm -rf bin/ dist/
build-all: clean
@mkdir -p dist
GOOS=linux GOARCH=amd64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/$(BINARY)-linux-amd64 ./cmd/metabigor
GOOS=linux GOARCH=arm64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/$(BINARY)-linux-arm64 ./cmd/metabigor
GOOS=darwin GOARCH=amd64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/$(BINARY)-darwin-amd64 ./cmd/metabigor
GOOS=darwin GOARCH=arm64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/$(BINARY)-darwin-arm64 ./cmd/metabigor
GOOS=windows GOARCH=amd64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o dist/$(BINARY)-windows-amd64.exe ./cmd/metabigor
snapshot:
@command -v goreleaser >/dev/null 2>&1 || { echo "goreleaser not installed. Install: https://goreleaser.com/install/"; exit 1; }
@echo "Building snapshot release with goreleaser..."
goreleaser release --snapshot --clean --skip=publish
release:
@command -v goreleaser >/dev/null 2>&1 || { echo "goreleaser not installed. Install: https://goreleaser.com/install/"; exit 1; }
@echo "Creating release with goreleaser..."
@echo "Note: Ensure you have a git tag and GITHUB_TOKEN set"
goreleaser release --clean