configui/release.sh

31 lines
947 B
Bash
Raw Normal View History

2021-10-21 08:04:57 +00:00
VERSION=$(git describe --tags --abbrev=0)
BUILD=$(git rev-parse --short HEAD)
2021-10-23 16:49:44 +00:00
PROJ=$(basename "$(pwd)")
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-10-23 16:49:44 +00:00
LDFLAGS="-ldflags \"-X main.Version=${VERSION} -X main.Build=${BUILD} -w\""
FAILURES=""
2021-10-21 08:04:57 +00:00
2021-10-23 16:49:44 +00:00
PLATFORMS="darwin/amd64 darwin/arm64"
PLATFORMS="$PLATFORMS windows/amd64" # arm compilation not available for Windows
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}"
sh -c "cd ${DIST} && zip ${PROJ}-${VERSION}-${GOOS}-${GOARCH}.zip ${BIN_FILENAME} && rm ${BIN_FILENAME}"
done
if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
exit 1
fi