Skip to content

Commit fef38cc

Browse files
committed
Fix crates.io version detection
* cargo search did not detect pre-releases
1 parent 9eb793b commit fef38cc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/publish_cratesio_new_versions.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ for workspace_member in $(cargo get --delimiter " " workspace.members); do
1111
fi
1212

1313
package_version=$(cargo get --entry "$workspace_member" package.version)
14-
cratesio_version=$(cargo search "$package_name" | sed -n 's/'$package_name' = "\([^"]*\)".*/\1/p')
1514

16-
# if local version is different from crates.io version, then publish to crates.io
17-
if [ "$package_version" != "$cratesio_version" ]; then
18-
echo "Local version of $package_name is $package_version, while the one on crates.io is $cratesio_version"
15+
# if local version not present on crates.io, publish it
16+
crates_io_url="https://crates.io/api/v1/crates/$package_name"
17+
if ! curl -sSLf "$crates_io_url" | jq -r '.versions[].num' | grep -q "^$package_version$"; then
18+
echo "The local version of $package_name is $package_version, which is not present on crates.io"
1919

2020
cargo login "$CRATES_IO_API_KEY"
2121
cargo publish -p "$package_name"

0 commit comments

Comments
 (0)