From 1dd6865cb1e2cd1b533caf369902bd7e99f780e3 Mon Sep 17 00:00:00 2001 From: AJ Bond Date: Tue, 30 Apr 2019 07:18:33 -0700 Subject: [PATCH 1/4] Enable cross compile using goreleaser --- .gitignore | 1 + .goreleaser.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 3 +++ Makefile | 7 ++++++- 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .goreleaser.yml diff --git a/.gitignore b/.gitignore index 88ddcdf4..f5889482 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ _output/ +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..e35750c8 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,45 @@ +project_name: kubectl-trace +builds: + - goos: + - linux + - darwin + - windows + goarch: + - amd64 + - 386 + main: ./cmd/kubectl-trace + env: + - GO111MODULE=on + - CGO_ENABLED=0 + ldflags: | + -X github.com/iovisor/kubectl-trace/pkg/version.buildTime={{ .Timestamp }} + -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit={{ .Commit }} + -X github.com/iovisor/kubectl-trace/pkg/version.imageName={{ .Env.IMAGE_NAME }} + binary: kubectl-trace + - goos: + - linux + - darwin + - windows + goarch: + - amd64 + - 386 + main: ./cmd/trace-runner + env: + - GO111MODULE=on + - CGO_ENABLED=0 + ldflags: | + -X github.com/iovisor/kubectl-trace/pkg/version.buildTime={{ .Timestamp }} + -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit={{ .Commit }} + -X github.com/iovisor/kubectl-trace/pkg/version.imageName={{ .Env.IMAGE_NAME }} + binary: trace-runner + +archive: + format_overrides: + - goos: windows + format: zip + +snapshot: + name_template: 'master' + +release: + disable: true diff --git a/.travis.yml b/.travis.yml index aec8509d..c22189be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,13 @@ go: - 1.11.4 services: - docker +before_install: + - go get github.com/goreleaser/goreleaser script: - make test - make _output/bin/kubectl-trace - ./hack/ci-build-image.sh - make integration +- make cross after_success: - ./hack/ci-release-image.sh diff --git a/Makefile b/Makefile index 6c31a5d9..0f0e154b 100644 --- a/Makefile +++ b/Makefile @@ -37,9 +37,14 @@ ${kubectl_trace}: ${trace_runner}: CGO_ENABLED=1 $(GO) build ${LDFLAGS} -o $@ ./cmd/trace-runner +.PHONY: cross +cross: + IMAGE_NAME=$(IMAGE_NAME) go run github.com/goreleaser/goreleaser --snapshot --rm-dist + .PHONY: clean clean: - rm -Rf _output + $(RM) -R _output + $(RM) -R dist .PHONY: image/build-init image/build-init: From 869b21025108519ddb69b508cbdd2211f1846509 Mon Sep 17 00:00:00 2001 From: AJ Bond Date: Mon, 2 Sep 2019 23:07:57 -0400 Subject: [PATCH 2/4] fix(travis): set go modules on --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c22189be..68080e73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ go: services: - docker before_install: - - go get github.com/goreleaser/goreleaser + - GO111MODULE=on; go get github.com/goreleaser/goreleaser script: - make test - make _output/bin/kubectl-trace From e0a647104878278ed79bf65005205f3fb73884b1 Mon Sep 17 00:00:00 2001 From: AJ Bond Date: Mon, 2 Sep 2019 23:44:02 -0400 Subject: [PATCH 3/4] fix(goreleaser): update go release syntax and address duplicate ids --- .goreleaser.yml | 18 +++++++++++------- .travis.yml | 10 +++++++++- Makefile | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index e35750c8..5de2a45f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,6 +1,7 @@ project_name: kubectl-trace builds: - - goos: + - id: "kubectl-trace" + goos: - linux - darwin - windows @@ -16,7 +17,8 @@ builds: -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit={{ .Commit }} -X github.com/iovisor/kubectl-trace/pkg/version.imageName={{ .Env.IMAGE_NAME }} binary: kubectl-trace - - goos: + - id: "trace-runner" + goos: - linux - darwin - windows @@ -33,13 +35,15 @@ builds: -X github.com/iovisor/kubectl-trace/pkg/version.imageName={{ .Env.IMAGE_NAME }} binary: trace-runner -archive: - format_overrides: - - goos: windows - format: zip +archives: + - id: windows + format_overrides: + - goos: windows + format: zip snapshot: name_template: 'master' release: - disable: true + github: + prerelease: auto diff --git a/.travis.yml b/.travis.yml index 68080e73..28c59f27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ go: services: - docker before_install: - - GO111MODULE=on; go get github.com/goreleaser/goreleaser +- curl -LO https://github.com/goreleaser/goreleaser/releases/latest/download/goreleaser_amd64.deb && sudo dpkg -i goreleaser_amd64.deb script: - make test - make _output/bin/kubectl-trace @@ -16,3 +16,11 @@ script: - make cross after_success: - ./hack/ci-release-image.sh + +deploy: +- provider: script + skip_cleanup: true + script: goreleaser + on: + tags: true + condition: $TRAVIS_OS_NAME = linux diff --git a/Makefile b/Makefile index 0f0e154b..ede031eb 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ ${trace_runner}: .PHONY: cross cross: - IMAGE_NAME=$(IMAGE_NAME) go run github.com/goreleaser/goreleaser --snapshot --rm-dist + IMAGE_NAME=$(IMAGE_NAME) goreleaser --snapshot --rm-dist .PHONY: clean clean: From f812093b87efc779fe52ce6847aa3c27a7569761 Mon Sep 17 00:00:00 2001 From: AJ Bond Date: Mon, 9 Sep 2019 10:17:55 -0400 Subject: [PATCH 4/4] fix(goreleaser): add go mod tidy before build --- .goreleaser.yml | 3 +++ Makefile | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 5de2a45f..7ee61762 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,7 @@ project_name: kubectl-trace +before: + hooks: + - go mod tidy builds: - id: "kubectl-trace" goos: diff --git a/Makefile b/Makefile index ede031eb..af416208 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ ${trace_runner}: .PHONY: cross cross: - IMAGE_NAME=$(IMAGE_NAME) goreleaser --snapshot --rm-dist + IMAGE_NAME=$(IMAGE_NAME) GO111MODULE=on goreleaser --snapshot --rm-dist .PHONY: clean clean: