forked from oras-project/oras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (53 loc) · 1.95 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
PROJECT_PKG = github.com/deislabs/oras
CLI_EXE = oras
CLI_PKG = $(PROJECT_PKG)/cmd/oras
GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
LDFLAGS = -w
ifdef VERSION
LDFLAGS += -X $(PROJECT_PKG)/internal/version.BuildMetadata=$(VERSION)
endif
ifneq ($(GIT_TAG),)
LDFLAGS += -X $(PROJECT_PKG)/internal/version.BuildMetadata=
endif
LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitCommit=${GIT_COMMIT}
LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitTreeState=${GIT_DIRTY}
.PHONY: test
test: vendor check-encoding
./scripts/test.sh
.PHONY: covhtml
covhtml:
open .cover/coverage.html
.PHONY: clean
clean:
git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf
.PHONY: build
build: build-linux build-linux-arm64 build-mac build-windows
.PHONY: build-linux
build-linux:
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \
-o bin/linux/amd64/$(CLI_EXE) $(CLI_PKG)
.PHONY: build-linux-arm64
build-linux-arm64:
GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \
-o bin/linux/arm64/$(CLI_EXE) $(CLI_PKG)
.PHONY: build-mac
build-mac:
GOARCH=amd64 CGO_ENABLED=0 GOOS=darwin go build -v --ldflags="$(LDFLAGS)" \
-o bin/darwin/amd64/$(CLI_EXE) $(CLI_PKG)
.PHONY: build-windows
build-windows:
GOARCH=amd64 CGO_ENABLED=0 GOOS=windows go build -v --ldflags="$(LDFLAGS)" \
-o bin/windows/amd64/$(CLI_EXE).exe $(CLI_PKG)
.PHONY: check-encoding
check-encoding:
! find cmd pkg internal examples -name "*.go" -type f -exec file "{}" ";" | grep CRLF
! find scripts -name "*.sh" -type f -exec file "{}" ";" | grep CRLF
.PHONY: fix-encoding
fix-encoding:
find cmd pkg internal examples -type f -name "*.go" -exec sed -i -e "s/\r//g" {} +
find scripts -type f -name "*.sh" -exec sed -i -e "s/\r//g" {} +
.PHONY: vendor
vendor:
GO111MODULE=on go mod vendor