1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-04 04:07:16 +02:00

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.
This commit is contained in:
Florian Wilhelm 2020-06-02 12:32:29 +02:00 committed by GitHub
parent c2de96ab43
commit 7fc9002ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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