diff --git a/ci3/release_prep_package_json b/ci3/release_prep_package_json index b03d5fc83cb1..70a727502687 100755 --- a/ci3/release_prep_package_json +++ b/ci3/release_prep_package_json @@ -22,3 +22,13 @@ for deps in dependencies devDependencies peerDependencies; do mv tmp.json package.json done done + +# Stamp aztec_version into any published noir contract artifacts in artifacts/*.json. The build-time stamp in +# noir-projects/noir-contracts/bootstrap.sh writes "dev"; $version here is the authoritative release version about to +# be written to package.json. We cannot stamp real version in bootstrap because there we don't have access to it. +if [ -d artifacts ]; then + for f in artifacts/*.json; do + [ -e "$f" ] || continue + jq --arg v "$version" '.aztec_version = $v' "$f" >$tmp && mv $tmp "$f" + done +fi diff --git a/noir-projects/noir-contracts/bootstrap.sh b/noir-projects/noir-contracts/bootstrap.sh index 5cf30927ae65..d5f5ca2cf90d 100755 --- a/noir-projects/noir-contracts/bootstrap.sh +++ b/noir-projects/noir-contracts/bootstrap.sh @@ -93,20 +93,17 @@ function get_contract_path { } export -f get_contract_path -# Stamps the aztec version into a contract artifact JSON in place. Mirrors stampAztecVersion in -# yarn-project/aztec/src/cli/cmds/compile.ts so monorepo-built artifacts match those produced by `aztec compile`. -# On release builds (REF_NAME is valid semver) the tag without the leading "v" is used; otherwise "dev". -function stamp_aztec_version { +# Stamps "dev" (DEV_VERSION) as the artifact's aztec_version - that is the expected version of a locally checked out +# monorepo. The real release version is applied at publish time by whichever path owns it: +# ci3/release_prep_package_json for npm packages, release-image/Dockerfile for the docker image. +function stamp_dev_aztec_version { local json_path=$1 - # "dev" here corresponds to DEV_VERSION in yarn-project/stdlib/src/update-checker/dev_version.ts. - local version="dev" - semver check "$REF_NAME" 2>/dev/null && version="${REF_NAME#v}" local tmp=$(mktemp) - jq --arg v "$version" '.aztec_version = $v' "$json_path" > "$tmp" + jq '.aztec_version = "dev"' "$json_path" > "$tmp" cat "$tmp" > "$json_path" rm "$tmp" } -export -f stamp_aztec_version +export -f stamp_dev_aztec_version # This compiles a noir contract, transpiles public functions, strips internal prefixes, # and generates verification keys for private functions via 'bb aztec_process'. @@ -128,9 +125,9 @@ function compile { $BB aztec_process -i $json_path cache_upload contract-$contract_hash.tar.gz $json_path fi - # Stamp the current version after the cache block so the field always matches the build's version, whether - # the artifact came from a fresh compile or a cache hit. - stamp_aztec_version "$json_path" + # Stamp the version after the cache block so the field is always present, whether the artifact came from a fresh + # compile or a cache hit. + stamp_dev_aztec_version "$json_path" } export -f compile diff --git a/release-image/Dockerfile b/release-image/Dockerfile index 4a4c329b3ff7..49378744b0b0 100644 --- a/release-image/Dockerfile +++ b/release-image/Dockerfile @@ -19,4 +19,16 @@ WORKDIR "/usr/src/yarn-project" ARG VERSION RUN echo '{".": "'$VERSION'"}' > /usr/src/.release-please-manifest.json +# Stamp aztec_version into the shipped contract artifacts. The build-time stamp in +# noir-projects/noir-contracts/bootstrap.sh writes "dev" unconditionally; $VERSION here is the authoritative release +# version for this image. +RUN for dir in \ + /usr/src/yarn-project/accounts/artifacts \ + /usr/src/yarn-project/noir-contracts.js/artifacts \ + /usr/src/yarn-project/noir-test-contracts.js/artifacts; do \ + for f in "$dir"/*.json; do \ + jq --arg v "$VERSION" '.aztec_version = $v' "$f" > /tmp/a.json && mv /tmp/a.json "$f"; \ + done; \ + done + ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec/dest/bin/index.js"]