Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. .PHONY: test test-cover build release-builds
  2. VERSION := `git fetch --tags && git tag | sort -V | tail -1`
  3. PKG=github.com/zricethezav/gitleaks
  4. LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v5/version.Version=$(VERSION)"
  5. _LDFLAGS="github.com/zricethezav/gitleaks/v5/version.Version=$(VERSION)"
  6. COVER=--cover --coverprofile=cover.out
  7. test-cover:
  8. go test ./... --race $(COVER) $(PKG) -v
  9. go tool cover -html=cover.out
  10. test:
  11. go get golang.org/x/lint/golint
  12. go fmt ./...
  13. go vet ./...
  14. golint ./...
  15. go test ./... --race $(PKG) -v
  16. test-integration:
  17. go test github.com/zricethezav/gitleaks/hosts -v -integration
  18. build:
  19. go fmt ./...
  20. golint ./...
  21. go vet ./...
  22. go mod tidy
  23. go build $(LDFLAGS)
  24. security-scan:
  25. go get github.com/securego/gosec/cmd/gosec
  26. gosec -no-fail ./...
  27. release-builds:
  28. rm -rf build
  29. mkdir build
  30. env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe" $(LDFLAGS)
  31. env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe" $(LDFLAGS)
  32. env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64" $(LDFLAGS)
  33. env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm" $(LDFLAGS)
  34. env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
  35. env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
  36. env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64" $(LDFLAGS)
  37. deploy:
  38. @echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
  39. docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
  40. echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
  41. docker push zricethezav/gitleaks
  42. dockerbuild:
  43. docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .