build: add version checks to release script

Enhances the release script to check that the specified tag
is also the tag that is currently checked out. In addition to that, the
script also ensures that the tag and the version specified in version.go
match.
This commit is contained in:
Joost Jager 2020-01-03 10:34:11 +01:00
parent f289a39c1a
commit eb96470c7f
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7

@ -16,6 +16,35 @@ if [[ $1x = x ]]; then
TAG=$DATE-$VERSION
else
TAG=$1
# If a tag is specified, ensure that that tag is present and checked out.
if [[ $TAG != $(git tag -l --points-at HEAD) ]]; then
echo "tag $TAG not checked out"
exit 1
fi
# Build lnd to extract version.
go build github.com/lightningnetwork/lnd/cmd/lnd
# Extract version command output.
LND_VERSION_OUTPUT=`./lnd --version`
# Use a regex to isolate the version string.
LND_VERSION_REGEX="lnd version (.+) commit"
if [[ $LND_VERSION_OUTPUT =~ $LND_VERSION_REGEX ]]; then
# Prepend 'v' to match git tag naming scheme.
LND_VERSION="v${BASH_REMATCH[1]}"
echo "version: $LND_VERSION"
# Match git tag with lnd version.
if [[ $TAG != $LND_VERSION ]]; then
echo "lnd version $LND_VERSION does not match tag $TAG"
exit 1
fi
else
echo "malformed lnd version output"
exit 1
fi
fi
go mod vendor