Skip to content

Commit

Permalink
Updated makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 29, 2021
1 parent a670414 commit 056ac4c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
15 changes: 13 additions & 2 deletions .make/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 19 additions & 4 deletions .make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,53 @@ 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)
@test $(VERSION_SHORT)
@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

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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 ./...
@go vet -v ./...

0 comments on commit 056ac4c

Please sign in to comment.