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 <poan.yang@suse.com>
  • Loading branch information
FrankYang0529 authored and David Ko committed Nov 16, 2023
1 parent dedd3ca commit 4b991a5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ set -e

source $(dirname $0)/version

if [ "$(git rev-parse --abbrev-ref HEAD)" = "master" ]; then
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/longhorn-instance-manager/..."
fi

cd $(dirname $0)/..

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

0 comments on commit 4b991a5

Please sign in to comment.