Skip to content

Commit

Permalink
CLI Unification: Unify goreleaser files with `goreleaser build --sing…
Browse files Browse the repository at this point in the history
…le-target` (#994)

* use goreleaser build --single-target

* update readme and rename file

* remove goreleaser suffix env var
  • Loading branch information
brianstrauch committed Sep 9, 2021
1 parent 9e60992 commit 37f5705
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .goreleaser-alpine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}} -X main.cliName=confluent
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
Expand Down
9 changes: 2 additions & 7 deletions .goreleaser-linux.yml → .goreleaser-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ project_name: confluent
dist: dist/confluent

builds:
-
binary: confluent
- binary: confluent
main: cmd/confluent/main.go
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}} -X main.cliName=confluent
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
- all=-trimpath={{.Env.GOPATH}}
goos:
- linux
goarch:
- amd64
2 changes: 1 addition & 1 deletion .goreleaser-fake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}} -X main.cliName=confluent
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
Expand Down
20 changes: 0 additions & 20 deletions .goreleaser-mac.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .goreleaser-windows.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}} -X main.cliName=confluent -buildmode=exe
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
Expand All @@ -35,7 +35,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}} -X main.cliName=confluent
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
Expand All @@ -57,7 +57,7 @@ builds:
flags:
- -mod=readonly
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}} -X main.cliName=confluent
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.ShortCommit}} -X main.date={{.Date}} -X main.host={{.Env.HOSTNAME}}
gcflags:
- all=-trimpath={{.Env.GOPATH}}
asmflags:
Expand Down
27 changes: 12 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ GIT_REMOTE_NAME ?= origin
MAIN_BRANCH ?= main
RELEASE_BRANCH ?= main

.PHONY: build
build:
@GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) HOSTNAME=$(HOSTNAME) goreleaser build -f .goreleaser-build.yml --rm-dist --single-target --snapshot

include ./mk-files/dockerhub.mk
include ./mk-files/semver.mk
include ./mk-files/docs.mk
Expand Down Expand Up @@ -32,19 +36,16 @@ generate:

.PHONY: deps
deps:
go get github.com/goreleaser/goreleaser@v0.162.1 && \
go get github.com/goreleaser/goreleaser@v0.164.0 && \
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.30.0 && \
go get github.com/mitchellh/golicense@v0.2.0

ifeq ($(shell uname),Darwin)
GORELEASER_SUFFIX ?= -mac.yml
SHASUM ?= gsha256sum
else ifneq (,$(findstring NT,$(shell uname)))
GORELEASER_SUFFIX ?= -windows.yml
# TODO: I highly doubt this works. Completely untested. The output format is likely very different than expected.
SHASUM ?= CertUtil SHA256 -hashfile
else
GORELEASER_SUFFIX ?= -linux.yml
SHASUM ?= sha256sum
endif

Expand All @@ -67,16 +68,12 @@ endif

.PHONY: run
run:
@GOPRIVATE=github.com/confluentinc go run -ldflags '-buildmode=exe' cmd/confluent/main.go $(RUN_ARGS)
@GOPRIVATE=github.com/confluentinc go run cmd/confluent/main.go $(RUN_ARGS)

#
# END DEVELOPMENT HELPERS
#

.PHONY: build
build:
@GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) HOSTNAME=$(HOSTNAME) goreleaser release --snapshot --rm-dist -f .goreleaser$(GORELEASER_SUFFIX)

