2021-09-14 23:31:28 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
# Validate lotus version matches the current tag
|
|
|
|
# $1 - lotus path to execute
|
|
|
|
# $2 - lotus git tag for this release
|
|
|
|
function validate_lotus_version_matches_tag(){
|
|
|
|
# sanity checks
|
|
|
|
if [[ $# != 2 ]]; then
|
|
|
|
echo "expected 2 args for validate_lotus_version, got ${$#}"
|
|
|
|
exit 100
|
|
|
|
fi
|
|
|
|
|
|
|
|
# extract version from `lotus --version` response
|
|
|
|
lotus_path=$1
|
|
|
|
# get version
|
|
|
|
lotus_raw_version=`${lotus_path} --version`
|
|
|
|
# grep for version string
|
2021-09-22 19:00:59 +00:00
|
|
|
lotus_actual_version=`echo ${lotus_raw_version} | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'`
|
2021-09-14 23:31:28 +00:00
|
|
|
|
|
|
|
# trim leading 'v'
|
|
|
|
tag=${2#v}
|
|
|
|
# trim possible -rc[0-9]
|
|
|
|
expected_version=${tag%-*}
|
|
|
|
|
|
|
|
# check the versions are consistent
|
|
|
|
if [[ ${expected_version} != ${lotus_actual_version} ]]; then
|
|
|
|
echo "lotus version does not match build tag"
|
|
|
|
exit 101
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_lotus_path=$1
|
|
|
|
|
2024-05-22 12:47:29 +00:00
|
|
|
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
2024-05-16 11:31:08 +00:00
|
|
|
validate_lotus_version_matches_tag "${_lotus_path}" "${GITHUB_REF#refs/tags/}"
|
2021-09-14 23:31:28 +00:00
|
|
|
else
|
2024-05-16 11:31:08 +00:00
|
|
|
echo "$GITHUB_REF is not a tag, skipping version check"
|
2021-09-14 23:31:28 +00:00
|
|
|
fi
|