From 056ac4c05b826c5fcfefb194f1c965b3486892d3 Mon Sep 17 00:00:00 2001 From: mrz1836 Date: Fri, 29 Oct 2021 12:36:15 -0400 Subject: [PATCH] Updated makefiles --- .make/common.mk | 15 +++++++++++++-- .make/go.mk | 23 +++++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.make/common.mk b/.make/common.mk index f99f95c..5d92c0a 100644 --- a/.make/common.mk +++ b/.make/common.mk @@ -41,39 +41,50 @@ diff: ## Show the git diff help: ## Show this help message @egrep -h '^(.+)\:\ ##\ (.+)' ${MAKEFILE_LIST} | column -t -c 2 -s ':#' +install-releaser: ## Install the GoReleaser application + @echo "installing GoReleaser..." + @curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh + release:: ## Full production release (creates release in Github) + @echo "releasing..." @test $(github_token) @export GITHUB_TOKEN=$(github_token) && goreleaser --rm-dist release-test: ## Full production test release (everything except deploy) + @echo "creating a release test..." @goreleaser --skip-publish --rm-dist release-snap: ## Test the full release (build binaries) + @echo "creating a release snapshot..." @goreleaser --snapshot --skip-publish --rm-dist replace-version: ## Replaces the version in HTML/JS (pre-deploy) + @echo "replacing version..." @test $(version) @test "$(path)" @find $(path) -name "*.html" -type f -exec sed -i '' -e "s/{{version}}/$(version)/g" {} \; @find $(path) -name "*.js" -type f -exec sed -i '' -e "s/{{version}}/$(version)/g" {} \; tag: ## Generate a new tag and push (tag version=0.0.0) + @echo "creating new tag..." @test $(version) @git tag -a v$(version) -m "Pending full release..." @git push origin v$(version) @git fetch --tags -f tag-remove: ## Remove a tag if found (tag-remove version=0.0.0) + @echo "removing tag..." @test $(version) @git tag -d v$(version) @git push --delete origin v$(version) @git fetch --tags tag-update: ## Update an existing tag to current commit (tag-update version=0.0.0) + @echo "updating tag to new commit..." @test $(version) @git push --force origin HEAD:refs/tags/v$(version) @git fetch --tags -f update-releaser: ## Update the goreleaser application - @brew update - @brew upgrade goreleaser + @echo "updating GoReleaser application..." + @$(MAKE) install-releaser diff --git a/.make/go.mk b/.make/go.mk index 739c2e3..49708b6 100644 --- a/.make/go.mk +++ b/.make/go.mk @@ -16,21 +16,27 @@ WINDOWS=$(BINARY_NAME)-windows.exe .PHONY: test lint vet install generate bench: ## Run all benchmarks in the Go application + @echo "running benchmarks..." @go test -bench=. -benchmem build-go: ## Build the Go application (locally) + @echo "building go app..." @go build -o bin/$(BINARY_NAME) clean-mods: ## Remove all the Go mod cache + @echo "cleaning mods..." @go clean -modcache coverage: ## Shows the test coverage + @echo "creating coverage report..." @go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out generate: ## Runs the go generate command in the base of the repo + @echo "generating files..." @go generate -v godocs: ## Sync the latest tag with GoDocs + @echo "syndicating to GoDocs..." @test $(GIT_DOMAIN) @test $(REPO_OWNER) @test $(REPO_NAME) @@ -38,20 +44,25 @@ godocs: ## Sync the latest tag with GoDocs @curl https://proxy.golang.org/$(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME)/@v/$(VERSION_SHORT).info install: ## Install the application + @echo "installing binary..." @go build -o $$GOPATH/bin/$(BINARY_NAME) install-go: ## Install the application (Using Native Go) + @echo "installing package..." @go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME) lint: ## Run the golangci-lint application (install if not found) + @echo "installing golangci-lint..." @#Travis (has sudo) - @if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.42.0 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ $(TRAVIS) ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.42.1 && sudo cp ./bin/golangci-lint $(go env GOPATH)/bin/; fi; @#AWS CodePipeline - @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.0; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(CODEBUILD_BUILD_ID)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1; fi; @#Github Actions - @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.42.0; fi; + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(GITHUB_WORKFLOW)" != "" ]; then curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b $(go env GOPATH)/bin v1.42.1; fi; @#Brew - MacOS @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then brew install golangci-lint; fi; + @#MacOS Vanilla + @if [ "$(shell command -v golangci-lint)" = "" ] && [ "$(shell command -v brew)" != "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- v1.42.1; fi; @echo "running golangci-lint..." @golangci-lint run --verbose @@ -61,6 +72,7 @@ test: ## Runs lint and ALL tests @go test ./... -v test-unit: ## Runs tests and outputs coverage + @echo "running unit tests..." @go test ./... -race -coverprofile=coverage.txt -covermode=atomic test-short: ## Runs vet, lint and tests (excludes integration tests) @@ -88,6 +100,7 @@ test-no-lint: ## Runs just tests @go test ./... -v uninstall: ## Uninstall the application (and remove files) + @echo "uninstalling go application..." @test $(BINARY_NAME) @test $(GIT_DOMAIN) @test $(REPO_OWNER) @@ -97,11 +110,13 @@ uninstall: ## Uninstall the application (and remove files) @rm -rf $$GOPATH/bin/$(BINARY_NAME) update: ## Update all project dependencies + @echo "updating dependencies..." @go get -u ./... && go mod tidy update-linter: ## Update the golangci-lint package (macOS only) + @echo "upgrading golangci-lint..." @brew upgrade golangci-lint vet: ## Run the Go vet application @echo "running go vet..." - @go vet -v ./... \ No newline at end of file + @go vet -v ./...