Skip to content

Commit

Permalink
build(make): add initial Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
gabor-boros committed Oct 8, 2021
1 parent 3c3b64c commit d25eab8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
before:
hooks:
- make clean
- make deps
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
dist: bin
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^chore:'
- '^docs:'
- '^test:'
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.PHONY: help prerequisites deps format lint test build clean
.DEFAULT_GOAL := build

BIN_NAME := minutes

help: ## Show available targets
@echo "Available targets:"
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

prerequisites: ## Download and install prerequisites
go install github.com/goreleaser/goreleaser@latest
go install github.com/sqs/goreturns@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest

deps: ## Download dependencies
go mod download
go mod tidy

format: deps ## Run formatter on the project
goreturns -b -local -p -w -e -l .

lint: format ## Run linters on the project
golangci-lint run --timeout 5m -E golint -e '(struct field|type|method|func) [a-zA-Z`]+ should be [a-zA-Z`]+'
gosec -quiet ./...

test: deps ## Run tests
go test ./...

build: deps ## Build binary
goreleaser build --rm-dist --snapshot --single-target
@find bin -name "$(BIN_NAME)" -exec cp "{}" bin/ \;

release: ## Release a new version on GitHub
goreleaser release --rm-dist --auto-snapshot

clean: ## Clean up project root
rm -rf bin/

0 comments on commit d25eab8

Please sign in to comment.