Skip to content

Commit

Permalink
disable CGO and make builds reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
cppforlife committed Jan 16, 2020
1 parent 5ce665a commit 9fb3393
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions hack/build-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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*
8 changes: 6 additions & 2 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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
Expand Down

0 comments on commit 9fb3393

Please sign in to comment.