diff --git a/.toolbox.mk b/.toolbox.mk new file mode 100644 index 0000000..6ef367f --- /dev/null +++ b/.toolbox.mk @@ -0,0 +1,62 @@ +## toolbox - start +## Generated with https://github.com/bakito/toolbox + +## Current working directory +TB_LOCALDIR ?= $(shell which cygpath > /dev/null 2>&1 && cygpath -m $$(pwd) || pwd) +## Location to install dependencies to +TB_LOCALBIN ?= $(TB_LOCALDIR)/bin +$(TB_LOCALBIN): + mkdir -p $(TB_LOCALBIN) + +## Tool Binaries +TB_GOLANGCI_LINT ?= $(TB_LOCALBIN)/golangci-lint +TB_GORELEASER ?= $(TB_LOCALBIN)/goreleaser +TB_MOCKGEN ?= $(TB_LOCALBIN)/mockgen +TB_SEMVER ?= $(TB_LOCALBIN)/semver + +## Tool Versions +# renovate: packageName=github.com/golangci/golangci-lint/cmd/golangci-lint +TB_GOLANGCI_LINT_VERSION ?= v1.61.0 +# renovate: packageName=github.com/goreleaser/goreleaser/v2 +TB_GORELEASER_VERSION ?= v2.3.2 +# renovate: packageName=go.uber.org/mock/mockgen +TB_MOCKGEN_VERSION ?= v0.4.0 +# renovate: packageName=github.com/bakito/semver +TB_SEMVER_VERSION ?= v1.1.3 + +## Tool Installer +.PHONY: tb.golangci-lint +tb.golangci-lint: $(TB_GOLANGCI_LINT) ## Download golangci-lint locally if necessary. +$(TB_GOLANGCI_LINT): $(TB_LOCALBIN) + test -s $(TB_LOCALBIN)/golangci-lint || GOBIN=$(TB_LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(TB_GOLANGCI_LINT_VERSION) +.PHONY: tb.goreleaser +tb.goreleaser: $(TB_GORELEASER) ## Download goreleaser locally if necessary. +$(TB_GORELEASER): $(TB_LOCALBIN) + test -s $(TB_LOCALBIN)/goreleaser || GOBIN=$(TB_LOCALBIN) go install github.com/goreleaser/goreleaser/v2@$(TB_GORELEASER_VERSION) +.PHONY: tb.mockgen +tb.mockgen: $(TB_MOCKGEN) ## Download mockgen locally if necessary. +$(TB_MOCKGEN): $(TB_LOCALBIN) + test -s $(TB_LOCALBIN)/mockgen || GOBIN=$(TB_LOCALBIN) go install go.uber.org/mock/mockgen@$(TB_MOCKGEN_VERSION) +.PHONY: tb.semver +tb.semver: $(TB_SEMVER) ## Download semver locally if necessary. +$(TB_SEMVER): $(TB_LOCALBIN) + test -s $(TB_LOCALBIN)/semver || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/semver@$(TB_SEMVER_VERSION) + +## Reset Tools +.PHONY: tb.reset +tb.reset: + @rm -f \ + $(TB_LOCALBIN)/golangci-lint \ + $(TB_LOCALBIN)/goreleaser \ + $(TB_LOCALBIN)/mockgen \ + $(TB_LOCALBIN)/semver + +## Update Tools +.PHONY: tb.update +tb.update: tb.reset + toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \ + github.com/golangci/golangci-lint/cmd/golangci-lint \ + github.com/goreleaser/goreleaser/v2 \ + go.uber.org/mock/mockgen@github.com/uber-go/mock \ + github.com/bakito/semver +## toolbox - end \ No newline at end of file diff --git a/Makefile b/Makefile index 53f224a..e6b1117 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +# Include toolbox tasks +include ./.toolbox.mk + lint: golangci-lint $(GOLANGCI_LINT) run --fix @@ -31,59 +34,3 @@ mocks: mockgen $(MOCKGEN) -destination pkg/mocks/client/mock.go k8s.io/client-go/dynamic Interface $(MOCKGEN) -destination pkg/mocks/mapper/mock.go k8s.io/apimachinery/pkg/api/meta RESTMapper -## toolbox - start -## Current working directory -LOCALDIR ?= $(shell which cygpath > /dev/null 2>&1 && cygpath -m $$(pwd) || pwd) -## Location to install dependencies to -LOCALBIN ?= $(LOCALDIR)/bin -$(LOCALBIN): - mkdir -p $(LOCALBIN) - -## Tool Binaries -GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint -GORELEASER ?= $(LOCALBIN)/goreleaser -MOCKGEN ?= $(LOCALBIN)/mockgen -SEMVER ?= $(LOCALBIN)/semver - -## Tool Versions -# renovate: packageName=github.com/golangci/golangci-lint/cmd/golangci-lint -GOLANGCI_LINT_VERSION ?= v1.61.0 -# renovate: packageName=github.com/goreleaser/goreleaser/v2 -GORELEASER_VERSION ?= v2.3.2 -# renovate: packageName=go.uber.org/mock/mockgen -MOCKGEN_VERSION ?= v0.4.0 -# renovate: packageName=github.com/bakito/semver -SEMVER_VERSION ?= v1.1.3 - -## Tool Installer -.PHONY: golangci-lint -golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. -$(GOLANGCI_LINT): $(LOCALBIN) - test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) -.PHONY: goreleaser -goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary. -$(GORELEASER): $(LOCALBIN) - test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser/v2@$(GORELEASER_VERSION) -.PHONY: mockgen -mockgen: $(MOCKGEN) ## Download mockgen locally if necessary. -$(MOCKGEN): $(LOCALBIN) - test -s $(LOCALBIN)/mockgen || GOBIN=$(LOCALBIN) go install go.uber.org/mock/mockgen@$(MOCKGEN_VERSION) -.PHONY: semver -semver: $(SEMVER) ## Download semver locally if necessary. -$(SEMVER): $(LOCALBIN) - test -s $(LOCALBIN)/semver || GOBIN=$(LOCALBIN) go install github.com/bakito/semver@$(SEMVER_VERSION) - -## Update Tools -.PHONY: update-toolbox-tools -update-toolbox-tools: - @rm -f \ - $(LOCALBIN)/golangci-lint \ - $(LOCALBIN)/goreleaser \ - $(LOCALBIN)/mockgen \ - $(LOCALBIN)/semver - toolbox makefile --renovate -f $(LOCALDIR)/Makefile \ - github.com/golangci/golangci-lint/cmd/golangci-lint \ - github.com/goreleaser/goreleaser/v2 \ - go.uber.org/mock/mockgen@github.com/uber-go/mock \ - github.com/bakito/semver -## toolbox - end diff --git a/renovate.json b/renovate.json index ad6aea8..2766382 100644 --- a/renovate.json +++ b/renovate.json @@ -4,9 +4,9 @@ { "customType": "regex", "datasourceTemplate": "go", - "description": "Update toolbox tools in Makefile", + "description": "Update toolbox tools in .toolbox.mk", "fileMatch": [ - "^Makefile$" + "^\\.toolbox\\.mk$" ], "matchStrings": [ "# renovate: packageName=(?.+?)\\s+.+?_VERSION \\?= (?.+?)\\s"