qrz/ci-build.sh

49 lines
730 B
Bash
Raw Normal View History

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
go get github.com/gobuffalo/packr/v2/packr2
2020-05-09 19:20:11 +02:00
${GOPATH}/bin/packr2
2020-04-26 10:15:14 +02:00
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
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-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
;;
*)
;;
esac