-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
59 lines (46 loc) · 1.65 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
PREFIX?=$(shell pwd)
NAME := pomerium-datasource
PKG := github.com/pomerium/datasource
BUILDDIR := ${PREFIX}/dist
BINDIR := ${PREFIX}/bin
GITCOMMIT := $(shell git rev-parse --short HEAD)
BUILDMETA:=
GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no)
ifneq ($(GITUNTRACKEDCHANGES),)
BUILDMETA := dirty
endif
CTIMEVAR=-X $(PKG)/internal/version.GitCommit=$(GITCOMMIT) \
-X $(PKG)/internal/version.BuildMeta=$(BUILDMETA) \
-X $(PKG)/internal/version.ProjectName=$(NAME) \
-X $(PKG)/internal/version.ProjectURL=$(PKG)
GO ?= "go"
GO_LDFLAGS=-ldflags "-s -w $(CTIMEVAR)"
GOOSARCHES = linux/amd64 darwin/amd64 windows/amd64
.PHONY: all
all: clean test build
.PHONY: test
test: ## test everything
go test ./...
.PHONY: tidy
tidy: ## run go mod tidy
go mod tidy -compat=1.19
.PHONY: clean
clean: ## Cleanup any build binaries or packages.
@echo "==> $@"
$(RM) -r $(BINDIR)
$(RM) -r $(BUILDDIR)
.PHONY: build
build: ## Build everything.
@echo "==> $@"
@CGO_ENABLED=0 GO111MODULE=on go build -tags "$(BUILDTAGS)" ${GO_LDFLAGS} -o $(BINDIR)/$(NAME) ./cmd/pomerium-datasource
.PHONY: snapshot
snapshot: ## Create release snapshot
APPARITOR_GITHUB_TOKEN=foo goreleaser release --snapshot --rm-dist
.PHONY: lint
lint:
@echo "@==> $@"
@VERSION=$$(go run github.com/mikefarah/yq/[email protected] '.jobs.lint.steps[] | select(.uses == "golangci/golangci-lint-action*") | .with.version' .github/workflows/lint.yml) && \
go run github.com/golangci/golangci-lint/cmd/golangci-lint@$$VERSION run --fix ./...
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'