-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
130 lines (114 loc) · 4.92 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
UNAME := $(shell uname)
.PHONY: release
release: update-licenses package-windows package-linux-amd64 package-linux-arm package-windows-bot package-linux-amd64-bot package-linux-arm-bot bundle-artifacts
.PHONY: update-licenses
update-licenses:
go-licenses report ./... --template=oss-template.tmpl > oss-licenses.txt
.PHONY: generate
generate:
go generate ./...
.PHONY: windows
windows: generate
@echo "--------------------------------"
@echo "Building for Windows (amd64)"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/windows"
cd "cmd/realweather" && env GOOS=windows GOARCH=amd64 go build -o ../../bin/windows/realweather.exe -trimpath
.PHONY: package-windows
package-windows: windows
cp config/config.json bin/windows/config.json
cp oss-licenses.txt bin/windows/oss-licenses.txt
zip -j windows.zip bin/windows/realweather.exe bin/windows/config.json bin/windows/oss-licenses.txt
$(eval VERSION := $(shell cat versioninfo/version.txt))
mv windows.zip bin/windows/realweather_$(VERSION).zip
.PHONY: linux-amd64
linux-amd64: generate
@echo "--------------------------------"
@echo "Building for Linux (amd64)"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/linux"
-rm resource.syso
env GOOS=linux GOARCH=amd64 go build -o bin/linux/realweather -trimpath cmd/realweather/main.go
.PHONY: package-linux-amd64
package-linux-amd64: linux-amd64
cp config/config.json bin/linux/config.json
cp oss-licenses.txt bin/linux/oss-licenses.txt
$(eval VERSION := $(shell cat versioninfo/version.txt))
tar czf bin/linux/realweather_linux_amd64_$(VERSION).tar.gz -C bin/linux/ realweather config.json oss-licenses.txt
.PHONY: linux-arm
linux-arm: generate
@echo "--------------------------------"
@echo "Building for Linux (arm)"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/linux"
-rm resource.syso
env GOOS=linux GOARCH=arm go build -o bin/linux/realweather -trimpath cmd/realweather/main.go
.PHONY: package-linux-arm
package-linux-arm: linux-arm
cp config/config.json bin/linux/config.json
cp oss-licenses.txt bin/linux/oss-licenses.txt
$(eval VERSION := $(shell cat versioninfo/version.txt))
tar czf bin/linux/realweather_linux_arm_$(VERSION).tar.gz -C bin/linux/ realweather config.json oss-licenses.txt
.PHONY: windows-bot
windows-bot: generate
@echo "--------------------------------"
@echo "Building bot for Windows (amd64)"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/windows"
cd "cmd/bot" && env GOOS=windows GOARCH=amd64 go build -o ../../bin/windows/rwbot.exe -trimpath
.PHONY: package-windows-bot
package-windows-bot: windows-bot
cp cmd/bot/config/config.json bin/windows/botconfig.json
cp oss-licenses.txt bin/windows/oss-licenses.txt
zip -j windows.zip bin/windows/rwbot.exe bin/windows/botconfig.json bin/windows/oss-licenses.txt
$(eval VERSION := $(shell cat versioninfo/version.txt))
mv windows.zip bin/windows/rwbot_$(VERSION).zip
.PHONY: linux-amd64-bot
linux-amd64-bot: generate
@echo "--------------------------------"
@echo "Building bot for Linux (amd64)"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/linux"
-rm resource.syso
env GOOS=linux GOARCH=amd64 go build -o bin/linux/rwbot -trimpath cmd/bot/main.go
.PHONY: package-linux-amd64-bot
package-linux-amd64-bot: generate
cp cmd/bot/config/config.json bin/linux/botconfig.json
cp oss-licenses.txt bin/linux/oss-licenses.txt
$(eval VERSION := $(shell cat versioninfo/version.txt))
tar czf bin/linux/rwbot_linux_amd64_$(VERSION).tar.gz -C bin/linux/ rwbot botconfig.json oss-licenses.txt
.PHONY: linux-arm-bot
linux-arm-bot: generate
@echo "--------------------------------"
@echo "Building bot for Linux (arm)"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/linux"
-rm resource.syso
env GOOS=linux GOARCH=arm go build -o bin/linux/rwbot -trimpath cmd/bot/main.go
.PHONY: package-linux-arm-bot
package-linux-arm-bot: linux-arm-bot
cp cmd/bot/config/config.json bin/linux/botconfig.json
cp oss-licenses.txt bin/linux/oss-licenses.txt
$(eval VERSION := $(shell cat versioninfo/version.txt))
tar czf bin/linux/rwbot_linux_arm_$(VERSION).tar.gz -C bin/linux/ rwbot botconfig.json oss-licenses.txt
.PHONY: bundle-artifacts
bundle-artifacts:
@echo "--------------------------------"
@echo "Bundling all build artifacts"
@echo "--------------------------------"
-@mkdir "bin"
-@mkdir "bin/bundle"
$(eval VERSION := $(shell cat versioninfo/version.txt))
-rm bin/bundle/*
-cp bin/windows/realweather_$(VERSION).zip bin/bundle
-cp bin/windows/rwbot_$(VERSION).zip bin/bundle
-cp bin/linux/realweather_linux_amd64_$(VERSION).tar.gz bin/bundle
-cp bin/linux/rwbot_linux_amd64_$(VERSION).tar.gz bin/bundle
-cp bin/linux/realweather_linux_arm_$(VERSION).tar.gz bin/bundle
-cp bin/linux/rwbot_linux_arm_$(VERSION).tar.gz bin/bundle