36 lines
1.1 KiB
Bash
36 lines
1.1 KiB
Bash
VERSION=$(git describe --tags --abbrev=0)
|
|
if [ $? -ne 0 ]; then VERSION=$DRONE_TAG; fi
|
|
[ -z "$VERSION" ] && VERSION=v0.0.0
|
|
BUILD=$(git rev-parse --short HEAD)
|
|
if [ $? -ne 0 ]; then BUILD=${DRONE_COMMIT:0:7}; fi
|
|
|
|
PROJ=talent
|
|
DIST=dist
|
|
|
|
LDFLAGS="-ldflags \"-X main.Version=${VERSION} -X main.Build=${BUILD} -w -s -extldflags '-static'\""
|
|
GOFLAGS="-a -tags netgo"
|
|
FAILURES=""
|
|
|
|
PLATFORMS="linux/s390x"
|
|
|
|
|
|
for PLATFORM in $PLATFORMS; do
|
|
GOOS=${PLATFORM%/*}
|
|
GOARCH=${PLATFORM#*/}
|
|
BIN_FILENAME="${PROJ}"
|
|
if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
|
|
CMD="CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build ${GOFLAGS} ${LDFLAGS} -o ${DIST}/${BIN_FILENAME} *.go"
|
|
echo "${CMD}"
|
|
eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
|
|
ssh root@bot.ework.tw rm talent
|
|
scp ${DIST}/${BIN_FILENAME} root@bot.ework.tw:~
|
|
ssh root@bot.ework.tw chmod +x talent
|
|
# ssh root@bot.ework.tw screen -X quit
|
|
# ssh root@bot.ework.tw screen -d -m ./talent -dev
|
|
done
|
|
|
|
if [[ "${FAILURES}" != "" ]]; then
|
|
echo ""
|
|
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
|
|
exit 1
|
|
fi |