.PHONY: build-integ
build-integ:
make build-integ-nonrace
Expand All @@ -86,7 +83,7 @@ build-integ:
build-integ-nonrace:
binary="confluent_test" ; \
[ "$${OS}" = "Windows_NT" ] && binexe=$${binary}.exe || binexe=$${binary} ; \
go test ./cmd/confluent -ldflags="-buildmode=exe -s -w \
go test ./cmd/confluent -ldflags="-s -w \
-X $(RESOLVED_PATH).commit=$(REF) \
-X $(RESOLVED_PATH).host=$(HOSTNAME) \
-X $(RESOLVED_PATH).date=$(DATE) \
Expand All @@ -98,7 +95,7 @@ build-integ-nonrace:
build-integ-race:
binary="confluent_test_race" ; \
[ "$${OS}" = "Windows_NT" ] && binexe=$${binary}.exe || binexe=$${binary} ; \
go test ./cmd/confluent -ldflags="-buildmode=exe -s -w \
go test ./cmd/confluent -ldflags="-s -w \
-X $(RESOLVED_PATH).commit=$(REF) \
-X $(RESOLVED_PATH).host=$(HOSTNAME) \
-X $(RESOLVED_PATH).date=$(DATE) \
Expand Down Expand Up @@ -163,22 +160,22 @@ lint-licenses: build
coverage-unit:
ifdef CI
@# Run unit tests with coverage.
@GOPRIVATE=github.com/confluentinc go test -v -race -coverpkg=$$(go list ./... | grep -v test | grep -v mock | tr '\n' ',' | sed 's/,$$//g') -coverprofile=unit_coverage.txt $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS) -ldflags '-buildmode=exe'
@GOPRIVATE=github.com/confluentinc go test -v -race -coverpkg=$$(go list ./... | grep -v test | grep -v mock | tr '\n' ',' | sed 's/,$$//g') -coverprofile=unit_coverage.txt $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS)
@grep -h -v "mode: atomic" unit_coverage.txt >> coverage.txt
else
@# Run unit tests.
@GOPRIVATE=github.com/confluentinc go test -race -coverpkg=./... $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS) -ldflags '-buildmode=exe'
@GOPRIVATE=github.com/confluentinc go test -race -coverpkg=./... $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS)
endif

.PHONY: coverage-integ
coverage-integ:
ifdef CI
@# Run integration tests with coverage.
@INTEG_COVER=on go test -v $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m -ldflags '-buildmode=exe'
@INTEG_COVER=on go test -v $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m
@grep -h -v "mode: atomic" integ_coverage.txt >> coverage.txt
else
@# Run integration tests.
@GOPRIVATE=github.com/confluentinc go test -v -race $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m -ldflags '-buildmode=exe'
@GOPRIVATE=github.com/confluentinc go test -v -race $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m
endif

.PHONY: test-prep
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ When you add a new command or resource, assuming it's already in the SDK, you ge

### Build Other Platforms

If you have a need to build a binary for a platform that is not the current one, use the following to target a different `.goreleaser-*` file matching the destined platform.
If you have a need to build a binary for a platform that is not the current one, use the following:

make build GORELEASER_SUFFIX=-linux.yml # build linux
make build GORELEASER_SUFFIX=-mac.yml # build mac
make build GORELEASER_SUFFIX=-windows.yml # build windows
GOOS=linux make build
GOOS=mac make build
GOOS=windows make build

