Skip to content

Commit

Permalink
Make release (#92)
Browse files Browse the repository at this point in the history
* set version var, initial 0.1.0+dev

* create release generate (cross compiler)
used xgo

* added pREST meta files on git ignored

* ignore all *.toml on git
  • Loading branch information
Thiago Avelino authored and felipeweb committed Jan 28, 2017
1 parent 5bd9377 commit 592c92e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ _testmain.go

data/
.idea
*.iml
*.iml

# pREST
prest
prest-*
/dist
*.toml
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
DIST := dist
IMPORT := github.com/nuveo/prest
LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')"
OUT := 'prest'
TARGETS ?= linux/*,darwin/*,windows/*

EXECUTABLE := $(OUT)
ifeq ($(OS), Windows_NT)
EXECUTABLE := $(OUT).exe
endif

PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)

.PHONY: errcheck
errcheck:
@which errcheck > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/kisielk/errcheck; \
fi
errcheck $(PACKAGES)

.PHONY: install
install: $(wildcard *.go)
go install -v -ldflags '-s -w $(LDFLAGS)'

.PHONY: build
build: $(EXECUTABLE)

$(EXECUTABLE): $(SOURCES)
go build -v -ldflags '-s -w $(LDFLAGS)' -o $@

.PHONY: release
release: release-dirs release-build release-check

.PHONY: release-dirs
release-dirs:
mkdir -p $(DIST)/binaries

.PHONY: release-build
release-build:
@which xgo > /dev/null; if [ $$? -ne 0 ]; then \
go get -u github.com/karalabe/xgo; \
fi
xgo -dest $(DIST)/binaries -ldflags '-s -w $(LDFLAGS)' -targets '$(TARGETS)' -out $(EXECUTABLE) $(IMPORT)
ifeq ($(CI),drone)
mv /build/* $(DIST)/binaries
endif

.PHONY: release-check
release-check:
cd $(DIST)/binaries; $(foreach file,$(wildcard $(DIST)/binaries/$(EXECUTABLE)-*),sha256sum $(notdir $(file)) > $(notdir $(file)).sha256;)
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"github.com/nuveo/prest/cmd"
)

var Version = "0.1.0+dev"

func main() {
cmd.Execute()
}

0 comments on commit 592c92e

Please sign in to comment.