| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
function publish { |
| 6 |
publish_this="$1" |
| 7 |
crate_name="$2" |
| 8 |
manifest="$3" |
| 9 |
|
| 10 |
if [ "$publish_this" != "true" ] |
| 11 |
then |
| 12 |
echo "Skipping $crate_name, publish not requested." |
| 13 |
return |
| 14 |
fi |
| 15 |
|
| 16 |
# Get the version from Cargo.toml |
| 17 |
version=`sed -n -E 's/^version = "(.*)"/\1/p' $manifest` |
| 18 |
|
| 19 |
# Check crates.io if it is already published |
| 20 |
set +e |
| 21 |
output=`curl --fail --silent --head --location https://static.crates.io/crates/$crate_name/$version/download` |
| 22 |
res="$?" |
| 23 |
set -e |
| 24 |
case $res in |
| 25 |
0) |
| 26 |
echo "${crate_name}@${version} appears to already be published" |
| 27 |
return |
| 28 |
;; |
| 29 |
22) ;; |
| 30 |
*) |
| 31 |
echo "Failed to check ${crate_name}@${version} res: $res" |
| 32 |
echo "$output" |
| 33 |
exit 1 |
| 34 |
;; |
| 35 |
esac |
| 36 |
|
| 37 |
cargo publish --manifest-path $manifest --no-verify |
| 38 |
|
| 39 |
tag="${crate_name}-${version}" |
| 40 |
git tag $tag |
| 41 |
git push origin "$tag" |
| 42 |
} |
| 43 |
|
| 44 |
publish $PUBLISH_LIBGIT2_SYS libgit2-sys libgit2-sys/Cargo.toml |
| 45 |
publish $PUBLISH_GIT2 git2 Cargo.toml |
| 46 |
publish $PUBLISH_GIT2_CURL git2-curl git2-curl/Cargo.toml |