forked from arnisoph/postisto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (64 loc) · 2.61 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
appname := postisto
sources = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
timestamp = $(shell date +"%Y.%m.%d")
gitrev = $(shell git rev-parse --short HEAD)
artifact_version = v$(timestamp)-$(gitrev)
build = GOOS=$(1) GOARCH=$(2) GOARM=$(4) go build -trimpath -ldflags "-X=main.build=$(artifact_version)" -o build/$(appname)$(3) cmd/$(appname)/main.go
tar = cd build && tar -cvzf $(appname)-$(artifact_version).$(1)-$(2).tar.gz $(appname)$(3) && rm $(appname)$(3)
zip = cd build && zip $(appname)-$(artifact_version).$(1)-$(2).zip $(appname)$(3) && rm $(appname)$(3)
all: build test install
.PHONY: build test go.test clean fmt vendor-update vendor docker-build release github-release docker-release install version git-release
build: clean docker-build windows darwin linux
build/$(appname): $(sources)
go build -ldflags "-X=main.build=$(artifact_version)" -v -o build/$(appname) cmd/$(appname)/main.go
test: go.test
clean:
rm -rf build/*
rm -rf postisto
install: build/$(appname)
cp build/$(appname) $(GOBIN)/postisto
uninstall:
rm -f $(GOBIN)/postisto
fmt:
go fmt ./...
go.test:
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
go.get:
go mod download
vendor:
go mod vendor
cd cmd/postisto/ && go get -u=patch
cd test/integration/ && go get -u=patch
go mod tidy
docker-build:
$(call build,linux,amd64,)
docker build -t ghcr.io/arnisoph/postisto/linux:$(artifact_version) .
make clean
docker-release: docker-build
docker push ghcr.io/arnisoph/postisto/linux:$(artifact_version)
git-release:
git tag $(artifact_version)
release: git-release build docker-release
version:
@echo $(artifact_version)
##### LINUX #####
linux: build/$(appname)-$(artifact_version).linux-amd64.tar.gz build/$(appname)-$(artifact_version).linux-arm7.tar.gz
build/$(appname)-$(artifact_version).linux-amd64.tar.gz: $(sources)
$(call build,linux,amd64,)
$(call tar,linux,amd64)
build/$(appname)-$(artifact_version).linux-arm7.tar.gz: $(sources)
$(call build,linux,arm,,7)
$(call tar,linux,arm7)
##### DARWIN (MAC) #####
darwin: build/$(appname)-$(artifact_version).darwin-amd64.tar.gz
build/$(appname)-$(artifact_version).darwin-amd64.tar.gz: $(sources)
$(call build,darwin,amd64,)
$(call tar,darwin,amd64)
##### WINDOWS #####
windows: build/$(appname)-$(artifact_version).windows-amd64.zip build/$(appname)-$(artifact_version).windows-arm7.zip
build/$(appname)-$(artifact_version).windows-amd64.zip: $(sources)
$(call build,windows,amd64,.exe,)
$(call zip,windows,amd64,.exe)
build/$(appname)-$(artifact_version).windows-arm7.zip: $(sources)
$(call build,windows,arm,.exe,7)
$(call zip,windows,arm7,.exe)