68 lines
1.1 KiB
Bash
Executable File
68 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
PROJECTNAME=qrz
|
|
RELEASENAME=${PROJECTNAME}
|
|
VERSION="0"
|
|
|
|
GOOPTIONS="-mod=vendor"
|
|
SRCFILES=cmd/qrz/*.go
|
|
|
|
build() {
|
|
echo "Begin of build"
|
|
if [[ ! -z $DRONE_TAG ]]
|
|
then
|
|
echo "Drone tag set, let's do a release"
|
|
VERSION=$DRONE_TAG
|
|
echo "${PROJECTNAME} ${VERSION}" > /build/VERSION
|
|
elif [[ ! -z $DRONE_TAG ]]
|
|
then
|
|
echo "Drone not set, let's only do a build"
|
|
VERSION=$DRONE_COMMIT
|
|
fi
|
|
|
|
if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
|
|
then
|
|
echo "Let's set a release name"
|
|
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
|
|
fi
|
|
|
|
echo "Building project"
|
|
go generate ${SRCFILES}
|
|
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
|
|
|
|
if [[ ! -z $DRONE_TAG ]]
|
|
then
|
|
echo "Let's make archives"
|
|
mkdir -p /build
|
|
tar -czvf /build/${RELEASENAME}.tar.gz ${PROJECTNAME}
|
|
fi
|
|
|
|
echo "Removing binary file"
|
|
rm ${PROJECTNAME}
|
|
|
|
echo "End of build"
|
|
}
|
|
|
|
clean() {
|
|
rm -rf $RELEASEDIR
|
|
for i in ${PROJECTNAME} "cmd/qrz/packrd" "cmd/qrz/main-packr.go"
|
|
do
|
|
rm -rf $i
|
|
done
|
|
}
|
|
|
|
case $1 in
|
|
"build")
|
|
build
|
|
;;
|
|
"clean")
|
|
clean
|
|
;;
|
|
*)
|
|
echo "No options choosen"
|
|
exit 1
|
|
;;
|
|
esac
|