-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (33 loc) · 1.08 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
VERSION ?= 0.3.0
BINARY_DIR ?= dist
BINARY_NAME ?= ssl-pubkey-fingerprint-exporter
PLATFORMS ?= linux/amd64 windows/amd64 darwin/amd64 darwin/arm64
GO ?= go
GOOPTS ?=
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
DOCKER ?= docker
DOCKER_REPO ?= basa
DOCKER_IMAGE_NAME ?= ssl-pubkey-fingerprint-exporter
DOCKER_ARCH ?= linux/amd64
SHA256SUM ?= sha256sum
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
_OS = $(word 1, $(subst /, ,$@))
_ARCH = $(word 2, $(subst /, ,$@))
build: $(GOHOSTOS)/$(GOHOSTARCH)
build-all: $(PLATFORMS)
test:
$(GO) test
$(PLATFORMS):
CGO_ENABLED=0 GOOS=$(_OS) GOARCH=$(_ARCH) $(GO) build \
-o $(BINARY_DIR)/$(BINARY_NAME)-$(_OS)-$(_ARCH)
docker:
$(DOCKER) build \
--build-arg VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
-t $(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(VERSION) .
release: test $(PLATFORMS)
$(SHA256SUM) $(BINARY_DIR)/$(BINARY_NAME)* | sed "s|$(BINARY_DIR)/||" > $(BINARY_DIR)/sha256sums.txt
clean:
$(GO) clean
rm -rf $(BINARY_DIR)