Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. format:
  11. go fmt ./...
  12. test: format
  13. go get golang.org/x/lint/golint
  14. go vet ./...
  15. golint ./...
  16. go test ./... --race $(PKG) -v
  17. build: format
  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) .