diff --git a/.goreleaser-linux-glibc-arm64.yml b/.goreleaser-linux-glibc-arm64.yml index b2dd0e5afe..9b56873c13 100644 --- a/.goreleaser-linux-glibc-arm64.yml +++ b/.goreleaser-linux-glibc-arm64.yml @@ -34,9 +34,6 @@ archives: - id: archive name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}" format: tar.gz - format_overrides: - - goos: windows - format: zip wrap_in_directory: "{{ .ProjectName }}" files: - LICENSE diff --git a/.goreleaser-linux-glibc.yml b/.goreleaser-linux-glibc.yml index 0fda9fe4f4..06e53f3291 100644 --- a/.goreleaser-linux-glibc.yml +++ b/.goreleaser-linux-glibc.yml @@ -34,9 +34,6 @@ archives: - id: archive name_template: "{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}" format: tar.gz - format_overrides: - - goos: windows - format: zip wrap_in_directory: "{{ .ProjectName }}" files: - LICENSE diff --git a/dockerfiles/Dockerfile_linux_glibc b/dockerfiles/Dockerfile_linux_glibc index 0b8a9a10ef..70086004e6 100644 --- a/dockerfiles/Dockerfile_linux_glibc +++ b/dockerfiles/Dockerfile_linux_glibc @@ -1,4 +1,4 @@ -FROM --platform=linux/amd64 050879227952.dkr.ecr.us-west-1.amazonaws.com/confluentinc/cli-centos-base-amd64:latest +FROM --platform=linux/amd64 050879227952.dkr.ecr.us-west-1.amazonaws.com/confluentinc/cli-centos-base-amd64:2.0 COPY . /go/src/github.com/confluentinc/cli/ diff --git a/dockerfiles/Dockerfile_linux_glibc_arm64 b/dockerfiles/Dockerfile_linux_glibc_arm64 index d8ffd96d0f..67ab6600be 100644 --- a/dockerfiles/Dockerfile_linux_glibc_arm64 +++ b/dockerfiles/Dockerfile_linux_glibc_arm64 @@ -1,4 +1,4 @@ -FROM --platform=linux/arm64/v8 050879227952.dkr.ecr.us-west-1.amazonaws.com/confluentinc/cli-centos-base-arm64:latest +FROM --platform=linux/arm64/v8 050879227952.dkr.ecr.us-west-1.amazonaws.com/confluentinc/cli-ubuntu-base-arm64:arm64 COPY . /go/src/github.com/confluentinc/cli/ @@ -6,4 +6,4 @@ RUN cd /go/src/github.com/confluentinc/cli && \ make gorelease-linux-glibc-arm64 RUN cd /go/src/github.com/confluentinc/cli && \ - for file in dist/*.txt; do mv -v "$file" "${file/checksums/checksums_linux_arm64}"; done; + rename 's/checksums/checksums_linux_arm64/' dist/*.txt diff --git a/dockerfiles/Dockerfile_linux_glibc_arm64_from_amd64 b/dockerfiles/Dockerfile_linux_glibc_arm64_from_amd64 new file mode 100644 index 0000000000..a3eabc6052 --- /dev/null +++ b/dockerfiles/Dockerfile_linux_glibc_arm64_from_amd64 @@ -0,0 +1,9 @@ +FROM --platform=linux/amd64 050879227952.dkr.ecr.us-west-1.amazonaws.com/confluentinc/cli-ubuntu-base-arm64:latest + +COPY . /go/src/github.com/confluentinc/cli/ + +RUN cd /go/src/github.com/confluentinc/cli && \ + make gorelease-linux-glibc-arm64 + +RUN cd /go/src/github.com/confluentinc/cli && \ + rename 's/checksums/checksums_linux_arm64/' dist/*.txt diff --git a/mk-files/release.mk b/mk-files/release.mk index 40432c1b50..f94cbef580 100644 --- a/mk-files/release.mk +++ b/mk-files/release.mk @@ -46,13 +46,15 @@ endef # The glibc container doesn't need to publish to S3 so it doesn't need to $(caasenv-authenticate) .PHONY: gorelease-linux-glibc gorelease-linux-glibc: - GO111MODULE=off go get -u github.com/inconshreveable/mousetrap && \ - GOPRIVATE=github.com/confluentinc GONOSUMDB=github.com/confluentinc,github.com/golangci/go-misc VERSION=$(VERSION) S3FOLDER=$(S3_STAG_FOLDER_NAME)/confluent-cli goreleaser release --rm-dist -f .goreleaser-linux-glibc.yml + GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) goreleaser release --rm-dist -f .goreleaser-linux-glibc.yml .PHONY: gorelease-linux-glibc-arm64 gorelease-linux-glibc-arm64: - GO111MODULE=off go get -u github.com/inconshreveable/mousetrap && \ - GOPRIVATE=github.com/confluentinc GONOSUMDB=github.com/confluentinc,github.com/golangci/go-misc VERSION=$(VERSION) S3FOLDER=$(S3_STAG_FOLDER_NAME)/confluent-cli goreleaser release --rm-dist -f .goreleaser-linux-glibc-arm64.yml +ifneq (,$(findstring x86_64,$(shell uname -m))) + GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ goreleaser release --rm-dist -f .goreleaser-linux-glibc-arm64.yml +else + GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) goreleaser release --rm-dist -f .goreleaser-linux-glibc-arm64.yml +endif # This builds the Darwin, Windows and Linux binaries using goreleaser on the host computer. Goreleaser takes care of uploading the resulting binaries/archives/checksums to S3. # Uploading linux glibc files because its goreleaser file has set release disabled @@ -61,11 +63,10 @@ gorelease: $(eval token := $(shell (grep github.com ~/.netrc -A 2 | grep password || grep github.com ~/.netrc -A 2 | grep login) | head -1 | awk -F' ' '{ print $$2 }')) $(aws-authenticate) && \ echo "BUILDING FOR DARWIN, WINDOWS, AND ALPINE LINUX" && \ - GO111MODULE=off go get -u github.com/inconshreveable/mousetrap && \ GOPRIVATE=github.com/confluentinc VERSION=$(VERSION) GITHUB_TOKEN=$(token) S3FOLDER=$(S3_STAG_FOLDER_NAME)/confluent-cli goreleaser release --rm-dist --timeout 60m -f .goreleaser.yml; \ rm -f CLIEVCodeSigningCertificate2.pfx && \ echo "BUILDING FOR GLIBC LINUX" && \ - ./build_linux_glibc.sh && \ + scripts/build_linux_glibc.sh && \ $(aws-authenticate) && \ aws s3 cp dist/confluent_$(VERSION)_linux_amd64.tar.gz $(S3_STAG_PATH)/confluent-cli/archives/$(VERSION_NO_V)/confluent_$(VERSION)_linux_amd64.tar.gz && \ aws s3 cp dist/confluent_$(VERSION)_linux_arm64.tar.gz $(S3_STAG_PATH)/confluent-cli/archives/$(VERSION_NO_V)/confluent_$(VERSION)_linux_arm64.tar.gz && \ diff --git a/build_linux_glibc.sh b/scripts/build_linux_glibc.sh similarity index 69% rename from build_linux_glibc.sh rename to scripts/build_linux_glibc.sh index 6ea517c512..c038d3ee0b 100755 --- a/build_linux_glibc.sh +++ b/scripts/build_linux_glibc.sh @@ -3,13 +3,20 @@ aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin 050879227952.dkr.ecr.us-west-1.amazonaws.com go mod vendor -#amd64 + +# Build linux/amd64 docker build . -f ./dockerfiles/Dockerfile_linux_glibc -t cli-linux-glibc-builder-image docker container create --name cli-linux-glibc-builder cli-linux-glibc-builder-image docker container cp cli-linux-glibc-builder:/go/src/github.com/confluentinc/cli/dist/. ./dist/ docker container rm cli-linux-glibc-builder -#arm64 -docker build . -f ./dockerfiles/Dockerfile_linux_glibc_arm64 -t cli-linux-glibc-arm64-builder-image + +# Build linux/arm64 +architecture=$(uname -m) +if [ "$architecture" == 'x86_64' ]; then + docker build . -f ./dockerfiles/Dockerfile_linux_glibc_arm64_from_amd64 -t cli-linux-glibc-arm64-builder-image +else + docker build . -f ./dockerfiles/Dockerfile_linux_glibc_arm64 -t cli-linux-glibc-arm64-builder-image +fi docker container create --name cli-linux-glibc-arm64-builder cli-linux-glibc-arm64-builder-image docker container cp cli-linux-glibc-arm64-builder:/go/src/github.com/confluentinc/cli/dist/. ./dist/ docker container rm cli-linux-glibc-arm64-builder