lotus/scripts/version-check.sh
Piotr Galar cfbe59d182
fix: ci: keep lotus checkout clean in the release workflow (#12028)
* ci: keep lotus checkout clean in the release workflow

* ci: allow providing custom ref to the release workflow

* ci: fix version check performed during the release

* ci: fix install go step of the release workflow

* ci: fix the working directory for the install go step in release workflow

* ci: provide github ref to lotus scripts explicitly

* ci: use actions from the chosen ref in release workflow

* ci: fix install go in release workflow

* ci: fix artifact upload in release workflow

* ci: set INPUTS_REF variable in release workflow

* ci: fix publish checksums script

* ci: allow releasing docker from an arbitrary ref

* ci: fix docker channel discovery
2024-05-22 14:47:29 +02:00

40 lines
1.0 KiB
Bash
Executable File

#!/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
lotus_actual_version=`echo ${lotus_raw_version} | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'`
# 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
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
validate_lotus_version_matches_tag "${_lotus_path}" "${GITHUB_REF#refs/tags/}"
else
echo "$GITHUB_REF is not a tag, skipping version check"
fi