This repository has been archived by the owner on Nov 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
55 lines (45 loc) · 1.56 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
.PHONY: clean lint changelog snapshot release
.PHONY: build
.PHONY: deps
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
VERSION ?= $(shell git describe --tags `git rev-list --tags --max-count=1`)
BINARY = lpweb
MAIN = main.go
BUILDDIR = build
GITREV = $(shell git rev-parse --short HEAD)
BUILDTIME = $(shell date +'%FT%TZ%z')
GO_BUILDER_VERSION=latest
deps:
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
go get -u golang.org/x/tools/cmd/goimports
build:
go build -o $(shell pwd)/$(BUILDDIR)/$(BINARY) $(shell pwd)/$(MAIN)
@echo "Build $(BINARY) done."
@echo "Run \"$(shell pwd)/$(BUILDDIR)/$(BINARY)\" to start $(BINARY)."
clean:
rm -rf $(shell pwd)/$(BUILDDIR)/
changelog:
git-chglog $(VERSION) > CHANGELOG.md
snapshot:
docker run --rm --privileged \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/lpweb \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /lpweb \
ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) --snapshot --clean
release: changelog
docker run --rm --privileged \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/lpweb \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /lpweb \
ghcr.io/gythialy/golang-cross:$(GO_BUILDER_VERSION) --rm-dist --release-notes=CHANGELOG.md
lint:
golangci-lint run --fix