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