Skip to content

Commit 56ca2b0

Browse files
committed
fix(ci): resolve workspace-inherited version in publish-crates
grep '^version' returned the literal 'true' for manifests using version.workspace = true, defeating the already-published pre-check. Use cargo metadata to expand the real workspace version.
1 parent 2357452 commit 56ca2b0

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.github/workflows/publish-crates.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,16 @@ jobs:
3838
echo "Missing manifest for $crate at $manifest" >&2
3939
exit 1
4040
fi
41-
version=$(grep -m1 '^version' "$manifest" | sed 's/.*"\(.*\)".*/\1/')
41+
# Resolve the real version via cargo metadata so that
42+
# `version.workspace = true` is expanded to the workspace value.
43+
# (A naive `grep '^version'` yields the literal "true".)
44+
version=$(cargo metadata --no-deps --format-version=1 \
45+
| jq -r --arg manifest "$manifest" \
46+
'.packages[] | select(.manifest_path | endswith($manifest)) | .version')
47+
if [ -z "$version" ]; then
48+
echo "ERROR: could not resolve version for $crate from $manifest" >&2
49+
exit 1
50+
fi
4251
# Check crates.io with auth to avoid rate limits
4352
if curl -fsS -H "Authorization: ${CARGO_REGISTRY_TOKEN}" "https://crates.io/api/v1/crates/$crate/$version" >/dev/null 2>&1; then
4453
echo "$crate $version already exists on crates.io; skipping"

0 commit comments

Comments
 (0)