pki/ci-build.sh

63 lines
1.0 KiB
Bash
Raw Normal View History

2020-11-25 20:36:07 +01:00
#!/bin/bash
2020-12-04 22:29:14 +01:00
set -e
2020-11-25 20:36:07 +01:00
PROJECTNAME=pki
RELEASENAME=${PROJECTNAME}
VERSION="0"
GOOPTIONS="-mod=vendor"
SRCFILES=cmd/pki/*.go
build() {
2020-11-29 13:34:51 +01:00
echo "Begin of build"
2020-11-25 20:36:07 +01:00
if [[ ! -z $DRONE_TAG ]]
then
2020-11-29 13:34:51 +01:00
echo "Drone tag set, let's do a release"
2020-11-25 20:36:07 +01:00
VERSION=$DRONE_TAG
2020-11-29 13:34:51 +01:00
echo "${PROJECTNAME} ${VERSION}" > /build/VERSION
2020-11-25 20:36:07 +01:00
elif [[ ! -z $DRONE_TAG ]]
then
2020-11-29 13:34:51 +01:00
echo "Drone not set, let's only do a build"
2020-11-25 20:36:07 +01:00
VERSION=$DRONE_COMMIT
fi
if [[ ! -z $VERSION && ! -z $GOOS && ! -z $GOARCH ]]
then
2020-11-29 13:34:51 +01:00
echo "Let's set a release name"
2020-11-25 20:36:07 +01:00
RELEASENAME=${PROJECTNAME}-${VERSION}-${GOOS}-${GOARCH}
fi
echo "Building project"
go build -o ${PROJECTNAME} ${GOOPTIONS} ${SRCFILES}
if [[ ! -z $DRONE_TAG ]]
then
2020-11-29 13:34:51 +01:00
echo "Let's make archives"
mkdir -p /build
tar -czvf /build/${RELEASENAME}.tar.gz ${PROJECTNAME}
2020-11-25 20:36:07 +01:00
fi
echo "Removing binary file"
rm ${PROJECTNAME}
2020-11-29 13:34:51 +01:00
echo "End of build"
2020-11-25 20:36:07 +01:00
}
clean() {
rm -rf $RELEASEDIR
}
case $1 in
"build")
build
;;
"clean")
clean
;;
*)
2020-11-29 13:34:51 +01:00
echo "No options choosen"
exit 1
2020-11-25 20:36:07 +01:00
;;
2020-11-29 13:34:51 +01:00
esac