pki/ci-build.sh

50 lines
749 B
Bash
Raw Normal View History

2020-11-25 20:36:07 +01:00
#!/bin/bash
PROJECTNAME=pki
RELEASENAME=${PROJECTNAME}
VERSION="0"
GOOPTIONS="-mod=vendor"
SRCFILES=cmd/pki/*.go
build() {
if [[ ! -z $DRONE_TAG ]]
then
VERSION=$DRONE_TAG
echo $DRONE_TAG > ./VERSION
elif [[ ! -z $DRONE_TAG ]]
then
VERSION=$DRONE_COMMIT
fi
if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
then
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
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