feat: Improve publish-all.sh script to handle zinit_client

- Correctly handle the `zinit_client` crate name in package
  publication checks and messages.  The script previously
  failed to account for the difference between the directory
  name and the package name.
- Improve the clarity of published crate names in output messages
  for better user understanding.  This makes the output more
  consistent and user friendly.
This commit is contained in:
Mahmoud-Emad 2025-07-02 12:46:42 +03:00
parent 95122dffee
commit b72c50bed9

View File

@ -147,8 +147,14 @@ is_published() {
local crate_name="$1" local crate_name="$1"
local version="$2" local version="$2"
# Handle special case for zinit_client (directory) -> sal-zinit-client (package)
local package_name="sal-$crate_name"
if [ "$crate_name" = "zinit_client" ]; then
package_name="sal-zinit-client"
fi
# Use cargo search to check if the exact version exists # Use cargo search to check if the exact version exists
if cargo search "sal-$crate_name" --limit 1 | grep -q "sal-$crate_name.*$version"; then if cargo search "$package_name" --limit 1 | grep -q "$package_name.*$version"; then
return 0 # Already published return 0 # Already published
else else
return 1 # Not published return 1 # Not published
@ -209,7 +215,12 @@ for crate in "${CRATES[@]}"; do
# Check if already published # Check if already published
if [ "$DRY_RUN" = false ] && is_published "$crate" "$VERSION"; then if [ "$DRY_RUN" = false ] && is_published "$crate" "$VERSION"; then
echo -e "${GREEN} ✅ sal-$crate@$VERSION already published, skipping${NC}" # Handle special case for zinit_client display name
display_name="sal-$crate"
if [ "$crate" = "zinit_client" ]; then
display_name="sal-zinit-client"
fi
echo -e "${GREEN}$display_name@$VERSION already published, skipping${NC}"
echo "" echo ""
continue continue
fi fi
@ -223,13 +234,24 @@ for crate in "${CRATES[@]}"; do
if [ "$DRY_RUN" = true ]; then if [ "$DRY_RUN" = true ]; then
echo -e "${BLUE} 🔍 Would run: cargo publish --allow-dirty${NC}" echo -e "${BLUE} 🔍 Would run: cargo publish --allow-dirty${NC}"
if is_published "$crate" "$VERSION"; then if is_published "$crate" "$VERSION"; then
echo -e "${YELLOW} 📝 Note: sal-$crate@$VERSION already exists${NC}" # Handle special case for zinit_client display name
display_name="sal-$crate"
if [ "$crate" = "zinit_client" ]; then
display_name="sal-zinit-client"
fi
echo -e "${YELLOW} 📝 Note: $display_name@$VERSION already exists${NC}"
fi fi
else else
# Handle special case for zinit_client display name
display_name="sal-$crate"
if [ "$crate" = "zinit_client" ]; then
display_name="sal-zinit-client"
fi
if cargo publish --allow-dirty; then if cargo publish --allow-dirty; then
echo -e "${GREEN} ✅ sal-$crate published successfully${NC}" echo -e "${GREEN}$display_name published successfully${NC}"
else else
echo -e "${RED} ❌ Failed to publish sal-$crate${NC}" echo -e "${RED} ❌ Failed to publish $display_name${NC}"
cd .. cd ..
restore_dependencies "$crate" restore_dependencies "$crate"
exit 1 exit 1