forked from jenkins-x-plugins/jx-release-version
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (31 loc) · 857 Bytes
/
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
NAME := jx-release-version
ORG := jenkins-x
ROOT_PACKAGE := main.go
GO := GO15VENDOREXPERIMENT=1 go
PACKAGE_DIRS := $(shell $(GO) list ./... | grep -v /vendor/)
FORMATTED := $(shell $(GO) fmt $(PACKAGE_DIRS))
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
BUILD_DIR ?= ./bin
BUILDFLAGS := '-w -s'
all: test build
check: fmt test
.PHONY: build
build:
CGO_ENABLED=0 GOARCH=amd64 go build -ldflags $(BUILDFLAGS) -o $(BUILD_DIR)/$(NAME) $(ROOT_PACKAGE)
fmt:
@FORMATTED=`$(GO) fmt $(PACKAGE_DIRS)`
@([[ ! -z "$(FORMATTED)" ]] && printf "Fixed unformatted files:\n$(FORMATTED)") || true
.PHONY: test
test:
go test -v $(GOPACKAGES)
.PHONY: release
release: clean test
goreleaser release
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
rm -rf dist
.PHONY: docker
docker: $(BUILD_DIR)/$(NAME)-linux
docker build -t "${ORG}/$(NAME):dev" .