diff --git a/hack/build-binaries.sh b/hack/build-binaries.sh index 68a24cc2..165a182e 100755 --- a/hack/build-binaries.sh +++ b/hack/build-binaries.sh @@ -4,8 +4,12 @@ set -e -x -u BUILD_VALUES= ./hack/build.sh -GOOS=darwin GOARCH=amd64 go build -o kbld-darwin-amd64 ./cmd/kbld/... -GOOS=linux GOARCH=amd64 go build -o kbld-linux-amd64 ./cmd/kbld/... -GOOS=windows GOARCH=amd64 go build -o kbld-windows-amd64.exe ./cmd/kbld/... +# makes builds reproducible +export CGO_ENABLED=0 +repro_flags="-ldflags=-buildid= -trimpath" + +GOOS=darwin GOARCH=amd64 go build $repro_flags -o kbld-darwin-amd64 ./cmd/kbld/... +GOOS=linux GOARCH=amd64 go build $repro_flags -o kbld-linux-amd64 ./cmd/kbld/... +GOOS=windows GOARCH=amd64 go build $repro_flags -o kbld-windows-amd64.exe ./cmd/kbld/... shasum -a 256 ./kbld-*-amd64* diff --git a/hack/build.sh b/hack/build.sh index fc9ee1f2..020d86a6 100755 --- a/hack/build.sh +++ b/hack/build.sh @@ -2,6 +2,10 @@ set -e -x -u +# makes builds reproducible +export CGO_ENABLED=0 +repro_flags="-ldflags=-buildid= -trimpath" + go fmt ./cmd/... ./pkg/... ./test/... build_values_path="../../../${BUILD_VALUES:-./hack/build-values-default.yml}" @@ -21,12 +25,12 @@ build_values_path="../../../${BUILD_VALUES:-./hack/build-values-default.yml}" mv tmp/generated.go.txt pkg/kbld/website/generated.go # export GOOS=linux GOARCH=amd64 -go build -o kbld ./cmd/kbld/... +go build $repro_flags -o kbld ./cmd/kbld/... ./kbld version # build aws lambda binary export GOOS=linux GOARCH=amd64 -go build -o ./tmp/main ./cmd/kbld-lambda-website/... +go build $repro_flags -o ./tmp/main ./cmd/kbld-lambda-website/... ( cd tmp chmod +x main