diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fc3ce4e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 + +[{Makefile,go.mod,go.sum,*.go}] +indent_style = tab +indent_size = 4 diff --git a/.travis.yml b/.travis.yml index 4174ac1..a4acd59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,17 @@ language: go -sudo: false +go: + - 1.13 before_install: + - go get golang.org/x/lint/golint - go get github.com/mattn/goveralls -matrix: - fast_finish: true - include: - - go: 1.13 - script: make test +install: + - make deps + +script: + - make lint + - make test after_success: - $HOME/gopath/bin/goveralls -service=travis-ci diff --git a/Makefile b/Makefile index 79da57a..d823890 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,17 @@ # Project information -OWNER = "tomohiro" -PACKAGE = $(shell basename $(PWD)) -VERSION = $(shell git describe --abbrev=0 --tags) +OWNER := tomohiro +PACKAGE := $(shell basename $(PWD)) +VERSION := $(shell git describe --abbrev=0 --tags) # Build information -DIST_DIR = $(PWD)/dist -ASSETS_DIR = $(DIST_DIR)/$(VERSION) -XC_OS = "linux darwin" -XC_ARCH = "386 amd64" -BUILD_FLAGS = "-w -s" +DIST_DIR := $(PWD)/dist +ASSETS_DIR := $(DIST_DIR)/$(VERSION) +XC_OS := "linux darwin" +XC_ARCH := "386 amd64" +BUILD_FLAGS := "-w -s" # Tasks +.PHONY: help help: @echo "Please type: make [target]" @echo " setup Setup development environment" @@ -23,46 +24,50 @@ help: @echo " clean Clean assets" @echo " help Show this help messages" +.PHONY: setup setup: @echo "===> Setup development tools..." - - # goxz - Just do cross building and archiving go tools conventionally + # Install goxz - Just do cross building and archiving go tools conventionally GO111MODULE=off go get -u github.com/Songmu/goxz/cmd/goxz - - # ghr - Upload multiple artifacts to GitHub Release in parallel + # Install ghr - Upload multiple artifacts to GitHub Release in parallel GO111MODULE=off go get -u github.com/tcnksm/ghr +.PHONY: deps deps: @echo "===> Installing runtime dependencies..." go mod download +.PHONY: updatedeps updatedeps: @echo "===> Updating runtime dependencies..." go get -u +.PHONY: lint lint: deps @echo "===> Running lint..." go vet ./... golint -set_exit_status ./... +.PHONY: test test: deps @echo "===> Running tests..." go test -v -cover ./... +.PHONY: dist dist: deps @echo "===> Shipping packages as release assets..." - goxz -d $(ASSETS_DIR) -z -os $(XC_OS) -arch $(XC_ARCH) --build-ldflags=$(BUILD_LDFLAGS) + goxz -z -d $(ASSETS_DIR) -os $(XC_OS) -arch $(XC_ARCH) --build-ldflags=$(BUILD_FLAGS) pushd $(ASSETS_DIR); \ shasum -a 256 *.zip > ./$(VERSION)_SHA256SUMS; \ popd +.PHONY: release release: @echo "===> Publishing release assets to GitHub..." ghr -u $(OWNER) -r $(PACKAGE) $(VERSION) $(ASSETS_DIR) +.PHONY: clean clean: @echo "===> Cleaning assets..." go clean rm -rf $(DIST_DIR) - -.PHONY: help setup deps updatedeps test dist release clean