-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (79 loc) · 3.03 KB
/
Copy pathMakefile
File metadata and controls
95 lines (79 loc) · 3.03 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
.PHONY: generate security fmt fmt-check vet check new-version run-unit run-unit-no-network run-integration clean-tests run-tests run install clean
# `sed -i` is not portable: GNU sed takes no argument after -i, while BSD/macOS
# sed requires a (possibly empty) backup-suffix argument. Detect which one we have.
ifeq ($(shell sed --version >/dev/null 2>&1 && echo gnu),gnu)
SED_INPLACE := sed -i
else
SED_INPLACE := sed -i ''
endif
# esbuild and sass needed
generate:
@echo "[*] Bundling JS with esbuild"
@esbuild assets/js/src/main.js --bundle --minify --outfile=httpserver/static/js/main.min.js
@echo "[*] Compiling SCSS"
@sass --no-source-map -s compressed assets/css/src/main.scss httpserver/static/css/style.css
@echo "[OK] Done bundling 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"
fmt:
@gofmt -w .
@echo "[OK] Formatted"
fmt-check:
@test -z "$$(gofmt -l .)" || { echo "[!] Needs gofmt:"; gofmt -l .; exit 1; }
@echo "[OK] Formatting clean"
vet:
@echo "[*] Running go vet"
@go vet ./...
@echo "[OK] go vet clean"
# on-demand quality gate (formatting + vet); security and tests are run separately
check: fmt-check vet
new-version:
ifndef VERSION
$(error Usage: make new-version VERSION=vX.Y.Z)
endif
@echo "Updating version to $(VERSION)..."
@$(SED_INPLACE) 's/var GoshsVersion = "v[^"]*"/var GoshsVersion = "$(VERSION)"/' goshsversion/version.go
@SPECVER=$$(echo "$(VERSION)" | sed 's/^v//'); \
DATE=$$(date '+%a %b %d %Y'); \
$(SED_INPLACE) "s|^Version:.*|Version: $$SPECVER|" packaging/rpm/goshs.spec; \
awk -v date="$$DATE" -v specver="$$SPECVER" -v ver="$(VERSION)" '\
{ print } \
/^%changelog/ { \
print "* " date " Patrick Hener <patrickhener@gmx.de> - " specver "-1"; \
print "- Add new version " ver; \
}' packaging/rpm/goshs.spec > packaging/rpm/goshs.spec.tmp && \
mv packaging/rpm/goshs.spec.tmp packaging/rpm/goshs.spec
@git add goshsversion/version.go packaging/rpm/goshs.spec
@git commit -m "New version $(VERSION)"
@git push
@git tag -a $(VERSION) -m "Release $(VERSION)"
@git push origin $(VERSION)
@echo "[*] Tag pushed. Release binaries, packages, and Docker images are built and published by CI."
@echo " See .github/workflows/release.yml and docker-release.yml"
run-unit: clean-tests
@go test $$(go list ./... | grep -v /integration) -count=1
run-unit-no-network:
@go test -short $$(go list ./... | grep -v /integration) -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/
@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!"