Makefile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/v7/version.Version=$(VERSION)"
  5. _LDFLAGS="github.com/zricethezav/gitleaks/v7/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. build:
  17. go fmt ./...
  18. golint ./...
  19. go vet ./...
  20. go mod tidy
  21. go build $(LDFLAGS)
  22. security-scan:
  23. go get github.com/securego/gosec/cmd/gosec
  24. gosec -no-fail ./...
  25. release-builds:
  26. rm -rf build
  27. mkdir build
  28. env GOOS="windows" GOARCH="amd64" go build -o "build/gitleaks-windows-amd64.exe" $(LDFLAGS)
  29. env GOOS="windows" GOARCH="386" go build -o "build/gitleaks-windows-386.exe" $(LDFLAGS)
  30. env GOOS="linux" GOARCH="amd64" go build -o "build/gitleaks-linux-amd64" $(LDFLAGS)
  31. env GOOS="linux" GOARCH="arm" go build -o "build/gitleaks-linux-arm" $(LDFLAGS)
  32. env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
  33. env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips" $(LDFLAGS)
  34. env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64" $(LDFLAGS)
  35. deploy:
  36. @echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
  37. docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .
  38. echo "Pushing zricethezav/gitleaks:$(VERSION) and zricethezav/gitleaks:latest"
  39. docker push zricethezav/gitleaks
  40. dockerbuild:
  41. docker build --build-arg ldflags=$(_LDFLAGS) -f Dockerfile -t zricethezav/gitleaks:latest -t zricethezav/gitleaks:$(VERSION) .