diff --git a/barretenberg/rust/barretenberg-rs/Cargo.toml b/barretenberg/rust/barretenberg-rs/Cargo.toml index 04f90e4408cb..f637a2a82a56 100644 --- a/barretenberg/rust/barretenberg-rs/Cargo.toml +++ b/barretenberg/rust/barretenberg-rs/Cargo.toml @@ -10,6 +10,9 @@ readme = "README.md" # crates.io allows max 5 keywords keywords = ["zero-knowledge", "snark", "plonk", "noir", "aztec"] categories = ["cryptography", "api-bindings"] +# Include generated files in the published crate even though they're gitignored. +# They're generated by `yarn generate` in ts/ and must exist on disk before `cargo publish`. +include = ["src/**/*.rs", "build.rs", "README.md"] [dependencies] # Serialization diff --git a/barretenberg/rust/bootstrap.sh b/barretenberg/rust/bootstrap.sh index 7c5c885eb2e3..5b9352241071 100755 --- a/barretenberg/rust/bootstrap.sh +++ b/barretenberg/rust/bootstrap.sh @@ -46,6 +46,30 @@ function test { BB_LIB_DIR="$(cd ../cpp/build/lib && pwd)" RUSTFLAGS="-C link-arg=-Wl,--allow-multiple-definition" denoise "cargo test --release --features ffi" } +function release { + echo_header "barretenberg-rs release" + + local version=${REF_NAME#v} + + # Set the workspace version to match the release tag + sed -i "s/^version = \".*\"/version = \"$version\"/" Cargo.toml + + # Generated files must exist (created during build step) + if [ ! -f barretenberg-rs/src/api.rs ] || [ ! -f barretenberg-rs/src/generated_types.rs ]; then + echo "ERROR: generated files not found. Run 'cd ../ts && yarn generate' first." + exit 1 + fi + + # Publish to crates.io (--allow-dirty because version was just set and generated files are gitignored) + local extra_flags="" + if ! gh release view "v$version" --repo AztecProtocol/aztec-packages &>/dev/null; then + # No matching GitHub release yet — skip verification build (which would try to download libbb-external.a) + echo "No GitHub release found for v$version, adding --no-verify (pass REF_NAME matching a release for full verification)" + extra_flags="--no-verify" + fi + retry "denoise 'cargo publish --allow-dirty $extra_flags -p barretenberg-rs'" +} + function test_download { echo_header "barretenberg-rs download test" @@ -121,6 +145,5 @@ case "$cmd" in $cmd ;; *) - echo "Unknown command: $cmd" - exit 1 + default_cmd_handler "$@" esac diff --git a/barretenberg/rust/tests/Cargo.toml b/barretenberg/rust/tests/Cargo.toml index 676f665a1b25..c52ddf88621e 100644 --- a/barretenberg/rust/tests/Cargo.toml +++ b/barretenberg/rust/tests/Cargo.toml @@ -3,6 +3,7 @@ name = "barretenberg-tests" version.workspace = true edition.workspace = true rust-version.workspace = true +publish = false [features] ffi = ["barretenberg-rs/ffi"] diff --git a/bootstrap.sh b/bootstrap.sh index 47b92fefb888..5e4aeee0b437 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -496,6 +496,7 @@ function release { projects=( barretenberg/cpp barretenberg/ts + barretenberg/rust noir l1-contracts noir-projects/aztec-nr