diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..b92a857 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,26 @@ +dist: dist +builds: + - main: ./main.go + env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + - windows + goarch: + - amd64 + ldflags: + - -w -s +archives: + - name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}" + wrap_in_directory: false + files: + - LICENSE +checksum: + name_template: 'CHECKSUM' +release: + github: + owner: grepplabs + name: rabbitmq-mv + draft: false + prerelease: auto \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index efdb0ca..666d04c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,5 +6,7 @@ ARG GOARCH=amd64 WORKDIR "/code" ADD . "/code" RUN make BINARY=rabbitmq-mv GOOS=${GOOS} GOARCH=${GOARCH} os.build + +FROM alpine:3.11 COPY --from=builder /code/rabbitmq-mv /rabbitmq-mv -ENTRYPOINT ["/rabbitmq-mv"] \ No newline at end of file +ENTRYPOINT ["/rabbitmq-mv"] diff --git a/Makefile b/Makefile index 8ec50ca..f595044 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,8 @@ .PHONY: clean build fmt test +TAG ?= "v0.0.1" + BUILD_FLAGS ?= BINARY ?= rabbitmq-mv VERSION ?= $(shell git describe --tags --always --dirty) @@ -13,6 +15,8 @@ GOOS ?= linux LOCAL_IMAGE ?= local/$(GOOS)-$(GOARCH)/$(BINARY) LOCAL_BIN ?= $(BINARY)-$(GOOS)-$(GOARCH) +CLOUD_IMAGE ?= grepplabs/rabbitmq-mv:$(TAG) + ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) default: build @@ -39,6 +43,12 @@ docker.copy: docker.build $(eval RESULT=$(shell sh -c "docker rmi $(LOCAL_IMAGE)")) echo "Binary copied to local directory" +.PHONY: docker.push +docker.push: + docker build -f Dockerfile -t $(LOCAL_IMAGE) . + docker tag $(LOCAL_IMAGE) $(CLOUD_IMAGE) + docker push $(CLOUD_IMAGE) + .PHONY: build.os build.os: clean docker.copy @@ -79,3 +89,20 @@ vendor: tidy: GO111MODULE=on go mod tidy +.PHONY: tag +tag: + git tag $(TAG) + +.PHONY: release.setup +release.setup: + curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh + +.PHONY: release.skip-publish +release.skip-publish: release.setup + $(ROOT_DIR)/bin/goreleaser release --rm-dist --skip-publish --snapshot + +.PHONY: release.publish +release.publish: release.setup + @[ "${GITHUB_TOKEN}" ] && echo "releasing $(TAG)" || ( echo "GITHUB_TOKEN is not set"; exit 1 ) + git push origin $(TAG) + $(ROOT_DIR)/bin/goreleaser release --rm-dist diff --git a/README.md b/README.md index 3d8b1c4..ad4fa96 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,27 @@ rabbitmq-mv is a utility to move messages from one rabbitmq queue to another one. +## Install binary release + +1. Download the latest release + + Linux + + curl -Ls https://github.com/grepplabs/rabbitmq-mv/releases/download/v0.0.1/rabbitmq-mv-v0.0.1-linux-amd64.tar.gz | tar xz + + macOS + + curl -Ls https://github.com/grepplabs/rabbitmq-mv/releases/download/v0.0.1/rabbitmq-mv-v0.0.1-darwin-amd64.tar.gz | tar xz + + windows + + curl -Ls https://github.com/grepplabs/rabbitmq-mv/releases/download/v0.0.1/rabbitmq-mv-v0.0.1-windows-amd64.tar.gz | tar xz + +2. Move the binary in to your PATH. + + ``` + sudo mv ./rabbitmq-mv /usr/local/bin/rabbitmq-mv + ``` ## Build binary @@ -35,7 +56,9 @@ rabbitmq-mv is a utility to move messages from one rabbitmq queue to another one Use producer transactions (slow) +## Docker + docker run -it --rm grepplabs/rabbitmq-mv:v0.0.1 -help ## Usage examples