From eb96470c7f9d6ec7b167e6249d49728226cdec56 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Fri, 3 Jan 2020 10:34:11 +0100 Subject: [PATCH] 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. --- build/release/release.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/build/release/release.sh b/build/release/release.sh index bf78cb3e..8bb5c1e4 100755 --- a/build/release/release.sh +++ b/build/release/release.sh @@ -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