qrz/ci-build.sh
Paul Lecuq 86b90dffd8
Some checks failed
continuous-integration/drone/push Build is failing
updated ci-build.sh
2020-05-09 19:52:31 +02:00

59 lines
890 B
Bash
Executable File

#!/bin/bash
PROJECTNAME=qrz
RELEASENAME=${PROJECTNAME}
VERSION="0"
GOOPTIONS="-mod=vendor"
SRCFILES=cmd/qrz/*.go
build() {
if [[ ! -z $DRONE_TAG ]]
then
VERSION=$DRONE_TAG
elif [[ ! -z $DRONE_TAG ]]
then
VERSION=$DRONE_COMMIT
fi
if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
then
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
fi
echo "Running packr2"
if [[ -f ${GOPATH}/bin/packr2 ]]
then
${GOPATH}/bin/packr2
else
echo "packr2 binary not found"
echo $(ls /go/bin)
exit 1
fi
echo "Building project"
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
if [[ ! -z $DRONE_TAG ]]
then
tar -czvf ${RELEASENAME}.tar.gz ${PROJECTNAME}
fi
echo "Removing binary file"
rm ${PROJECTNAME}
}
clean() {
rm -rf $RELEASEDIR
}
case $1 in
"build")
build
;;
"clean")
clean
;;
*)
;;
esac