-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
61 lines (47 loc) · 1.76 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
default: build
NAME:=gitlab-multirepo-deployer
ifeq ($(VERSION),)
VERSION_TAG=$(shell git describe --abbrev=0 --tags --exact-match 2>/dev/null || git describe --abbrev=0 --all)-$(shell date +"%Y%m%d%H%M%S")
else
VERSION_TAG=$(VERSION)-$(shell date +"%Y%m%d%H%M%S")
endif
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
.PHONY: help
help:
@cat docs/developer-guide/make-targets.md
.PHONY: release
release: linux alpine compress
.PHONY: build
build:
go build -o ./.bin/$(NAME) -ldflags "-X \"main.version=$(VERSION_TAG)\"" main.go
.PHONY: linux
linux:
GOOS=linux GOARCH=amd64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME)_linux-amd64
cp .bin/$(NAME)_linux-amd64 .bin/$(NAME)
GOOS=linux GOARCH=arm64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME)_linux-arm64
.PHONY: alpine
alpine:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME)_alpine-amd64
GCGO_ENABLED=0 OOS=linux GOARCH=arm64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME)_alpine-arm64
.PHONY: darwin
darwin:
GOOS=darwin GOARCH=amd64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME)_darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME)_darwin-arm64
.PHONY: windows
windows:
GOOS=windows GOARCH=amd64 go build -ldflags "-X \"main.version=$(VERSION_TAG)\"" -o .bin/$(NAME).exe
.PHONY: compress
compress:
upx -5 ./.bin/*
ls -al ./.bin
.PHONY: install
install:
cp ./.bin/$(NAME) /usr/local/bin/
.PHONY: lint
lint: build
golangci-lint run --verbose --print-resources-usage