herald.go/build_and_push.sh

29 lines
719 B
Bash
Raw Normal View History

2021-07-06 02:20:38 +02:00
#!/bin/bash
2021-09-28 14:31:11 +02:00
IMPORT_PATH="github.com/lbryio/hub"
2021-09-24 22:24:22 +02:00
function print_and_die() {
echo "$1"
exit 1
}
2021-07-06 02:20:38 +02:00
# Get new tags from remote
git fetch --tags
# Get latest tag name
2021-09-24 22:24:22 +02:00
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
2021-07-06 02:20:38 +02:00
# Make sure it match the format vX.XXXX.XX.XX
2021-09-24 22:24:22 +02:00
[[ $LATEST_TAG =~ ^v[0-9]+\.[0-9]{4}\.[0-9]{2}\.[0-9]{2}.*$ ]] || print_and_die "bad version ${LATEST_TAG}"
VERSION=$LATEST_TAG
echo "using tag $LATEST_TAG"
2021-07-06 02:20:38 +02:00
# Checkout latest tag
2021-09-24 22:24:22 +02:00
git checkout "$LATEST_TAG"
2021-07-06 02:20:38 +02:00
2021-09-28 14:31:11 +02:00
CGO_ENABLED=0 go build -v -ldflags "-X ${IMPORT_PATH}/meta.Version=${VERSION}"
2021-07-06 02:20:38 +02:00
docker build . -t lbry/hub:latest
2021-09-24 22:24:22 +02:00
docker tag lbry/hub:latest lbry/hub:"$LATEST_TAG"
2021-07-06 02:20:38 +02:00
docker push lbry/hub:latest
2021-09-24 22:24:22 +02:00
docker push lbry/hub:"$LATEST_TAG"