-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
59 lines (50 loc) · 1.77 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
WORKDIR := $(shell pwd)
LATEST-GIT-SHA := $(shell git rev-parse HEAD)
VERSION := $(shell cat VERSION)
FLAGS := -X main.version=$(VERSION) -X main.commit=$(LATEST-GIT-SHA)
BIN := anklet
ARCH ?= $(shell arch)
ifeq ($(ARCH), i386)
ARCH = amd64
endif
ifeq ($(ARCH), x86_64)
ARCH = amd64
endif
OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
BIN_FULL ?= dist/$(BIN)_v$(VERSION)_$(OS_TYPE)_$(ARCH)
export PATH := $(shell go env GOPATH)/bin:$(PATH)
all: build-and-install
build-and-install: clean go.releaser install
#clean: @ Remove the build binaries
clean:
rm -rf dist
rm -f ~/bin/$(BIN)
#go.releaser @ Run goreleaser for current version
go.releaser:
git tag -d "$(VERSION)" 2>/dev/null || true
git tag -a "$(VERSION)" -m "Version $(VERSION)"
echo "LATEST TAG: $$(git describe --tags --abbrev=0)"
goreleaser release --verbose --clean
file dist/* | grep executable | awk '{print $1}' | cut -d: -f1 | xargs rm -f
#go.lint: @ Run `golangci-lint run` against the current code
go.lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.57.2
golangci-lint run --fast
go.test:
go mod tidy
# go test -v *
install:
mkdir -p ~/bin
cp -f dist/$(BIN)_v$(VERSION)_$(OS_TYPE)_$(ARCH) ~/bin/$(BIN)
go.build:
GOARCH=$(ARCH) go build $(RACE) -ldflags "-X main.version=$(VERSION)" -o dist/$(BIN)_v$(VERSION)_$(OS_TYPE)_$(ARCH)
chmod +x dist/$(BIN)_v$(VERSION)_$(OS_TYPE)_$(ARCH)
build-linux:
GOOS=linux OS_TYPE=linux $(MAKE) go.build
run-docker-compose:
cp dist/anklet_v$(VERSION)*_linux_$(ARCH) docker/
cd docker && \
rm -f anklet_linux_$(ARCH) && \
mv anklet_v$(VERSION)*_linux_$(ARCH) anklet_linux_$(ARCH) && \
rm -f anklet_v$(VERSION)*_linux_$(ARCH).zip && \
docker-compose up --build --force-recreate