Skip to content

Commit

Permalink
chore: Fix sync_publish.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Sep 19, 2023
1 parent f338ef9 commit 9c9016d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -ex

VERSION=$(echo $1 | sed 's/v//')
shift
Expand Down
9 changes: 5 additions & 4 deletions scripts/sync_publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ TMP_DIR=/tmp/test1

DIR="$1"
FORCE="$2"
shift
shift

NAME=$(grep '^name' "$DIR/Cargo.toml" | head -n 1 | sed 's/name = "\([^"]*\)"/\1/')
cd "$DIR"
Expand All @@ -22,8 +24,7 @@ VERSION=$(cargo metadata --format-version 1 2>/dev/null | jq -r '.packages[] | s
rm -rf "$TMP_DIR"
cargo new "$TMP_DIR" > /dev/null 2>&1
cd "$TMP_DIR"
cargo add "$NAME" --vers "=$VERSION" > /dev/null 2>&1
if cargo generate-lockfile > /dev/null 2>&1; then
if cargo add "$NAME@$VERSION" > /dev/null 2>&1; then
echo "$NAME=$VERSION already exists, skipping."
exit 0
fi
Expand All @@ -35,10 +36,10 @@ if [ "$FORCE" != "-f" ]; then
fi

cd "$DIR"
cargo publish
cargo publish $@

cd "$TMP_DIR"
while ! cargo generate-lockfile > /dev/null 2>&1; do
while ! cargo add "$NAME@$VERSION" > /dev/null 2>&1; do
echo "Waiting for crate to be published..."
sleep 1
done

0 comments on commit 9c9016d

Please sign in to comment.