Skip to content

Commit

Permalink
feat: add -cover build to master/version-head branch
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>
  • Loading branch information
FrankYang0529 authored and David Ko committed Nov 16, 2023
1 parent 51a0031 commit 7735176
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ set -e

source $(dirname $0)/version

LINKFLAGS="-X main.Version=$VERSION
-X main.GitCommit=$GITCOMMIT
-X main.BuildDate=$BUILDDATE
-linkmode external -extldflags -static"

# add coverage flags if there is no tag and it's on master or a version branch like v1.6.x
COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
COMMIT_TAG=$(git tag --points-at HEAD | head -n 1)
if [[ "$COMMIT_TAG" == "" ]] && [[ "$COMMIT_BRANCH" == master || "$COMMIT_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x$ ]]; then
COVER="-cover"
COVERPKG="-coverpkg=github.com/longhorn/backing-image-manager/..."
fi

cd $(dirname $0)/..

mkdir -p bin
go build -ldflags \
"-X main.Version=$VERSION \
-X main.GitCommit=$GITCOMMIT \
-X main.BuildDate=$BUILDDATE \
-linkmode external -extldflags -static" \
-o bin/backing-image-manager
go build -o bin/backing-image-manager -ldflags "$LINKFLAGS" $COVER $COVERPKG

0 comments on commit 7735176

Please sign in to comment.