From 265a7c4e7f3e353eda56d75a2eaa4bec945b9c98 Mon Sep 17 00:00:00 2001 From: Scott Andrews Date: Mon, 5 Oct 2026 23:05:00 -0400 Subject: [PATCH] Restore library version for published crates Signed-off-by: Scott Andrews --- .github/workflows/ci.yaml | 4 ++++ Cargo.toml | 4 +++- scripts/bump-version.sh | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 32e030b..ca77acd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,6 +35,10 @@ jobs: echo "::error::the workspace version ${workspace_version} in Cargo.toml does not match the interface version ${interface_version}, see scripts/bump-version.sh" exit 1 fi + - name: Check crates can be published + # the release workflow publishes the crates when a release is published, too late to find a + # crate can't be published. The cli is verified against the library being published with it. + run: cargo publish --dry-run --locked -p componentized-constants -p componentized-constants-cli - name: Build components run: make components - name: Collect components.tar diff --git a/Cargo.toml b/Cargo.toml index 4f4951d..5adf0ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,9 @@ version = "0.1.1-dev" [workspace.dependencies] anyhow = "1" -componentized-constants = { path = "./crates/componentized-constants" } +# published with the cli, the cli requires the library at exactly the same version, kept in step by +# scripts/bump-version.sh +componentized-constants = { path = "./crates/componentized-constants", version = "=0.1.1-dev" } futures = { version = "0.3", default-features = false, features = ["executor"] } test-harness = { path = "./crates/test-harness" } wasmtime = { version = "49", default-features = false, features = ["anyhow", "component-model", "component-model-async", "cranelift", "runtime"] } diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 4fb0229..8739093 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -68,6 +68,14 @@ if ! grep -qF "$workflow_default" "$workflow"; then exit 1 fi +# the cli requires the library at exactly the current version, publishing fails without a version +# requirement, checked before changing anything +library_requirement="${LIBRARY} = { path = \"./crates/${LIBRARY}\", version = \"=${old}\" }" +if ! grep -qxF "$library_requirement" Cargo.toml; then + echo "unable to find the ${LIBRARY} requirement on the current version in Cargo.toml, expected: ${library_requirement}" >&2 + exit 1 +fi + old_re="${old//./\\.}" # references to the package or one of its interfaces, an interface named for a keyword is escaped # with `%`, e.g. `componentized:constants/%u8@0.1.1-dev` @@ -93,7 +101,7 @@ fi # the version in the [workspace.package] section, inherited by the crates perl -pi -e 'if (/^\[workspace\.package\]/ .. /^\[(?!workspace\.package\])/) { s/^version = "[^"]*"/version = "'"${new}"'"/ }' Cargo.toml echo "updated the workspace version in Cargo.toml" -perl -pi -e 's/^(\Q'"${LIBRARY}"'\E = \{.*\bversion = ")[^"]*(")/${1}'"${new}"'${2}/' Cargo.toml +perl -pi -e 's/^(\Q'"${LIBRARY}"'\E = \{.*\bversion = "=)[^"]*(")/${1}'"${new}"'${2}/' Cargo.toml echo "updated the ${LIBRARY} requirement in Cargo.toml" perl -pi -e 's{^(\s+)\Q'"${workflow_default}"'\E$}{${1}'"${workflow_default/\"${old}\"/\"${new}\"}"'}' "$workflow"