Skip to content

Commit 9ca3249

Browse files
committed
fix(ci): improve crates.io publication check robustness
- Redirect stderr to avoid 'note:' messages interfering with grep - Capture search output for debugging when check fails - Add debug output to see what cargo search returns - This should fix the false positives where already-published crates are detected as needing publishing
1 parent 759f84f commit 9ca3249

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/publish-crates.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99
inputs:
1010
dry-run:
11-
description: 'Dry run (do not actually publish)'
11+
description: "Dry run (do not actually publish)"
1212
required: false
1313
default: false
1414
type: boolean
@@ -59,10 +59,15 @@ jobs:
5959
echo "Checking $crate v$CRATE_VERSION..."
6060
6161
# Check if this version is already on crates.io
62-
if cargo search $crate --limit 1 | grep -q "^$crate = \"$CRATE_VERSION\""; then
62+
# Capture both stdout and stderr, ignore stderr output (the "note:" lines)
63+
SEARCH_OUTPUT=$(cargo search "$crate" --limit 1 2>/dev/null || true)
64+
65+
# Check if the exact version is found
66+
if echo "$SEARCH_OUTPUT" | grep -q "^${crate} = \"${CRATE_VERSION}\""; then
6367
echo " ✓ $crate v$CRATE_VERSION is already published"
6468
else
6569
echo " → $crate v$CRATE_VERSION needs publishing"
70+
echo " Search output was: $SEARCH_OUTPUT"
6671
NEEDS_PUBLISH="$NEEDS_PUBLISH $crate"
6772
fi
6873
done
@@ -141,10 +146,12 @@ jobs:
141146
CRATE_VERSION=$(grep "^version" crates/$crate/Cargo.toml | sed 's/.*= *"\(.*\)"/\1/')
142147
echo -n "Checking $crate v$CRATE_VERSION... "
143148
144-
if cargo search $crate --limit 1 | grep -q "^$crate = \"$CRATE_VERSION\""; then
149+
SEARCH_OUTPUT=$(cargo search "$crate" --limit 1 2>/dev/null || true)
150+
if echo "$SEARCH_OUTPUT" | grep -q "^${crate} = \"${CRATE_VERSION}\""; then
145151
echo "✓ Published!"
146152
else
147153
echo "✗ Not found!"
154+
echo "Search output: $SEARCH_OUTPUT"
148155
exit 1
149156
fi
150157
done

0 commit comments

Comments
 (0)