forked from ossf/package-feeds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (56 loc) · 1.71 KB
/
Makefile
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
66
GO ?= go
BIN := bin
GOOS ?= $(shell uname | tr A-Z a-z)
GOLANGCI_LINT_VERSION = v1.53.3
PROJECT := package-feeds
VERSION ?= $(shell echo $$VERSION)
ifeq ($(VERSION),)
VERSION := $(shell git rev-parse --short HEAD)
endif
.PHONY: help
help: ## Display this help
@awk \
-v "col=${COLOR}" -v "nocol=${NOCOLOR}" \
' \
BEGIN { \
FS = ":.*##" ; \
printf "Available targets:\n"; \
} \
/^[a-zA-Z0-9_-]+:.*?##/ { \
printf " %s%-25s%s %s\n", col, $$1, nocol, $$2 \
} \
/^##@/ { \
printf "\n%s%s%s\n", col, substr($$0, 5), nocol \
} \
' $(MAKEFILE_LIST)
.PHONY: build
build:
mkdir -p $(BIN)/$(PROJECT) && \
env CGO_ENABLED=0 GOOS=$(GOOS) go build -o $(BIN)/$(PROJECT) -a ./...
.PHONY: build_image
build_image: ## Build the docker image
docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_REPO)/$(PROJECT):$(VERSION) . --load
.PHONY: push_image
push_image: build_image ## Push the docker image
docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_REPO)/$(PROJECT):$(VERSION) . --push
.PHONY: clean
clean: ## Clean the build directory
rm -rf $(BIN)
.PHONY: go-mod
go-mod: ## Cleanup and verify go modules
$(GO) mod tidy && $(GO) mod verify
# Verification targets
.PHONY: verify
verify: verify-go-mod verify-go-lint ## Run all verification targets
.PHONY: verify-go-mod
verify-go-mod: go-mod ## Verify the go modules
./hacks/tree-status
.PHONY: verify-go-lint
verify-go-lint: golangci-lint ## Verify the golang code by linting
$(BIN)/golangci-lint run -c ./.golangci.yml
golangci-lint:
export \
VERSION=$(GOLANGCI_LINT_VERSION) \
URL=https://raw.githubusercontent.com/golangci/golangci-lint \
BINDIR=$(BIN) && \
curl -sfL $$URL/$$VERSION/install.sh | sh -s $$VERSION