-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
72 lines (60 loc) · 1.68 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
67
68
69
70
71
72
PROJECT := signy
ORG := cnabio
BINDIR := $(CURDIR)/bin
GOFLAGS :=
GOBUILDTAGS := osusergo
ifeq ($(OS),Windows_NT)
TARGET = $(PROJECT).exe
SHELL = cmd.exe
CHECK = where.exe
else
TARGET = $(PROJECT)
SHELL ?= bash
CHECK ?= which
endif
# These commands come from https://github.com/cnabio/cnab-to-oci/blob/c91ac3daf0d74446a914727e80ffa15529da16d8/Makefile#L14
ifeq ($(COMMIT),)
COMMIT := $(shell git rev-parse --short HEAD 2> /dev/null)
endif
ifeq ($(BUILDTIME),)
BUILDTIME := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" 2> /dev/null)
endif
ifeq ($(BUILDTIME),)
BUILDTIME := unknown
$(warning unable to set BUILDTIME. Set the value manually)
endif
# TAG environment variable should be set before calling make
LDFLAGS := "-s -w \
-X github.com/cnabio/signy/pkg/docker.Tag=latest \
-X main.Commit=$(COMMIT) \
-X main.Version=$(TAG) \
-X main.BuildTime=$(BUILDTIME)"
.PHONY: build
build:
go build $(GOFLAGS) -tags '$(GOBUILDTAGS)' -ldflags $(LDFLAGS) -o $(BINDIR)/$(TARGET) github.com/$(ORG)/$(PROJECT)/cmd/...
.PHONY: install
install: build
mv $(BINDIR)/$(TARGET) $(GOPATH)/bin
.PHONY: test
test:
go test $(TESTFLAGS) ./...
.PHONY: lint
lint:
golangci-lint run --config ./golangci.yml
HAS_GOLANGCI := $(shell $(CHECK) golangci-lint)
HAS_GOIMPORTS := $(shell $(CHECK) goimports)
GOLANGCI_VERSION := v1.46.2
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOLANGCI
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VERSION)
endif
ifndef HAS_GOIMPORTS
go install golang.org/x/tools/cmd/goimports@latest
endif
.PHONY: e2e
e2e:
make e2e-list
.PHONY: e2e-list
e2e-list:
./bin/signy list docker.io/library/alpine