-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
64 lines (55 loc) · 1.74 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
VERSION=v7.1.2
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOLINT=golangci-lint run
BUILD_PLATFORM=linux/amd64
PACKAGE_PLATFORM=$(BUILD_PLATFORM),linux/arm64,linux/arm/v7
PACKAGE_PLATFORM=$(BUILD_PLATFORM)
VERSION_MAJOR=$(shell echo $(VERSION) | cut -f1 -d.)
VERSION_MINOR=$(shell echo $(VERSION) | cut -f2 -d.)
BINARY_NAME=alephium-mining-companion
GO_PACKAGE=touilleio/alephium-mining-companion
DOCKER_REGISTRY=
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
BUILD_DATE=$(shell date '+%Y-%m-%d-%H:%M:%S')
all: ensure build package
ensure:
$(GOCMD) mod download
clean:
$(GOCLEAN)
lint:
$(GOLINT) ...
build:
env CGO_ENABLED=0 $(GOCMD) mod download && \
env CGO_ENABLED=0 \
$(GOBUILD) \
-ldflags "-X github.com/sqooba/go-common/version.GitCommit=${GIT_COMMIT}${GIT_DIRTY} \
-X github.com/sqooba/go-common/version.BuildDate=${BUILD_DATE} \
-X github.com/sqooba/go-common/version.Version=${VERSION}" \
-o $(BINARY_NAME) \
.
package:
docker buildx build -f Dockerfile \
--platform $(BUILD_PLATFORM) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR).$(VERSION_MINOR) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR) \
--load --no-cache \
.
test:
go test ./...
release:
docker buildx build -f Dockerfile \
--platform $(PACKAGE_PLATFORM) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR).$(VERSION_MINOR) \
-t ${DOCKER_REGISTRY}${GO_PACKAGE}:$(VERSION_MAJOR) \
--push \
.