meilisearch/.github/scripts/check-release.sh

29 lines
721 B
Bash
Raw Normal View History

#!/bin/sh
2022-06-21 16:46:32 +08:00
# check_tag $current_tag $file_tag $file_name
function check_tag {
if [ "$1" != "$2" ]; then
2022-06-22 18:20:12 +08:00
echo "Error: the current tag does not match the version in $3: found $1 - expected $2"
ret=1
2022-06-21 16:46:32 +08:00
fi
}
2022-06-22 18:20:12 +08:00
ret=0
2022-06-21 16:46:32 +08:00
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
2022-06-22 18:20:12 +08:00
toml_files='*/Cargo.toml'
for toml_file in $toml_files;
do
2022-06-22 18:20:12 +08:00
file_tag="$(grep '^version = ' $toml_file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')"
check_tag $current_tag $file_tag $toml_file
done
2022-06-21 16:46:32 +08:00
lock_file='Cargo.lock'
lock_tag=$(grep -A 1 'name = "meilisearch-auth"' $lock_file | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
check_tag $current_tag $lock_tag $lock_file
2022-06-22 18:20:12 +08:00
if [ "$ret" -eq 0 ] ; then
echo 'OK'
fi
exit $ret