Skip to content

Commit

Permalink
Merge pull request #99 from ethernetdan/makefile
Browse files Browse the repository at this point in the history
added makefile and releases
  • Loading branch information
ethernetdan committed Mar 7, 2016
2 parents 39d1e12 + 5f5c1b2 commit ad7af85
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 30 deletions.
32 changes: 18 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@ language: go
sudo: false
go:
- 1.6
env:
- SPREAD="./pkg/... ./cli/... ./cmd/..."

go_import_path: rsprd.com/spread

install:
# install golint
- go get -u github.com/golang/lint/golint
# install build dependencies
- make deps

before_script:
- go vet $SPREAD
- make validate

script:
- go test -v $SPREAD
- make test

after_success:
- |
while IFS=' ' read -ra PKG; do
for i in "${PKG[@]}"; do
echo "Running golint on $i:"
golint $i
printf "#########################\n\n\n"
done
done <<< "$SPREAD"
# If release then crosscompile
- if [ -n "$TRAVIS_TAG" ]; then make crossbuild; else echo "Skipping release build..."; fi

deploy:
provider: releases
api_key:
secure: Jqzgb1hVOHhXAtzr1CaYtz9Ws8VGbyTP5qdWr9Dobg69hCTQDLg8Yuc/pJBIMtajxiQnrNmcI5ZpSdrPd1mxUKQBxr6ra3A8G/Utnfs8ilO0qDR4/pF+G+dVZlIUT/8iAfvpEiCkEckndrB/fVgR1p3o4R7kceHsjduTy+dX0j1v9jN1FA901o2C6tz3OYGn85q7p0wYXOd6l4WhtRK2EShvcPMG7Hs5Vz9Ihb7cznH1Lxpst2zohXz45O0vzfyFLXJp4RftAvg/1IOl9E4OTIanL9SQckRxfFRI57AAogKdJPYrbm8L7/HxRN96lW5e8EtNZXf77Orc/9NvR4YENRUINDhaCxz+IUTtU2TLt4nyCtHCEGyqFJ4ZnK5+sO4Ha7STiPVLNZSfu6rZPo3l77o0JTLo/IK8QtTrQ6H6JyjN3brle/FoOJTxtbjZ/DZKpR4QweO2zG4sQ8sKS8KuQ4LUx9Gm4ucuI8vsWIUsSMg8mKkCCQzf2z84Ih5FxZEwzXrAH+xVrrmUQlsgF3KflT/78LnJMFhOoxO+CPW2sStxndxh2L8duLOt+Jrf4URUnrjwGyWhebPcTI/gj0wuRUFY3VahkmWAD4r/3A/62s1/mc2vYwT9VLRxtKsA16Ur5ujM4nUVfJG/nYVE07+rqrngd9OCvmM8u5WmFpMqKWc=
skip_cleanup: true
file:
- ./build/spread_linux_amd64
- ./build/spread_darwin_amd64
- ./build/spread_windows_amd64.exe
on:
tags: true
82 changes: 82 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
BASE := rsprd.com/spread
CMD_NAME := spread

EXEC_PKG := $(BASE)/cmd/$(CMD_NAME)
PKGS := ./pkg/... ./cli/... ./cmd/...

GOX_OS ?= linux darwin windows
GOX_ARCH ?= amd64

GO ?= go
GOX ?= gox
GOFMT ?= gofmt # eventually should add "-s"
GOLINT ?= golint

GOFILES := find . -name '*.go' -not -path "./vendor/*"

GOBUILD_LDFLAGS ?=
GOBUILD_FLAGS ?=
GOTEST_FLAGS ?= -v
GOX_FLAGS ?= -output="build/{{.Dir}}_{{.OS}}_{{.Arch}}" -os="${GOX_OS}" -arch="${GOX_ARCH}"

GOX_OS ?= linux darwin windows
GOX_ARCH ?= amd64

.PHONY: all
all: clean validate test

.PHONY: release
release: validate test crossbuild

.PHONY: test
test: build
$(GO) test $(GOTEST_FLAGS) $(PKGS)

.PHONY: validate
validate: lint checkgofmt vet

.PHONY: build
build:
$(GO) install $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) $(EXEC_PKG)

.PHONY: crossbuild
crossbuild: deps gox-setup
$(GOX) $(GOX_FLAGS) -gcflags="$(GOBUILD_FLAGS)" -ldflags="$(GOBUILD_LDFLAGS)" $(EXEC_PKG)

.PHONY: vet
vet:
$(GO) vet $(PKGS)

lint: .golint-install
for pkg in $(PKGS); do \
echo "Running golint on $$i:"; \
golint $$i; \
done;

.PHONY: checkgofmt
checkgofmt:
# get all go files and run go fmt on them
$(GOFILES) | xargs $(GOFMT) -l
files=$$($(GOFILES) | xargs $(GOFMT) -l); echo "test $$files"; if [[ -n "$$files" ]]; then \
echo "Error: '$(GOFMT)' needs to be run on:"; \
echo "$${files}"; \
exit 1; \
fi;

.PHONY: deps
deps: .golint-install .gox-install

.golint-install:
$(GO) get -x github.com/golang/lint/golint > $@

PHONY: gox-setup
gox-setup: .gox-install

.gox-install:
$(GO) get -x github.com/mitchellh/gox > $@

.PHONY: clean
clean:
rm -vf .gox-* .golint-*
rm -rfv ./build
$(GO) clean $(PKGS) || true
16 changes: 0 additions & 16 deletions make.sh

This file was deleted.

0 comments on commit ad7af85

Please sign in to comment.