Skip to content

Commit

Permalink
Add a Makefile (#2)
Browse files Browse the repository at this point in the history
Adds a `Makefile` to simplify the maintenance tasks.
  • Loading branch information
rgreinho authored Jun 23, 2019
1 parent 80e7c66 commit ffd394a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
12 changes: 4 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Binaries for programs and plugins
*.dll
*.dylib
*.exe
*.exe~
*.dll
*.out
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
dist/
56 changes: 56 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Project name.
PROJECT_NAME = keeparelease

# Makefile parameters.
TAG ?= $(shell git describe)

# General.
SHELL = /bin/bash
TOPDIR = $(shell git rev-parse --show-toplevel)

# Project specifics.
BUILD_DIR = dist
PLATFORMS = linux darwin
OS = $(word 1, $@)
GOOS = $(shell uname -s | tr A-Z a-z)
GOARCH = amd64

default: build

.PHONY: help
help: # Display help
@awk -F ':|##' \
'/^[^\t].+?:.*?##/ {
printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \
}' $(MAKEFILE_LIST) | sort

.PHONY: build
build: ## Build the project for the current platform
mkdir -p $(BUILD_DIR)
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(BUILD_DIR)/$(PROJECT_NAME)-$(TAG)-$(GOOS)-$(GOARCH)

.PHONY: test
test: ## Run the unit tests
go test .../keeparelease

.PHONY: clean
clean: clean-code ## Clean everything (!DESTRUCTIVE!)

.PHONY: clean-code
clean-code: ## Remove unwanted files in this project (!DESTRUCTIVE!)
@cd $(TOPDIR) && git clean -ffdx && git reset --hard

dist: $(PLATFORMS) ## Package the project for all available platforms

.PHONY: publish
publish: dist ## Create GitHub release
keeparelease -a dist/*

.PHONY: setup
setup: ## Setup the full environment (default)
go mod tidy

$(PLATFORMS): # Build the project for all available platforms
mkdir -p $(BUILD_DIR)
GOOS=$(OS) GOARCH=$(GOARCH) go build -o $(BUILD_DIR)/$(PROJECT_NAME)-$(TAG)-$(OS)-$(GOARCH)
.PHONY: $(PLATFORMS)
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down

0 comments on commit ffd394a

Please sign in to comment.