Skip to content

Commit 36b6d32

Browse files
benesjanclaude
andcommitted
fix(release-image): stamp aztec_version in published contract artifacts
The v4.3.0 release shipped contract artifact JSONs with aztec_version: "dev" baked in, because release-image/Dockerfile copies pre-built artifacts from an earlier stage where REF_NAME isn't set (so stamp_aztec_version in noir-projects/noir-contracts/bootstrap.sh falls back to "dev"). Mirror the stdlib/package.json stamp pattern (75fd494) to re-stamp aztec_version in every artifact under accounts/, noir-contracts.js/, and noir-test-contracts.js/ at image-build time. Forward port of #23470 from backport-to-v4-next-staging. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ede2dec commit 36b6d32

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

ci3/release_prep_package_json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ for deps in dependencies devDependencies peerDependencies; do
2222
mv tmp.json package.json
2323
done
2424
done
25+
26+
# Stamp aztec_version into any published noir contract artifacts in artifacts/*.json. The build-time stamp in
27+
# noir-projects/noir-contracts/bootstrap.sh writes "dev"; $version here is the authoritative release version about to
28+
# be written to package.json. We cannot stamp real version in bootstrap because there we don't have access to it.
29+
if [ -d artifacts ]; then
30+
for f in artifacts/*.json; do
31+
[ -e "$f" ] || continue
32+
jq --arg v "$version" '.aztec_version = $v' "$f" >$tmp && mv $tmp "$f"
33+
done
34+
fi

noir-projects/noir-contracts/bootstrap.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,17 @@ function get_contract_path {
9393
}
9494
export -f get_contract_path
9595

96-
# Stamps the aztec version into a contract artifact JSON in place. Mirrors stampAztecVersion in
97-
# yarn-project/aztec/src/cli/cmds/compile.ts so monorepo-built artifacts match those produced by `aztec compile`.
98-
# On release builds (REF_NAME is valid semver) the tag without the leading "v" is used; otherwise "dev".
99-
function stamp_aztec_version {
96+
# Stamps "dev" (DEV_VERSION) as the artifact's aztec_version - that is the expected version of a locally checked out
97+
# monorepo. The real release version is applied at publish time by whichever path owns it:
98+
# ci3/release_prep_package_json for npm packages, release-image/Dockerfile for the docker image.
99+
function stamp_dev_aztec_version {
100100
local json_path=$1
101-
# "dev" here corresponds to DEV_VERSION in yarn-project/stdlib/src/update-checker/dev_version.ts.
102-
local version="dev"
103-
semver check "$REF_NAME" 2>/dev/null && version="${REF_NAME#v}"
104101
local tmp=$(mktemp)
105-
jq --arg v "$version" '.aztec_version = $v' "$json_path" > "$tmp"
102+
jq '.aztec_version = "dev"' "$json_path" > "$tmp"
106103
cat "$tmp" > "$json_path"
107104
rm "$tmp"
108105
}
109-
export -f stamp_aztec_version
106+
export -f stamp_dev_aztec_version
110107

111108
# This compiles a noir contract, transpiles public functions, strips internal prefixes,
112109
# and generates verification keys for private functions via 'bb aztec_process'.
@@ -128,9 +125,9 @@ function compile {
128125
$BB aztec_process -i $json_path
129126
cache_upload contract-$contract_hash.tar.gz $json_path
130127
fi
131-
# Stamp the current version after the cache block so the field always matches the build's version, whether
132-
# the artifact came from a fresh compile or a cache hit.
133-
stamp_aztec_version "$json_path"
128+
# Stamp the version after the cache block so the field is always present, whether the artifact came from a fresh
129+
# compile or a cache hit.
130+
stamp_dev_aztec_version "$json_path"
134131
}
135132
export -f compile
136133

release-image/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,16 @@ WORKDIR "/usr/src/yarn-project"
1919
ARG VERSION
2020
RUN echo '{".": "'$VERSION'"}' > /usr/src/.release-please-manifest.json
2121

22+
# Stamp aztec_version into the shipped contract artifacts. The build-time stamp in
23+
# noir-projects/noir-contracts/bootstrap.sh writes "dev" unconditionally; $VERSION here is the authoritative release
24+
# version for this image.
25+
RUN for dir in \
26+
/usr/src/yarn-project/accounts/artifacts \
27+
/usr/src/yarn-project/noir-contracts.js/artifacts \
28+
/usr/src/yarn-project/noir-test-contracts.js/artifacts; do \
29+
for f in "$dir"/*.json; do \
30+
jq --arg v "$VERSION" '.aztec_version = $v' "$f" > /tmp/a.json && mv /tmp/a.json "$f"; \
31+
done; \
32+
done
33+
2234
ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec/dest/bin/index.js"]

0 commit comments

Comments
 (0)