Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #
  2. # botex - a bad bot mitigation tool by ScraperWall
  3. # Copyright (C) 2021 ScraperWall, Tobias von Dewitz <tobias@scraperwall.com>
  4. #
  5. # This program is free software: you can redistribute it and/or modify it
  6. # under the terms of the GNU Affero General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or (at your
  8. # option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but WITHOUT
  11. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
  13. # for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. #
  18. VERSION=$(shell git describe --tags | sed 's/^v//')
  19. BUILDDATE=$(shell date +%FT%T%z)
  20. HOST=$(shell hostname)
  21. NAME=$(shell basename $(PWD))
  22. all: image
  23. .PHONY: bin
  24. image:
  25. docker build \
  26. --rm \
  27. --build-arg VERSION=$(VERSION) \
  28. --build-arg BUILDDATE="$(BUILDDATE)" \
  29. --build-arg HOST=$(HOST) \
  30. -t registry.scw.systems/$(NAME):latest \
  31. -t registry.scw.systems/$(NAME):$(VERSION) \
  32. .
  33. release:
  34. docker push registry.scw.systems/$(NAME):latest
  35. docker push registry.scw.systems/$(NAME):$(VERSION)
  36. compile:
  37. docker run --rm -v $(PWD):/src \
  38. -w /src \
  39. golang:alpine \
  40. env CGO_ENABLED=0 go build \
  41. -tags netgo \
  42. -a -v \
  43. -mod=vendor \
  44. -ldflags "-s -X main.Version=$(VERSION) -X main.BuildDate=$(BUILDDATE) -X main.BuildHost=$(HOST) -extldflags 'static'"
  45. bin:
  46. env GOOS=linux GOARCH=amd64 go build -ldflags "-s -X main.Version=$(VERSION) -X main.BuildDate=$(BUILDDATE) -X main.BuildHost=$(HOST) -extldflags 'static'" -o ./bin/linux-amd64/botex ./cmd/botex
  47. cp LICENSE ./bin/linux-amd64/
  48. (cd bin/linux-amd64 && tar cvfz botex-linux-amd64-$(VERSION).tar.gz botex LICENSE)
  49. env GOOS=darwin GOARCH=amd64 go build -ldflags "-s -X main.Version=$(VERSION) -X main.BuildDate=$(BUILDDATE) -X main.BuildHost=$(HOST)" -o ./bin/darwin-amd64/botex ./cmd/botex
  50. cp LICENSE ./bin/darwin-amd64/
  51. (cd bin/darwin-amd64 && tar cvfz botex-darwin-amd64-$(VERSION).tar.gz botex LICENSE)
  52. env GOOS=darwin GOARCH=arm64 go build -ldflags "-s -X main.Version=$(VERSION) -X main.BuildDate=$(BUILDDATE) -X main.BuildHost=$(HOST)" -o ./bin/darwin-arm64/botex ./cmd/botex
  53. cp LICENSE ./bin/darwin-arm64/
  54. (cd bin/darwin-arm64 && tar cvfz botex-darwin-arm64-$(VERSION).tar.gz botex LICENSE)
  55. sha256sum bin/*/*.tar.gz | perl -pe 's:bin/.+?/::' > bin/checksums-$(VERSION).txt