ci: fix publish crate version checking (#31894)

* ci: fix publish crate version checking

* ci: add warning when publish crates don't use worksapce version
This commit is contained in:
Yihau Chen 2023-06-01 14:28:10 +08:00 committed by GitHub
parent 1d6b03358f
commit 405db3e436
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 4 deletions

View File

@ -26,14 +26,28 @@ expectedCrateVersion="$MAJOR.$MINOR.$PATCH$SPECIAL"
exit 1
}
# check workspace.version for worksapce root
workspace_cargo_tomls=(Cargo.toml programs/sbf/Cargo.toml)
for cargo_toml in "${workspace_cargo_tomls[@]}"; do
if ! grep -q "^version = \"$expectedCrateVersion\"$" "$cargo_toml"; then
echo "Error: Cargo.toml version is not $expectedCrateVersion"
exit 1
fi
done
Cargo_tomls=$(ci/order-crates-for-publishing.py)
for Cargo_toml in $Cargo_tomls; do
echo "--- $Cargo_toml"
grep -q "^version = \"$expectedCrateVersion\"$" "$Cargo_toml" || {
echo "Error: $Cargo_toml version is not $expectedCrateVersion"
exit 1
}
# check the version which doesn't inherit from worksapce
if ! grep -q "^version = { workspace = true }$" "$Cargo_toml"; then
echo "Warn: $Cargo_toml doesn't use the inherited version"
grep -q "^version = \"$expectedCrateVersion\"$" "$Cargo_toml" || {
echo "Error: $Cargo_toml version is not $expectedCrateVersion"
exit 1
}
fi
crate_name=$(grep -m 1 '^name = ' "$Cargo_toml" | cut -f 3 -d ' ' | tr -d \")