From 7fc9002ce1d46173ffc9f68e45d8954a910dc04b Mon Sep 17 00:00:00 2001 From: Florian Wilhelm Date: Tue, 2 Jun 2020 12:32:29 +0200 Subject: [PATCH] Build go binary without debug symbols (#1618) This produces a much smaller binary for faster downloads. See https://golang.org/cmd/link/ for docs on -s and -w flag. --- .github/workflows/upload-go-master.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/upload-go-master.yml b/.github/workflows/upload-go-master.yml index 414045de0..a2639a0a3 100644 --- a/.github/workflows/upload-go-master.yml +++ b/.github/workflows/upload-go-master.yml @@ -16,10 +16,13 @@ jobs: - env: CGO_ENABLED: 0 run: | - go build -ldflags "-X github.com/SAP/jenkins-library/cmd.GitCommit=${GITHUB_SHA} \ + # See https://golang.org/cmd/link/ for info on -w (omit the DWARF symbol table) and -s (omit the symbol table and debug information) + # We use those flags to get a smaller compiled binary for faster downloads. + go build -ldflags "-w -s -X github.com/SAP/jenkins-library/cmd.GitCommit=${GITHUB_SHA} \ -X github.com/SAP/jenkins-library/pkg/log.LibraryRepository=${GITHUB_REPOSITORY} \ -X github.com/SAP/jenkins-library/pkg/telemetry.LibraryRepository=https://github.com/${GITHUB_REPOSITORY}.git" \ -o piper_master . + stat --printf="File size of piper_master in bytes: %s\n" piper_master - uses: SAP/project-piper-action@master with: piper-version: master