diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ae60f82..2f4ed6a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -9,9 +9,9 @@ jobs: runs-on: ubuntu-latest name: Build binary steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: go-version: ^1.19 @@ -22,9 +22,9 @@ jobs: runs-on: ubuntu-latest name: Format and lint steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v3 with: go-version: ^1.19 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..decef5f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,26 @@ +name: Release + +on: + push: + tags: ['[0-9]+\.[0-9]+\.[0-9]+'] + +jobs: + release: + runs-on: ubuntu-latest + name: Release + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + with: + go-version: ^1.19 + + - name: Create release distribution + run: make build-all-platforms tar-all-platforms + + - name: Create Github release + run: | + export TAG=${GITHUB_REF##*/} + gh release create ${TAG} --title "Release ${TAG}" *.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} diff --git a/.gitignore b/.gitignore index cde087e..f5b87b1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .idea/ -/chtop +/chtop-* diff --git a/Makefile b/Makefile index e12a6bb..4f5bb37 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,35 @@ +GOOS ?= $(shell go env GOOS) +GOARCH ?= $(shell go env GOARCH) +GOBUILD=CGO_ENABLED=0 installsuffix=cgo go build -trimpath + .DEFAULT_GOAL := run .PHONY: run run: - go run main.go + go run main.go --metrics-url http://localhost:9363/metrics --queries-url localhost:9000 --config ./chtop.yaml .PHONY: build build: - go build -o chtop main.go + ${GOBUILD} -o chtop-$(GOOS)-$(GOARCH) main.go + +.PHONY: build-linux-amd64 +build-linux-amd64: + GOOS=linux GOARCH=amd64 $(MAKE) build + +.PHONY: build-linux-arm64 +build-linux-arm64: + GOOS=linux GOARCH=arm64 $(MAKE) build + +.PHONY: build-darwin-amd64 +build-darwin-amd64: + GOOS=darwin GOARCH=amd64 $(MAKE) build + +.PHONY: build-darwin-arm64 +build-darwin-arm64: + GOOS=darwin GOARCH=arm64 $(MAKE) build + +.PHONY: build-all-platforms +build-all-platforms: build-linux-amd64 build-linux-arm64 build-darwin-amd64 build-darwin-arm64 .PHONY: fmt fmt: @@ -26,6 +49,29 @@ install-tools: go install golang.org/x/tools/cmd/goimports@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest +.PHONY: tar +tar: + tar -czvf chtop-$(GOOS)-$(GOARCH).tar.gz chtop-$(GOOS)-$(GOARCH) chtop.yaml + +.PHONY: tar-linux-amd64 +tar-linux-amd64: + GOOS=linux GOARCH=amd64 $(MAKE) tar + +.PHONY: tar-linux-arm64 +tar-linux-arm64: + GOOS=linux GOARCH=arm64 $(MAKE) tar + +.PHONY: tar-darwin-amd64 +tar-darwin-amd64: + GOOS=darwin GOARCH=amd64 $(MAKE) tar + +.PHONY: tar-darwin-arm64 +tar-darwin-arm64: + GOOS=darwin GOARCH=arm64 $(MAKE) tar + +.PHONY: tar-all-platforms +tar-all-platforms: tar-linux-amd64 tar-linux-arm64 tar-darwin-amd64 tar-darwin-arm64 + .PHONY: upgrade-deps upgrade-deps: go get -u ./... diff --git a/go.mod b/go.mod index ffe7a10..8901e5f 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( ) require ( - github.com/ClickHouse/ch-go v0.51.1 // indirect + github.com/ClickHouse/ch-go v0.51.2 // indirect github.com/andybalholm/brotli v1.0.4 // indirect github.com/aymanbagabas/go-osc52 v1.2.1 // indirect github.com/containerd/console v1.0.3 // indirect diff --git a/go.sum b/go.sum index da06aea..8d44176 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/ClickHouse/ch-go v0.51.1 h1:qT66gldDXAzZNbgu3E/LwTROWrZejG6n8tVMRuyw/vA= -github.com/ClickHouse/ch-go v0.51.1/go.mod h1:z+/hEezvvHvRMV/I00CaXBnxOx+td4zRe7HJpBYLwGU= +github.com/ClickHouse/ch-go v0.51.2 h1:PesdqjUImi21U61yPKsDhfer8wiQ3geTsjdjZzXd/3s= +github.com/ClickHouse/ch-go v0.51.2/go.mod h1:z+/hEezvvHvRMV/I00CaXBnxOx+td4zRe7HJpBYLwGU= github.com/ClickHouse/clickhouse-go/v2 v2.5.1 h1:+KebkZtGJKaCilgNF0vQBrc7hOdNWnheue0bX1OVhl4= github.com/ClickHouse/clickhouse-go/v2 v2.5.1/go.mod h1:21ga8MAMxWl6AKFJTaoT/ur/zIo8OJccxj/5bF8T9SE= github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=