Skip to content

Commit

Permalink
Merge pull request #3 from tomohiro/update-build
Browse files Browse the repository at this point in the history
Update build process
  • Loading branch information
tomohiro authored Dec 10, 2019
2 parents 63c6abc + b47ad56 commit 26ae0e0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 20 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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

0 comments on commit 26ae0e0

Please sign in to comment.