forked from poseidon/matchbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (97 loc) · 3.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
export CGO_ENABLED:=0
DIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
VERSION=$(shell git describe --tags --match=v* --always --dirty)
LD_FLAGS="-w -X github.com/poseidon/matchbox/matchbox/version.Version=$(VERSION)"
REPO=github.com/poseidon/matchbox
LOCAL_REPO=poseidon/matchbox
IMAGE_REPO=quay.io/poseidon/matchbox
.PHONY: all
all: build test vet fmt
.PHONY: build
build:
@go build -o bin/matchbox -ldflags $(LD_FLAGS) $(REPO)/cmd/matchbox
.PHONY: test
test:
@go test ./... -cover
.PHONY: vet
vet:
@go vet -all ./...
.PHONY: fmt
fmt:
@test -z $$(go fmt ./...)
.PHONY: lint
lint:
@golangci-lint run ./...
.PHONY: image
image: \
image-amd64 \
image-arm64
image-%:
buildah bud -f Dockerfile \
-t $(LOCAL_REPO):$(VERSION)-$* \
--arch $* --override-arch $* \
--format=docker .
push: \
push-amd64
push-arm64
push-%:
buildah tag $(LOCAL_REPO):$(VERSION)-$* $(IMAGE_REPO):$(VERSION)-$*
buildah push --format v2s2 $(IMAGE_REPO):$(VERSION)-$*
manifest:
buildah manifest create $(IMAGE_REPO):$(VERSION)
buildah manifest add $(IMAGE_REPO):$(VERSION) docker://$(IMAGE_REPO):$(VERSION)-amd64
buildah manifest add --variant v8 $(IMAGE_REPO):$(VERSION) docker://$(IMAGE_REPO):$(VERSION)-arm64
buildah manifest inspect $(IMAGE_REPO):$(VERSION)
buildah manifest push -f v2s2 $(IMAGE_REPO):$(VERSION) docker://$(IMAGE_REPO):$(VERSION)
protoc/%:
podman run --security-opt label=disable \
-u root \
--mount type=bind,src=$(DIR),target=/mnt/code \
quay.io/dghubble/protoc:v3.10.1 \
--go_out=plugins=grpc,paths=source_relative:. $*
codegen: \
protoc/matchbox/storage/storagepb/*.proto \
protoc/matchbox/server/serverpb/*.proto \
protoc/matchbox/rpc/rpcpb/*.proto
clean:
@rm -rf bin
clean-release:
@rm -rf _output
release: \
clean \
clean-release \
_output/matchbox-linux-amd64.tar.gz \
_output/matchbox-linux-arm.tar.gz \
_output/matchbox-linux-arm64.tar.gz \
_output/matchbox-darwin-amd64.tar.gz \
_output/matchbox-darwin-arm64.tar.gz
bin/linux-amd64/matchbox: GOARGS = GOOS=linux GOARCH=amd64
bin/linux-arm/matchbox: GOARGS = GOOS=linux GOARCH=arm GOARM=6
bin/linux-arm64/matchbox: GOARGS = GOOS=linux GOARCH=arm64
bin/darwin-amd64/matchbox: GOARGS = GOOS=darwin GOARCH=amd64
bin/darwin-arm64/matchbox: GOARGS = GOOS=darwin GOARCH=arm64
bin/linux-ppc64le/matchbox: GOARGS = GOOS=linux GOARCH=ppc64le
bin/%/matchbox:
$(GOARGS) go build -o $@ -ldflags $(LD_FLAGS) -a $(REPO)/cmd/matchbox
_output/matchbox-%.tar.gz: NAME=matchbox-$(VERSION)-$*
_output/matchbox-%.tar.gz: DEST=_output/$(NAME)
_output/matchbox-%.tar.gz: bin/%/matchbox
mkdir -p $(DEST)
cp bin/$*/matchbox $(DEST)
./scripts/dev/release-files $(DEST)
tar zcvf $(DEST).tar.gz -C _output $(NAME)
.PHONY: all build clean test release
.SECONDARY: _output/matchbox-linux-amd64 _output/matchbox-darwin-amd64
release-sign:
gpg2 --armor --detach-sign _output/matchbox-$(VERSION)-linux-amd64.tar.gz
gpg2 --armor --detach-sign _output/matchbox-$(VERSION)-linux-arm.tar.gz
gpg2 --armor --detach-sign _output/matchbox-$(VERSION)-linux-arm64.tar.gz
gpg2 --armor --detach-sign _output/matchbox-$(VERSION)-darwin-amd64.tar.gz
gpg2 --armor --detach-sign _output/matchbox-$(VERSION)-darwin-arm64.tar.gz
release-verify: NAME=_output/matchbox
release-verify:
gpg2 --verify $(NAME)-$(VERSION)-linux-amd64.tar.gz.asc $(NAME)-$(VERSION)-linux-amd64.tar.gz
gpg2 --verify $(NAME)-$(VERSION)-linux-arm.tar.gz.asc $(NAME)-$(VERSION)-linux-arm.tar.gz
gpg2 --verify $(NAME)-$(VERSION)-linux-arm64.tar.gz.asc $(NAME)-$(VERSION)-linux-arm64.tar.gz
gpg2 --verify $(NAME)-$(VERSION)-darwin-amd64.tar.gz.asc $(NAME)-$(VERSION)-darwin-amd64.tar.gz
gpg2 --verify $(NAME)-$(VERSION)-darwin-arm64.tar.gz.asc $(NAME)-$(VERSION)-darwin-arm64.tar.gz