-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
58 lines (49 loc) · 1.33 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
.DEFAULT_GOAL := build
VERSION := $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
GIT_HASH := $(shell git rev-parse HEAD)
BUILD_TIME := $(shell date -u | sed 's| |_|'g)
.PHONY: run
run: build
./config
.PHONY: build
build:
CGO_ENABLED=0 \
go build \
-v \
-ldflags="-s -w -X main.GitHash=$(GIT_HASH) -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" \
-o bin/ ./cmd/cfg
.PHONY: install
install:
CGO_ENABLED=0 \
go build \
-v \
-ldflags="-s -w -X main.GitHash=$(GIT_HASH) -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" \
./cmd/cfg
.PHONY: generate-release-artifacts
generate-release-artifacts:
make build-release GOOS="darwin" GOARCH="arm64"
make build-release GOOS="darwin" GOARCH="amd64"
make build-release GOOS="linux" GOARCH="arm64"
make build-release GOOS="linux" GOARCH="amd64"
.PHONY: build-release
build-release:
CGO_ENABLED=0 \
GOOS=$(GOOS) \
GOARCH=$(GOARCH) \
go build \
-ldflags="-s -w -X main.GitHash=$(GIT_HASH) -X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)" \
-o bin/cfg_$(GOOS)-$(GOARCH) ./cmd/cfg
.PHONY: gofmt
gofmt:
gofmt -l -s -w ./cmd/cfg ./pkg
.PHONY: mod
mod:
go mod tidy
.PHONY: lint
lint:
docker run \
--rm -it \
-w /sources \
-v $(shell PWD):/sources \
golangci/golangci-lint:v1.59.1 \
golangci-lint -v -c .golangci.yml run