2020-04-07 23:43:41 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-04-12 16:35:17 +02:00
|
|
|
PROJECTNAME=qrz
|
|
|
|
RELEASENAME=${PROJECTNAME}
|
2020-04-12 15:25:09 +02:00
|
|
|
VERSION="0"
|
2020-04-08 00:13:49 +02:00
|
|
|
|
2020-04-12 16:35:17 +02:00
|
|
|
GOOPTIONS="-mod=vendor"
|
2020-04-12 15:25:09 +02:00
|
|
|
SRCFILES=cmd/qrz/*.go
|
2020-04-07 23:47:40 +02:00
|
|
|
|
2020-04-12 15:25:09 +02:00
|
|
|
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
|
2020-04-12 16:35:17 +02:00
|
|
|
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
|
2020-04-12 15:25:09 +02:00
|
|
|
fi
|
2020-05-09 19:09:27 +02:00
|
|
|
|
2020-05-09 19:47:48 +02:00
|
|
|
echo "Running packr2"
|
2020-05-09 19:39:21 +02:00
|
|
|
if [[ -f ${GOPATH}/bin/packr2 ]]
|
2020-05-09 19:30:28 +02:00
|
|
|
then
|
|
|
|
${GOPATH}/bin/packr2
|
2020-05-09 19:39:21 +02:00
|
|
|
else
|
2020-05-09 19:47:48 +02:00
|
|
|
echo "packr2 binary not found"
|
2020-05-09 19:52:31 +02:00
|
|
|
echo $(ls /go/bin)
|
2020-05-09 19:39:21 +02:00
|
|
|
exit 1
|
2020-05-09 19:30:28 +02:00
|
|
|
fi
|
2020-05-09 19:20:11 +02:00
|
|
|
|
2020-05-09 19:47:48 +02:00
|
|
|
echo "Building project"
|
2020-04-26 10:15:14 +02:00
|
|
|
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
|
2020-05-09 19:09:27 +02:00
|
|
|
|
2020-04-12 15:25:09 +02:00
|
|
|
if [[ ! -z $DRONE_TAG ]]
|
|
|
|
then
|
2020-04-26 10:19:48 +02:00
|
|
|
tar -czvf ${RELEASENAME}.tar.gz ${PROJECTNAME}
|
2020-04-12 15:25:09 +02:00
|
|
|
fi
|
2020-05-09 19:47:48 +02:00
|
|
|
|
|
|
|
echo "Removing binary file"
|
2020-04-26 10:15:14 +02:00
|
|
|
rm ${PROJECTNAME}
|
2020-04-12 15:25:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
clean() {
|
|
|
|
rm -rf $RELEASEDIR
|
|
|
|
}
|
|
|
|
|
|
|
|
case $1 in
|
|
|
|
"build")
|
|
|
|
build
|
|
|
|
;;
|
|
|
|
"clean")
|
|
|
|
clean
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
2020-05-09 19:09:27 +02:00
|
|
|
esac
|