github.com/ericwq/aprilsh@v0.0.0-20240517091432-958bc568daa0/frontend/client/build.sh (about) 1 #!/bin/sh 2 3 # 4 # Terminate the test if any command below does not complete successfully. 5 set -e 6 7 # 8 # prepare coverage directory 9 rm -rf coverage 10 mkdir -p coverage/unit 11 mkdir -p coverage/int 12 13 # selecting package for integration coverage test 14 PKGS="github.com/ericwq/aprilsh/frontend/client" 15 16 # prepare for ldflags 17 _module_name=$(head ../../go.mod | grep '^module' | awk '{print $2}') 18 _go_version=$(go version | grep 'version' | awk '{print $3}') 19 _git_tag=$(git describe --tags) 20 _git_commit=$(git rev-parse --short HEAD) 21 _git_branch=$(git rev-parse --abbrev-ref HEAD) 22 23 # set ldflags 24 ldflags="-s -w \ 25 -X $_module_name/frontend.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%S) \ 26 -X $_module_name/frontend.GitBranch=$_git_branch \ 27 -X $_module_name/frontend.GitCommit=$_git_commit \ 28 -X $_module_name/frontend.GitTag=$_git_tag \ 29 -X $_module_name/frontend.GoVersion=$_go_version \ 30 " 31 # required for github.com/docker/docker 32 export GO111MODULE=auto 33 34 # build client for test 35 echo "build client start: $(date '+%F %T')" 36 go build -cover -coverpkg=$PKGS -ldflags="$ldflags" -o ~/.local/bin/apsh 37 echo "build client end : $(date '+%F %T')" 38 echo "output client to : ~/.local/bin/apsh" 39 echo "run with : GOCOVERDIR=./coverage/int ~/.local/bin/apsh -verbose ide@localhost" 40 41 # chech version number 42 # if [ "$1" != "" ]; then Version=$1;else 43 # read -p "Input Build Version: " Version; if [ "$Version" = "" ]; then echo "The input cannot be empty";exit;fi 44 # fi