2021-10-23 18:15:38 +00:00
|
|
|
|
2021-10-21 08:04:57 +00:00
|
|
|
VERSION=$(git describe --tags --abbrev=0)
|
2021-10-23 18:15:38 +00:00
|
|
|
if [ $? -ne 0 ]; then VERSION=$DRONE_TAG; fi
|
2021-10-21 08:04:57 +00:00
|
|
|
BUILD=$(git rev-parse --short HEAD)
|
2021-10-23 18:15:38 +00:00
|
|
|
if [ $? -ne 0 ]; then BUILD=${DRONE_COMMIT:0:7}; fi
|
|
|
|
|
|
|
|
PROJ=configui
|
2021-10-21 08:04:57 +00:00
|
|
|
HUB=hub.kumoly.io
|
|
|
|
HUB_PROJECT=tools
|
2021-10-23 16:49:44 +00:00
|
|
|
DIST=dist
|
2021-10-21 08:04:57 +00:00
|
|
|
|
2021-11-08 09:03:22 +00:00
|
|
|
LDFLAGS="-ldflags \"-X main.Version=${VERSION} -X main.Build=${BUILD} -w -s\""
|
2021-10-23 16:49:44 +00:00
|
|
|
FAILURES=""
|
2021-10-21 08:04:57 +00:00
|
|
|
|
2021-10-23 16:49:44 +00:00
|
|
|
PLATFORMS="darwin/amd64 darwin/arm64"
|
2021-11-05 16:14:30 +00:00
|
|
|
PLATFORMS="$PLATFORMS windows/amd64"
|
2021-10-23 16:49:44 +00:00
|
|
|
PLATFORMS="$PLATFORMS linux/amd64"
|
2021-10-21 08:04:57 +00:00
|
|
|
|
|
|
|
|
2021-10-23 16:49:44 +00:00
|
|
|
for PLATFORM in $PLATFORMS; do
|
|
|
|
GOOS=${PLATFORM%/*}
|
|
|
|
GOARCH=${PLATFORM#*/}
|
|
|
|
BIN_FILENAME="${PROJ}"
|
|
|
|
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
|
|
|
|
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build ${LDFLAGS} -o ${DIST}/${BIN_FILENAME} $@"
|
|
|
|
echo "${CMD}"
|
|
|
|
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
2021-10-23 17:31:25 +00:00
|
|
|
sh -c "cd ${DIST} && tar -czf ${PROJ}-${VERSION}-${GOOS}-${GOARCH}.tar.gz ${BIN_FILENAME} && rm ${BIN_FILENAME}"
|
2021-10-23 16:49:44 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "${FAILURES}" != "" ]]; then
|
|
|
|
echo ""
|
|
|
|
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
|
|
|
|
exit 1
|
|
|
|
fi
|