2021-11-16 18:04:21 +00:00
|
|
|
VERSION=$(git describe --tags --abbrev=0)
|
|
|
|
if [ $? -ne 0 ]; then VERSION=$DRONE_TAG; fi
|
|
|
|
BUILD=$(git rev-parse --short HEAD)
|
|
|
|
if [ $? -ne 0 ]; then BUILD=${DRONE_COMMIT:0:7}; fi
|
|
|
|
|
|
|
|
PROJ=gterm
|
|
|
|
DIST=dist
|
|
|
|
|
|
|
|
LDFLAGS="-ldflags \"-X main.Version=${VERSION} -X main.Build=${BUILD} -w -s\""
|
|
|
|
FAILURES=""
|
|
|
|
|
|
|
|
PLATFORMS="darwin/amd64 darwin/arm64"
|
|
|
|
PLATFORMS="$PLATFORMS linux/amd64"
|
|
|
|
|
|
|
|
for PLATFORM in $PLATFORMS; do
|
|
|
|
GOOS=${PLATFORM%/*}
|
|
|
|
GOARCH=${PLATFORM#*/}
|
|
|
|
BIN_FILENAME="${PROJ}"
|
2021-11-18 02:51:41 +00:00
|
|
|
CMD="CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build ${LDFLAGS} -o ${DIST}/${BIN_FILENAME} cmd/gterm/main.go"
|
2021-11-16 18:04:21 +00:00
|
|
|
echo "${CMD}"
|
|
|
|
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
|
|
|
sh -c "cd ${DIST} && tar -czf ${PROJ}-${VERSION}-${GOOS}-${GOARCH}.tar.gz ${BIN_FILENAME} && rm ${BIN_FILENAME}"
|
2021-11-17 16:10:35 +00:00
|
|
|
|
2021-11-16 18:04:21 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [[ "${FAILURES}" != "" ]]; then
|
|
|
|
echo ""
|
|
|
|
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
|
|
|
|
exit 1
|
|
|
|
fi
|