From f5542305abaa475660ab6549eb5b6ed5dccc645f Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Wed, 8 Jun 2022 18:42:00 -0400 Subject: [PATCH 1/3] prevent tagging validator release without updating version in miner.erl --- tag-release.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tag-release.sh b/tag-release.sh index fa57f8779..0196a2973 100755 --- a/tag-release.sh +++ b/tag-release.sh @@ -13,6 +13,30 @@ dep_hash() { git show "${MINER}:rebar.lock" | grep -A2 "${DEP}" | sed -e "s/.*\"\(.*\)\".*/\1/" | tr '\n' ' ' | awk '{print $3}' } +strip_zeros() { + local VZN=$(echo $1 | sed -e 's/0//g') + + if [[ $VZN == "" ]]; then + echo "0" + else + echo $VZN + fi +} + +val_tag() { + local VAL_VERSION + local MAJ + local MIN + local PATCH + + VAL_VERSION=$(grep -A 1 "%% MMMmmmPPPP" src/miner.erl | grep -o -E '[0-9]+') + MAJ=$(echo $VAL_VERSION | awk '{print substr( $0, 1, 3 )}') + MIN=$(echo $VAL_VERSION | awk '{print substr( $0, 4, 3 )}') + PATCH=$(echo $VAL_VERSION | awk '{print substr( $0, 7, 4 )}') + + echo "validator$(strip_zeros $MAJ).$(strip_zeros $MIN).$(strip_zeros $PATCH)" +} + declare -r repos="blockchain libp2p sibyl ecc508 relcast dkg hbbft helium_proto" declare NAMED_TAG @@ -44,6 +68,11 @@ fi MINER_HASH=$1 if [[ ! -z $NAMED_TAG ]]; then + VAL_VERSION_TO_TAG=$(val_tag) + if [[ ! $VAL_VERSION_TO_TAG == $NAMED_TAG ]]; then + echo "tag doesnt match committed version; should be ${VAL_VERSION_TO_TAG} per miner.erl!" + exit 1 + fi RELEASE_TAG=$NAMED_TAG else while git tag -l | grep -q "${TAG_NAME}.${TAG_NUMBER}"; do From f9549ec59b315a1dc10fbb7c0adaed15ac4ab081 Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Wed, 8 Jun 2022 20:53:50 -0400 Subject: [PATCH 2/3] dont rely on comment for grep pattern --- tag-release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tag-release.sh b/tag-release.sh index 0196a2973..64142ad2c 100755 --- a/tag-release.sh +++ b/tag-release.sh @@ -29,7 +29,7 @@ val_tag() { local MIN local PATCH - VAL_VERSION=$(grep -A 1 "%% MMMmmmPPPP" src/miner.erl | grep -o -E '[0-9]+') + VAL_VERSION=$(sed -n "/^version() ->$/,/\.$/p" src/miner.erl | grep -o -E '[0-9]{10}') MAJ=$(echo $VAL_VERSION | awk '{print substr( $0, 1, 3 )}') MIN=$(echo $VAL_VERSION | awk '{print substr( $0, 4, 3 )}') PATCH=$(echo $VAL_VERSION | awk '{print substr( $0, 7, 4 )}') From e2206e3a9467400598d62be94cc721f3772730e4 Mon Sep 17 00:00:00 2001 From: jeffgrunewald Date: Thu, 9 Jun 2022 09:30:49 -0400 Subject: [PATCH 3/3] handle trailing zero correctly --- tag-release.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tag-release.sh b/tag-release.sh index 64142ad2c..b4f91764a 100755 --- a/tag-release.sh +++ b/tag-release.sh @@ -13,16 +13,6 @@ dep_hash() { git show "${MINER}:rebar.lock" | grep -A2 "${DEP}" | sed -e "s/.*\"\(.*\)\".*/\1/" | tr '\n' ' ' | awk '{print $3}' } -strip_zeros() { - local VZN=$(echo $1 | sed -e 's/0//g') - - if [[ $VZN == "" ]]; then - echo "0" - else - echo $VZN - fi -} - val_tag() { local VAL_VERSION local MAJ @@ -34,7 +24,7 @@ val_tag() { MIN=$(echo $VAL_VERSION | awk '{print substr( $0, 4, 3 )}') PATCH=$(echo $VAL_VERSION | awk '{print substr( $0, 7, 4 )}') - echo "validator$(strip_zeros $MAJ).$(strip_zeros $MIN).$(strip_zeros $PATCH)" + echo "validator$((10#$MAJ)).$((10#$MIN)).$((10#$PATCH))" } declare -r repos="blockchain libp2p sibyl ecc508 relcast dkg hbbft helium_proto"