-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathMakefile
More file actions
173 lines (152 loc) · 6.95 KB
/
Makefile
File metadata and controls
173 lines (152 loc) · 6.95 KB
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
.PHONY: build-all
# uglify-js and sass needed
generate:
@echo "[*] Minifying js and compiling scss"
@uglifyjs -o httpserver/static/js/main.min.js assets/js/main.js
@uglifyjs -o httpserver/static/js/color-modes.min.js assets/js/color-modes.js
@sass --no-source-map -s compressed assets/css/style.scss httpserver/static/css/style.css
@echo "[OK] Done minifying and compiling things"
@echo "[*] Copying embedded files to target location"
@rm -rf httpserver/embedded
@cp -r embedded httpserver/
security:
@echo "[*] Checking with gosec"
@gosec ./...
@echo "[OK] No issues detected"
build-all: clean generate build-linux build-mac build-windows build-dragonfly build-freebsd build-openbsd build-netbsd
build-linux: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for linux"
@GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/linux_amd64/goshs
@GOOS=linux GOARCH=386 go build -ldflags="-s -w" -o dist/linux_386/goshs
@GOOS=linux GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o dist/linux_arm_5/goshs
@GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o dist/linux_arm_6/goshs
@GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/linux_arm_7/goshs
@GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o dist/linux_arm64_8/goshs
@echo "[OK] App binary was created!"
build-mac: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for mac"
@GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o dist/darwin_amd64/goshs
@GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o dist/darwin_arm64/goshs
@echo "[OK] App binary was created!"
build-windows: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for windows"
@GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o dist/windows_amd64/goshs.exe
@GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o dist/windows_386/goshs.exe
@GOOS=windows GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o dist/windows_arm_5/goshs.exe
@GOOS=windows GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o dist/windows_arm_6/goshs.exe
@GOOS=windows GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/windows_arm_7/goshs.exe
@GOOS=windows GOARCH=arm64 go build -ldflags="-s -w" -o dist/windows_arm64_8/goshs.exe
@echo "[OK] App binary was created!"
build-dragonfly: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for dragonfly"
@GOOS=dragonfly GOARCH=amd64 go build -ldflags="-s -w" -o dist/dragonfly_amd64/goshs
@echo "[OK] App binary was created!"
build-freebsd: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for freebsd"
@GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -o dist/freebsd_amd64/goshs
@GOOS=freebsd GOARCH=386 go build -ldflags="-s -w" -o dist/freebsd_386/goshs
@GOOS=freebsd GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o dist/freebsd_arm_5/goshs
@GOOS=freebsd GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o dist/freebsd_arm_6/goshs
@GOOS=freebsd GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/freebsd_arm_7/goshs
@GOOS=freebsd GOARCH=arm64 go build -ldflags="-s -w" -o dist/freebsd_arm64_8/goshs
@echo "[OK] App binary was created!"
build-openbsd: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for openbsd"
@GOOS=openbsd GOARCH=amd64 go build -ldflags="-s -w" -o dist/openbsd_amd64/goshs
@GOOS=openbsd GOARCH=386 go build -ldflags="-s -w" -o dist/openbsd_386/goshs
@GOOS=openbsd GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o dist/openbsd_arm_5/goshs
@GOOS=openbsd GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o dist/openbsd_arm_6/goshs
@GOOS=openbsd GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/openbsd_arm_7/goshs
@GOOS=openbsd GOARCH=arm64 go build -ldflags="-s -w" -o dist/openbsd_arm64_8/goshs
@echo "[OK] App binary was created!"
build-netbsd: clean generate
@echo "[*] go mod dowload"
@go mod download
@echo "[*] Building for netbsd"
@GOOS=netbsd GOARCH=amd64 go build -ldflags="-s -w" -o dist/netbsd_amd64/goshs
@GOOS=netbsd GOARCH=386 go build -ldflags="-s -w" -o dist/netbsd_386/goshs
@GOOS=netbsd GOARCH=arm GOARM=5 go build -ldflags="-s -w" -o dist/netbsd_arm_5/goshs
@GOOS=netbsd GOARCH=arm GOARM=6 go build -ldflags="-s -w" -o dist/netbsd_arm_6/goshs
@GOOS=netbsd GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/netbsd_arm_7/goshs
@GOOS=netbsd GOARCH=arm64 go build -ldflags="-s -w" -o dist/netbsd_arm64_8/goshs
@echo "[OK] App binary was created!"
new-version:
ifndef VERSION
$(error Usage: make new-version VERSION=vX.Y.Z)
endif
@echo "Updating version to $(VERSION)..."
@sed -i 's/var GoshsVersion = "v[^"]*"/var GoshsVersion = "$(VERSION)"/' goshsversion/version.go
@sed -i 's|https://img.shields.io/badge/Version-v[^-]*-green|https://img.shields.io/badge/Version-$(VERSION)-green|' README.md
@git add goshsversion/version.go README.md
@git commit -m "New version $(VERSION)"
@git push
@git tag $(VERSION)
@git push origin $(VERSION)
@docker build -t patrickhener/goshs:$(VERSION) .
@docker build -t patrickhener/goshs:latest .
@docker push patrickhener/goshs:$(VERSION)
@docker push patrickhener/goshs:latest
run-unit: clean-tests
@go test ./ca -count=1
@go test ./cli -count=1
@go test ./clipboard -count=1
@go test ./config -count=1
@go test ./logger -count=1
@go test ./sftpserver -count=1
@go test ./update -count=1
@go test ./utils -count=1
@go test ./webhook -count=1
@go test ./ws -count=1
run-unit-no-network:
@go test -short ./ca -count=1
@go test -short ./cli -count=1
@go test -short ./clipboard -count=1
@go test -short ./config -count=1
@go test -short ./logger -count=1
@go test -short ./sftpserver -count=1
@go test -short ./update -count=1
@go test -short ./utils -count=1
@go test -short ./webhook -count=1
@go test -short ./ws -count=1
run-integration: clean-tests
@go test -v ./integration -count=1
clean-tests:
@mkdir -p ./integration/files
@rm -rf ./integration/files/*
@cp ./integration/keepFiles/test_data.txt ./integration/files/
@mkdir ./integration/files/ACL
@mkdir ./integration/files/ACL/testfolder
@mkdir ./integration/files/ACLAuth
@mkdir ./integration/files/ACLAuth/testfolder
@cp ./integration/keepFiles/goshsACL ./integration/files/ACL/.goshs
@cp ./integration/keepFiles/testfile.txt ./integration/files/ACL/
@cp ./integration/keepFiles/testfile2.txt ./integration/files/ACL/
@cp ./integration/keepFiles/testfile2.txt ./integration/files/ACL/testfolder/
@cp ./integration/keepFiles/goshsACLAuth ./integration/files/ACLAuth/.goshs
@cp ./integration/keepFiles/testfile.txt ./integration/files/ACLAuth/
@cp ./integration/keepFiles/testfile2.txt ./integration/files/ACLAuth/
@cp ./integration/keepFiles/testfile2.txt ./integration/files/ACLAuth/testfolder/
@rm -rf ./sftpserver/testdir
@rm -f ./sftpserver/test.txt
@echo "cleaned up, ready for next test"
run-tests: run-unit run-integration
run:
@go run main.go
install:
@go install ./...
@echo "[OK] Application was installed to go binary directory!"
clean:
@rm -rf ./dist
@echo "[OK] Cleaned up!"