Repository: meilisearch/meilisearch
File: .github/scripts/check-release.sh (Shell)

Code before:
#!/bin/sh

# Checking if current tag matches the package version
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
file1='meilisearch-auth/Cargo.toml'
file2='meilisearch-http/Cargo.toml'
file3='meilisearch-lib/Cargo.toml'
file4='meilisearch-types/Cargo.toml'
file5='Cargo.lock'

file_tag1=$(grep '^version = ' $file1 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
file_tag2=$(grep '^version = ' $file2 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
file_tag3=$(grep '^version = ' $file3 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
file_tag4=$(grep '^version = ' $file4 | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')
file_tag5=$(grep -A 1 'name = "meilisearch-auth"' $file5 | grep version | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')

if [ "$current_tag" != "$file_tag1" ] || [ "$current_tag" != "$file_tag2" ] || [ "$current_tag" != "$file_tag3" ] || [ "$current_tag" != "$file_tag4" ] || [ "$current_tag" != "$file_tag5" ]; then
  echo "Error: the current tag does not match the version in package file(s)."
  echo "$file1: found $file_tag1 - expected $current_tag"
  echo "$file2: found $file_tag2 - expected $current_tag"
  echo "$file3: found $file_tag3 - expected $current_tag"
  echo "$file4: found $file_tag4 - expected $current_tag"
  echo "$file5: found $file_tag5 - expected $current_tag"
  exit 1
fi

echo 'OK'
exit 0


Review comment (security):
Actually, I was wondering, why are we bumping the version of meilisearch-[`auth`, `http`, `lib`, `types`] when the only interesting thing is the meilisearch-lib?

Maybe we should take a decision and decide if we;
1. Bump the version number of ALL the crate in the repo,  including `permissive-json-pointer`.
That would allow us to do a;
```suggestion
# Checking if current tag matches the package version
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
files='*/Cargo.toml'
lock_file='Cargo.lock'
```
2. Only bump `meilisearch-http` since it's the one that's going to set the version number of the binary.

---------

I don't know what's the best but here is a few examples of projects that do one or the other;
1. [helix-editor](https://github.com/helix-editor/helix/)
2. [ripgrep](https://github.com/BurntSushi/ripgrep/tree/master/crates), [tauri](https://github.com/tauri-apps/tauri/tree/dev/core), [serde](https://github.com/serde-rs/serde), [actix-web](https://github.com/actix/actix-web), [rust](https://github.com/rust-lang/rust/tree/master/library) (-> they make everything be in 0.0.0), [deno](https://github.com/denoland/deno)

Code after:
#!/bin/sh

# check_tag $current_tag $file_tag $file_name
function check_tag {
  if [ "$1" != "$2" ]; then
      echo "Error: the current tag does not match the version in $3: found $1 - expected $2"
      ret=1
  fi
}

ret=0
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')

toml_files='*/Cargo.toml'
for toml_file in $toml_files;
do
    file_tag="$(grep '^version = ' $toml_file | cut -d '=' -f 2 | tr -d '"' | tr -d ' ')"
    check_tag $current_tag $file_tag $toml_file
done

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

if [ "$ret" -eq 0 ] ; then
  echo 'OK'
fi
exit $ret