-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (61 loc) · 1.96 KB
/
Makefile
File metadata and controls
77 lines (61 loc) · 1.96 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
66
67
68
69
70
71
72
73
74
75
76
77
PREFIX?=$(shell pwd)
NAME := pomerium-cli
PKG := github.com/pomerium/cli
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
# Keep cgo disabled on Linux, to avoid the cgo version of the Go standard
# library 'net' package. On macOS and Windows we need cgo for the system cert
# store integrations, but as of Go 1.20 the 'net' package does not use cgo on
# macOS, and the 'net' package never used cgo on Windows (see
# https://go.dev/doc/go1.20#cgo).
ifeq ($(shell uname),Linux)
export CGO_ENABLED=0
endif
CTIMEVAR=-X $(PKG)/version.GitCommit=$(GITCOMMIT) \
-X $(PKG)/version.BuildMeta=$(BUILDMETA) \
-X $(PKG)/version.ProjectName=$(NAME) \
-X $(PKG)/version.ProjectURL=$(PKG)
GO ?= "go"
GOTAGS = -tags embed_pomerium
GO_LDFLAGS=-ldflags "-s -w $(CTIMEVAR)"
GOOSARCHES = linux/amd64 darwin/amd64 windows/amd64
.PHONY: all
all: clean lint test build
.PHONY: test
test: ## test everything
go test $(GOTAGS) ./...
.PHONY: lint
lint:
@echo "==> $@"
$(GO) run ./pkg/tools/get-tools.go && \
./bin/golangci-lint run --fix --timeout=20m ./...
.PHONY: tidy
tidy: ## run go mod tidy
go mod tidy -compat=1.19
.PHONY: tools
tools: generate
.PHONY: generate
generate:
@echo "==> $@"
go run github.com/bufbuild/buf/cmd/buf@v1.51.0 generate
.PHONY: clean
clean: ## Cleanup any build binaries or packages.
@echo "==> $@"
$(RM) -r $(BINDIR)
$(RM) -r $(BUILDDIR)
.PHONY: build
build: ## Build everything.
@echo "==> $@"
@go build $(GOTAGS) $(GO_LDFLAGS) -o $(BINDIR)/$(NAME) ./cmd/"$(NAME)"
.PHONY: snapshot
snapshot: ## Create release snapshot
APPARITOR_GITHUB_TOKEN=foo VERSION_FLAGS="$(CTIMEVAR)" goreleaser release --snapshot --clean
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'