From 89abde4ef2439b62f3c152e3fa23c475909edc18 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Wed, 20 Feb 2019 19:24:27 +0100 Subject: [PATCH] Add goreleaser to perform release --- .gitignore | 2 ++ .goreleaser.yml | 28 ++++++++++++++++++++++++++++ .travis.yml | 22 ++++++++++++++++++++-- Makefile | 23 +++++++++++++++++++++++ 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .goreleaser.yml create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46e5d7a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/kroki +/dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..e4903d9 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,28 @@ +project_name: kroki-cli + +before: + hooks: + - go mod download + +builds: + - env: + - CGO_ENABLED=0 + - binary: kroki + goos: + - windows + - darwin + - linux + - openbsd + goarch: + - amd64 + +archive: + format_overrides: + - goos: windows + format: zip + +release: + github: + owner: yuzutech + name: kroki-cli + draft: true diff --git a/.travis.yml b/.travis.yml index 549a385..3d701cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,23 @@ install: - go mod vendor script: -- go test -race ./... -- golangci-lint run . +- make test +- make lint + +jobs: + include: + - stage: goreleaser-snapshot + go: "1.11.x" + script: + - curl -sL https://git.io/goreleaser | head -n -2 | bash + - tar -xf /tmp/goreleaser.tar.gz -C $GOPATH/bin + - goreleaser --snapshot --skip-sign + - stage: goreleaser-release + go: "1.11.x" + if: | + repo = 'yuzutech/kroki-cli' AND \ + tag IS present + script: + - curl -sL https://git.io/goreleaser | head -n -2 | bash + - tar -xf /tmp/goreleaser.tar.gz -C $GOPATH/bin + - goreleaser --skip-sign \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8e9b4ba --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +version := $(shell git describe --exact-match --tags $(git log -n1 --pretty='%h') 2> /dev/null || echo 'latest') +vcs_ref := $(shell git rev-parse HEAD) + +GO_FILES = $(shell find . -type f -name '*.go') + +.PHONY: all +all: clean kroki + +kroki: $(GO_FILES) + go build -o $@ -ldflags "-s -w -X main.version=${version} -X main.commit=${vcs_ref}" + +.PHONY: lint +lint: $(GO_FILES) + golangci-lint run ./... + +.PHONY: test +test: $(GO_FILES) + go test -race ./... + +.PHONY: clean +clean: + go clean + rm -rf kroki