Skip to content

Commit

Permalink
Aditional flags options for go build
Browse files Browse the repository at this point in the history
Signed-off-by: debasishbsws <debasishbsws.dev@gmail.com>
  • Loading branch information
debasishbsws committed Nov 6, 2023
1 parent 4cdad80 commit 6ef42e8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/build/pipelines/go/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ inputs:
description:
List of [pattern=]arg to pass to the go compiler with -ldflags

flags:
description: |
List of any aditional go build flags e.g: -mod=vendor -gcflags="-m=2", etc.
install-dir:
description: |
Directory where binaries will be installed
Expand All @@ -68,6 +72,7 @@ pipeline:
- runs: |
TAGS=""
LDFLAGS=""
FLAGS=""
if [ ! "${{inputs.tags}}" == "" ]; then
TAGS="${{inputs.tags}}"
Expand All @@ -77,6 +82,10 @@ pipeline:
LDFLAGS="${{inputs.ldflags}}"
fi
if [ ! "${{inputs.flags}}" == "" ]; then
FLAGS="${{inputs.flags}}"
fi
BASE_PATH="${{inputs.prefix}}/${{inputs.install-dir}}/${{inputs.output}}"
cd "${{inputs.modroot}}"
Expand All @@ -90,4 +99,4 @@ pipeline:
# If vendor is specified, update the vendor directory
"${{inputs.vendor}}" && go mod vendor
fi
go build -o "${{targets.contextdir}}"/${BASE_PATH} -tags "${TAGS}" -ldflags "${LDFLAGS}" -trimpath ${{inputs.packages}}
go build -o "${{targets.contextdir}}"/${BASE_PATH} -tags "${TAGS}" -ldflags "${LDFLAGS}" ${FLAGS} -trimpath ${{inputs.packages}}

0 comments on commit 6ef42e8

Please sign in to comment.