-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
89 lines (76 loc) · 2.17 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
default: help
.PHONY: help
help:
@echo "What you can do with this Makefile"
@echo " make mac - make the executable for macOS"
@echo " make linux - make the executable for Linux"
@echo ""
@echo "Check the Makefile for more options."
.PHONY: linux
linux: std-linux-bin
# Comment out upx as it seems causing problems.
# upx logspout
.PHONY: std-linux-bin
std-linux-bin: clean generate
env GOOS=linux GOARCH=amd64 go build
.PHONY: std-bin
std-bin: clean generate
go build
.PHONY: bin
mac: std-bin
# Comment out upx as it seems causing problems.
# upx logspout
.PHONY: clean-bin
clean-bin:
rm -f logspout
.PHONY: clean-logs
clean-logs:
rm -f *.log
.PHONY: clean
clean: clean-bin clean-logs
.PHONY: generate
generate: clean-generated
go generate ./...
clean-generated:
rm output/type_jsonenums.go
.PHONY: test
test: generate
go test -v -race ./...
are-you-sure:
@read -p "I suppose you know what you are doing. Are you sure? [Y/n]" -n 1 -r; \
if [[ $$REPLY != "Y" ]]; then \
echo -e -n "\nSee you. >> "; \
exit 1; \
fi
@echo -e "\nGood, proceeding..."; \
$(eval confirmed := "Yes")
# Change the value of initVersion and tag it with the version number.
# Usage: make VERSION=blabla tag-and-release
# TODO: It is deprecated and will be replaced by a safer way soon.
tag-and-release: are-you-sure
# VERSION must be set
@if [ -z "$$VERSION" ]; then \
echo -e "The VERSION is unset or an empty string"; \
exit 1; \
fi
# Let you know what you are doing.
@echo -e "Changing the version number and tag it with ${VERSION}."
# Stash your current work, in case of any
@git stash
# We tag and release on the master branch
@git checkout master
# Make sure it's up-to-date
@git fetch origin
@git reset --hard origin/master
# Replace the version with the value provided by you
@sed -i 's/const logspoutVersion = ".*"/const logspoutVersion = "${VERSION}"/' version.go
# And commit it
@git add version.go
@git commit -m "Changed version to ${VERSION}"
# Now we create tags as a release
@git tag -a ${VERSION} -m "Version: ${VERSION}"
# Push it to the remote master branch
@git push origin master --follow-tags
# Resume your workspace
@git checkout ${prev_branch}
@git stash pop