### URLS
Use the `login` command with the `--url` option to point to a different development environment
Expand Down
33 changes: 15 additions & 18 deletions debian/patches/standard_build_layout.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
--- cli/Makefile 2021-08-02 15:19:10.000000000 -0600
+++ debian/Makefile 2021-07-21 21:31:30.000000000 -0600
@@ -1,205 +1,130 @@
--- cli/Makefile 2021-09-02 14:46:00.000000000 -0700
+++ debian/Makefile 2021-08-26 16:04:24.000000000 -0700
@@ -1,202 +1,130 @@
-SHELL := /bin/bash
-ALL_SRC := $(shell find . -name "*.go" | grep -v -e vendor)
-GIT_REMOTE_NAME ?= origin
-MAIN_BRANCH ?= main
-RELEASE_BRANCH ?= main
-
-.PHONY: build
-build:
- @GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) HOSTNAME=$(HOSTNAME) goreleaser build -f .goreleaser-build.yml --rm-dist --single-target --snapshot
-
-include ./mk-files/dockerhub.mk
-include ./mk-files/semver.mk
-include ./mk-files/docs.mk
Expand Down Expand Up @@ -54,22 +58,19 @@
-
-.PHONY: deps
-deps:
- go get github.com/goreleaser/goreleaser@v0.162.1 && \
- go get github.com/goreleaser/goreleaser@v0.164.0 && \
- go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.30.0 && \
- go get github.com/mitchellh/golicense@v0.2.0
-
-ifeq ($(shell uname),Darwin)
-GORELEASER_SUFFIX ?= -mac.yml
-SHASUM ?= gsha256sum
-else ifneq (,$(findstring NT,$(shell uname)))
-GORELEASER_SUFFIX ?= -windows.yml
-# TODO: I highly doubt this works. Completely untested. The output format is likely very different than expected.
-SHASUM ?= CertUtil SHA256 -hashfile
+ifeq ($(PACKAGE_TYPE),archive)
+PREFIX=$(PACKAGE_NAME)
+SYSCONFDIR=$(PREFIX)/etc/$(PACKAGE_TITLE)
else
-GORELEASER_SUFFIX ?= -linux.yml
-SHASUM ?= sha256sum
+PREFIX=/usr
+SYSCONFDIR=/etc/$(PACKAGE_TITLE)
Expand All @@ -95,16 +96,12 @@
-
-.PHONY: run
-run:
- @GOPRIVATE=github.com/confluentinc go run -ldflags '-buildmode=exe' cmd/confluent/main.go $(RUN_ARGS)
- @GOPRIVATE=github.com/confluentinc go run cmd/confluent/main.go $(RUN_ARGS)
-
-#
-# END DEVELOPMENT HELPERS
-#
-
-.PHONY: build
-build:
- @GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) HOSTNAME=$(HOSTNAME) goreleaser release --snapshot --rm-dist -f .goreleaser$(GORELEASER_SUFFIX)
-
-.PHONY: build-integ
-build-integ:
- make build-integ-nonrace
Expand All @@ -114,7 +111,7 @@
-build-integ-nonrace:
- binary="confluent_test" ; \
- [ "$${OS}" = "Windows_NT" ] && binexe=$${binary}.exe || binexe=$${binary} ; \
- go test ./cmd/confluent -ldflags="-buildmode=exe -s -w \
- go test ./cmd/confluent -ldflags="-s -w \
- -X $(RESOLVED_PATH).commit=$(REF) \
- -X $(RESOLVED_PATH).host=$(HOSTNAME) \
- -X $(RESOLVED_PATH).date=$(DATE) \
Expand All @@ -126,7 +123,7 @@
-build-integ-race:
- binary="confluent_test_race" ; \
- [ "$${OS}" = "Windows_NT" ] && binexe=$${binary}.exe || binexe=$${binary} ; \
- go test ./cmd/confluent -ldflags="-buildmode=exe -s -w \
- go test ./cmd/confluent -ldflags="-s -w \
- -X $(RESOLVED_PATH).commit=$(REF) \
- -X $(RESOLVED_PATH).host=$(HOSTNAME) \
- -X $(RESOLVED_PATH).date=$(DATE) \
Expand Down Expand Up @@ -250,22 +247,22 @@
-coverage-unit:
- ifdef CI
- @# Run unit tests with coverage.
- @GOPRIVATE=github.com/confluentinc go test -v -race -coverpkg=$$(go list ./... | grep -v test | grep -v mock | tr '\n' ',' | sed 's/,$$//g') -coverprofile=unit_coverage.txt $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS) -ldflags '-buildmode=exe'
- @GOPRIVATE=github.com/confluentinc go test -v -race -coverpkg=$$(go list ./... | grep -v test | grep -v mock | tr '\n' ',' | sed 's/,$$//g') -coverprofile=unit_coverage.txt $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS)
- @grep -h -v "mode: atomic" unit_coverage.txt >> coverage.txt
- else
- @# Run unit tests.
- @GOPRIVATE=github.com/confluentinc go test -race -coverpkg=./... $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS) -ldflags '-buildmode=exe'
- @GOPRIVATE=github.com/confluentinc go test -race -coverpkg=./... $$(go list ./... | grep -v vendor | grep -v test) $(UNIT_TEST_ARGS)
- endif
-
-.PHONY: coverage-integ
-coverage-integ:
- ifdef CI
- @# Run integration tests with coverage.
- @INTEG_COVER=on go test -v $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m -ldflags '-buildmode=exe'
- @INTEG_COVER=on go test -v $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m
- @grep -h -v "mode: atomic" integ_coverage.txt >> coverage.txt
- else
- @# Run integration tests.
- @GOPRIVATE=github.com/confluentinc go test -v -race $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m -ldflags '-buildmode=exe'
- @GOPRIVATE=github.com/confluentinc go test -v -race $$(go list ./... | grep cli/test) $(INT_TEST_ARGS) -timeout 45m
- endif
-
-.PHONY: test-prep
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ require (
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/google/go-cmp v0.5.5
github.com/google/go-github/v25 v25.0.2
github.com/google/go-github/v28 v28.1.1 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.2.0
github.com/goreleaser/goreleaser v0.162.1
github.com/goreleaser/goreleaser v0.164.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-hclog v0.9.2
github.com/hashicorp/go-multierror v1.1.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -639,6 +640,8 @@ github.com/google/go-github/v25 v25.0.2 h1:MqXE7nOlIF91NJ/PXAcvS2dC+XXCDbY7RvJzj
github.com/google/go-github/v25 v25.0.2/go.mod h1:6z5pC69qHtrPJ0sXPsj4BLnd82b+r6sLB7qcBoRZqpw=
github.com/google/go-github/v28 v28.1.1 h1:kORf5ekX5qwXO2mGzXXOjMe/g6ap8ahVe0sBEulhSxo=
github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM=
github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606 h1:+8mvMVu+3yXBi/HdWq39mWbt/60u9qS+dkVZfjqEnt8=
github.com/google/go-github/v35 v35.0.1-0.20210421135231-b235769d1606/go.mod h1:s0515YVTI+IMrDoy9Y4pHt9ShGpzHvHO8rZ7L7acgvs=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-replayers/grpcreplay v1.0.0 h1:B5kVOzJ1hBgnevTgIWhSTatQ3608yu/2NnU0Ta1d0kY=
Expand Down Expand Up @@ -692,6 +695,8 @@ github.com/goreleaser/fileglob v1.2.0 h1:OErqbdzeg/eibfDGPHDQDN8jL5u1jNyxA5IQzNP
github.com/goreleaser/fileglob v1.2.0/go.mod h1:rFyb2pXaK3YdnYnSjn6lifw0h2Q6s8OfOsx6I6bXkKE=
github.com/goreleaser/goreleaser v0.162.1 h1:NCMY3ZNx/aHpO0rgJIXe4ejd+g3dhxrIodsjTxoApZU=
github.com/goreleaser/goreleaser v0.162.1/go.mod h1:5WElSKi1ft66CyFDfowJdVOhR/JSwUqXeckGme5I4UI=
github.com/goreleaser/goreleaser v0.164.0 h1:w0zTtZSg9exA+eUoaFuZiJ5UuHaMom/TgXQvySAEJiY=
github.com/goreleaser/goreleaser v0.164.0/go.mod h1:gFyE4wWnpj09KPhjnWS3Dm7WJ2u85jylmWy5l/OZEH4=
github.com/goreleaser/nfpm/v2 v2.4.0 h1:OV8F+8XCIpvCUwOSU/aVahQK9UJJRdI5c4YP7NQIUjM=
github.com/goreleaser/nfpm/v2 v2.4.0/go.mod h1:lFgRyap3jgtdiQ5wO5G02DrTUF4YhoEqYdE1FLNjc74=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
Expand Down Expand Up @@ -1131,6 +1136,7 @@ github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThC
github.com/rs/zerolog v1.18.0/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I=
github.com/rsc/goversion v1.2.0 h1:zVF4y5ciA/rw779S62bEAq4Yif1cBc/UwRkXJ2xZyT4=
github.com/rsc/goversion v1.2.0/go.mod h1:Tf/O0TQyfRvp7NelXAyfXYRKUO+LX3KNgXc8ALRUv4k=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryancurrah/gomodguard v1.1.0 h1:DWbye9KyMgytn8uYpuHkwf0RHqAYO6Ay/D0TbCpPtVU=
github.com/ryancurrah/gomodguard v1.1.0/go.mod h1:4O8tr7hBODaGE6VIhfJDHcwzh5GUccKSJBU0UMXJFVM=
Expand Down

0 comments on commit 37f5705

Please sign in to comment.