bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/build/release.sh (about)

     1  #!/bin/sh
     2  set -e
     3  
     4  if [ -z "$1"  ]; then
     5    echo "Usage: `basename $0` /path/to/bosun/repository"
     6    exit 1
     7  fi
     8  
     9  BOSUN_PATH=$1
    10  
    11  TIME=`date +%Y%m%d%H%M%S`
    12  export GIT_SHA=`cd ${BOSUN_PATH}; git rev-parse HEAD`
    13  
    14  build()
    15  {
    16  	export GOOS=$1
    17  	export GOARCH=$2
    18  	EXT=""
    19  	if [ $GOOS = "windows" ]; then
    20  		EXT=".exe"
    21  	fi
    22  	if [ $GOARCH = "arm" ]; then
    23  		export GOARM=${3-6}
    24  		EXT="v${GOARM}"
    25  	fi
    26  	echo $GOOS $GOARCH $EXT
    27  	if $BOSUN; then
    28  		go build -o ${OUTPUTDIR}bosun-$GOOS-$GOARCH$EXT -ldflags "-X bosun.org/_version.VersionSHA=$GIT_SHA -X bosun.org/_version.OfficialBuild=true -X bosun.org/_version.VersionDate=$TIME" bosun.org/cmd/bosun
    29  		go build -o ${OUTPUTDIR}tsdbrelay-$GOOS-$GOARCH$EXT -ldflags "-X bosun.org/_version.VersionSHA=$GIT_SHA -X bosun.org/_version.OfficialBuild=true -X bosun.org/_version.VersionDate=$TIME" bosun.org/cmd/tsdbrelay
    30  	fi
    31  	go build -o ${OUTPUTDIR}scollector-$GOOS-$GOARCH$EXT -ldflags "-X bosun.org/_version.VersionSHA=$GIT_SHA -X bosun.org/_version.OfficialBuild=true -X bosun.org/_version.VersionDate=$TIME" bosun.org/cmd/scollector
    32  }
    33  
    34  BOSUN=true
    35  for GOOS in windows linux; do
    36  	for GOARCH in amd64 386; do
    37  		build $GOOS $GOARCH
    38  	done
    39  done
    40  # darwin/386 is no longer supported
    41  build darwin amd64
    42  
    43  BOSUN=false
    44  
    45  build linux arm 5
    46  build linux arm 6
    47  build linux arm 7
    48  
    49  if [ "$GITHUB_ACCESS_TOKEN" = "" ]; then
    50  	echo GITHUB_ACCESS_TOKEN not set: not running githubRelease.go
    51  else
    52  	GOOS=linux
    53  	GOARCH=amd64
    54  	export BUILD_NUMBER=`${OUTPUTDIR}bosun-linux-amd64 -version | awk '{print $3}'`
    55  	go run build/release/githubRelease.go
    56  fi