Skip to content

Commit 8930802

Browse files
committed
fix: add --registry crates-io to cargo search and publish
The CI runner has a custom cargo config that replaces crates-io. Need to explicitly specify --registry crates-io to use the real crates.io. Also fix grep pattern to use -E for extended regex and ^ anchor.
1 parent 9bf8fb0 commit 8930802

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ jobs:
9090
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
9191
run: |
9292
VERSION="${{ steps.versions.outputs.qrcode_rust_shared }}"
93-
if cargo search qrcode-rust-shared --limit 1 2>/dev/null | grep -q "qrcode-rust-shared = \"$VERSION\""; then
93+
# 使用 crates.io registry 搜索,检查版本是否已存在
94+
if cargo search qrcode-rust-shared --limit 1 --registry crates-io 2>/dev/null | grep -qE "^qrcode-rust-shared = \"$VERSION\""; then
9495
echo "✅ qrcode-rust-shared v$VERSION already exists, skipping"
9596
else
9697
echo "📦 Publishing qrcode-rust-shared v$VERSION..."
97-
cargo publish -p qrcode-rust-shared --token "$CARGO_REGISTRY_TOKEN"
98+
cargo publish -p qrcode-rust-shared --token "$CARGO_REGISTRY_TOKEN" --registry crates-io
9899
echo "✅ qrcode-rust-shared published"
99100
fi
100101
@@ -107,12 +108,12 @@ jobs:
107108
continue-on-error: true
108109
run: |
109110
VERSION="${{ steps.versions.outputs.qrcode_rust }}"
110-
if cargo search qrcode-rust --limit 1 2>/dev/null | grep -q "qrcode-rust = \"$VERSION\""; then
111+
if cargo search qrcode-rust --limit 1 --registry crates-io 2>/dev/null | grep -qE "^qrcode-rust = \"$VERSION\""; then
111112
echo "✅ qrcode-rust v$VERSION already exists, skipping"
112113
else
113114
echo "📦 Publishing qrcode-rust v$VERSION..."
114115
for i in 1 2 3; do
115-
if cargo publish -p qrcode-rust --token "$CARGO_REGISTRY_TOKEN" 2>&1; then
116+
if cargo publish -p qrcode-rust --token "$CARGO_REGISTRY_TOKEN" --registry crates-io 2>&1; then
116117
echo "✅ qrcode-rust published"
117118
exit 0
118119
fi
@@ -129,12 +130,12 @@ jobs:
129130
continue-on-error: true
130131
run: |
131132
VERSION="${{ steps.versions.outputs.qrcode_fast }}"
132-
if cargo search qrcode-fast --limit 1 2>/dev/null | grep -q "qrcode-fast = \"$VERSION\""; then
133+
if cargo search qrcode-fast --limit 1 --registry crates-io 2>/dev/null | grep -qE "^qrcode-fast = \"$VERSION\""; then
133134
echo "✅ qrcode-fast v$VERSION already exists, skipping"
134135
else
135136
echo "📦 Publishing qrcode-fast v$VERSION..."
136137
for i in 1 2 3; do
137-
if cargo publish -p qrcode-fast --token "$CARGO_REGISTRY_TOKEN" 2>&1; then
138+
if cargo publish -p qrcode-fast --token "$CARGO_REGISTRY_TOKEN" --registry crates-io 2>&1; then
138139
echo "✅ qrcode-fast published"
139140
exit 0
140141
fi

0 commit comments

Comments
 (0)