-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1329 from plebhash/add-release-libs-sh
add `scripts/release-libs.sh`
- Loading branch information
Showing
2 changed files
with
83 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
# USAGE: | ||
# ./scripts/cargo-publish.sh <crate-dir> | ||
|
||
# the script returns 0 on success of cargo publish, and 1 on failure | ||
# the only exception is when cargo publish fails because the crate is already published | ||
# in that case, the script also returns 0 | ||
|
||
CRATE_DIR="$1" | ||
|
||
echo "Publishing crate in directory: $CRATE_DIR" | ||
|
||
cd "$CRATE_DIR" | ||
|
||
CARGO_COMMAND="cargo publish" | ||
|
||
OUTPUT="$($CARGO_COMMAND 2>&1)" | ||
EXIT_CODE=$? | ||
echo "Ran cargo command, exit code was $EXIT_CODE" | ||
|
||
if [ "$EXIT_CODE" -eq 0 ] ; then | ||
echo "Publish command succeeded: $CRATE_DIR" | ||
exit 0 | ||
fi | ||
|
||
# If cargo failed, check whether it was 'already uploaded' | ||
if echo "$OUTPUT" | grep -q "already uploaded"; then | ||
echo "Crate is already published: $CRATE_DIR" | ||
exit 0 | ||
fi | ||
|
||
echo "Publish command failed for $CRATE_DIR" | ||
echo "$OUTPUT" | ||
exit 1 |