Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/ci3_post_checkout.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Run by ci3/bootstrap_ec2 on the build instance right after checkout, before ci3/source derives
# COMMIT_HASH from HEAD. Its stdout is printed at the start of the run; its stderr only on failure.
set -euo pipefail
if [ "${RELEASE_TARGET:-}" = private ]; then
exec scripts/apply_private_release_patch
fi
11 changes: 5 additions & 6 deletions .github/workflows/private-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# This is release.yml with a different target. The two workflows differ in the tag pattern, the
# environment, the RELEASE_TARGET literal, the credentials named, and REF_NAME — everything else
# about a release is the same code (ci.sh release), driven by ci3/source_release_target.
# about a release is the same code (ci.sh release), driven by scripts/source_release_target.
#
# The environments are what keep the two apart: release-private holds the Artifact Registry
# credential and nothing that can publish publicly, `release` holds the npmjs and DockerHub
Expand All @@ -30,12 +30,11 @@ jobs:
release:
runs-on: ubuntu-latest
environment: release-private
# Nothing a private build produces may reach the build cache: it is served over plain HTTP with
# no credentials. The build itself gets this from ci3/source_release_target; this covers the
# runner's own cache write in ci3_success.sh.
# Nothing a private build produces may reach the shared build cache, which anyone can read: it
# uses the private cache. The build selects the bucket itself (scripts/source_release_target);
# this covers the runner. Its logs go with every other log, which only the dashboard serves.
env:
NO_CACHE_UPLOAD: 1
NO_CACHE: 1
CI3_CACHE_BUCKET: aztec-ci-private-cache
permissions:
id-token: write # required for OIDC assume-role with AWS
contents: read # checkout/fetch with the default github.token
Expand Down
5 changes: 3 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function release {
echo_header "release all"
# RELEASE_PROJECTS is what the target publishes; a private release names neither aztec-up nor
# playground, whose artifacts are public by nature.
source $ci3/source_release_target
source $root/scripts/source_release_target
set -x

local projects=($RELEASE_PROJECTS)
Expand Down Expand Up @@ -956,7 +956,8 @@ case "$cmd" in
if ! semver check $REF_NAME; then
exit 1
fi
source $ci3/source_release_target # Source vars for public or private releases.
source $root/scripts/source_release_target # Source vars for public or private releases.
source $ci3/source_cache_bucket $RELEASE_CACHE_BUCKET
./bootstrap.sh build release
./bootstrap.sh release
;;
Expand Down
12 changes: 12 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ function get_latest_run_id {
# Jobs in the ci dashboards are grouped on a single line by RUN_ID.
export RUN_ID=${RUN_ID:-$(date +%s%3N)}

# What ci3/bootstrap_ec2 passes into the build container beyond ci3's own settings: these
# variables as they are, and these files (paths on this machine, passed as paths to a copy).
export CI3_PASS_ENV="${CI3_PASS_ENV:-} RELEASE_TARGET GCP_PROJECT_ID NAMESPACE NETWORK R2_ACCESS_KEY_ID R2_SECRET_ACCESS_KEY
CHONK_INPUTS_STATE_DIR NETLIFY_SITE_ID NETLIFY_AUTH_TOKEN AZTEC_TOOLCHAIN_DEFAULT_MAJOR_VERSION"
export CI3_PASS_FILES="${CI3_PASS_FILES:-} GOOGLE_APPLICATION_CREDENTIALS NETWORK_ENV_FILE AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY_FILE"
# The release workflow supplies the aztec-nr mirror's deploy key as the secret's contents.
if [ -n "${AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY:-}" ] && [ -z "${AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY_FILE:-}" ]; then
export AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY_FILE=$(mktemp)
chmod 600 "$AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY_FILE"
printf '%s\n' "$AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY" > "$AZTEC_NR_GITHUB_MIRROR_DEPLOY_KEY_FILE"
fi

case "$cmd" in
dash)
watch_ci -s main,prs --user --watch
Expand Down
6 changes: 6 additions & 0 deletions labs-aztec-toolchain/download_chonk_inputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ if ! curl -sSf "$url" -o "$tmp/inputs.tar.gz"; then
echo "The pin in $hash_file may be stale." >&2
exit 1
fi
# The pin is the tarball's sha256 prefix, so it says what to expect, not only where to look.
actual=$(sha256sum "$tmp/inputs.tar.gz" | cut -c1-16)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Fresh downloads fail on macOS

download_chonk_inputs.sh now requires sha256sum. If a macOS developer uses the standard Homebrew setup, coreutils exposes gsha256sum, not sha256sum. This script runs directly without adding Homebrew's unprefixed commands to PATH, so fresh downloads stop with “command not found,” blocking benchmarks that need them. Use shasum -a 256 on macOS or select an available checksum command.

Fix in Claude Code Fix in Conductor

if [ "$actual" != "$hash" ]; then
echo "ERROR: pinned chonk inputs from $url have sha256 prefix $actual, not the pinned $hash" >&2
exit 1
fi
rm -rf "$dest"
mkdir -p "$dest"
tar -xzf "$tmp/inputs.tar.gz" -C "$dest"
Expand Down
8 changes: 4 additions & 4 deletions release-image/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function test_cmds {
function release {
echo_header "release-image release"

source $ci3/source_release_target
source $root/scripts/source_release_target
docker_login
local repo=${DOCKER_REGISTRY%/}

Expand All @@ -164,7 +164,7 @@ function release {
function release_docker_manifest {
echo_header "release-image manifest"

source $ci3/source_release_target
source $root/scripts/source_release_target
docker_login
local repo=${DOCKER_REGISTRY%/}

Expand Down Expand Up @@ -197,7 +197,7 @@ function release_docker_manifest {
function push_pr {
echo_header "release-image push_pr"

source $ci3/source_release_target
source $root/scripts/source_release_target
docker_login
local image=$(pr_image_name)
docker tag azteclabs/aztec:$COMMIT_HASH $image
Expand All @@ -207,7 +207,7 @@ function push_pr {
# The name push_pr publishes, for the deploys that consume it: one definition, so the image a
# deploy asks for is the image that was pushed.
function pr_image_name {
source $ci3/source_release_target
source $root/scripts/source_release_target
echo "${DOCKER_REGISTRY%/}/aztec-dev:$COMMIT_HASH"
}

Expand Down
48 changes: 48 additions & 0 deletions scripts/apply_private_release_patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Downloads this private release's patch, applies it to HEAD and commits it, so the build sees a
# clean tree. Prints the patch's location and sha256, never the patch or the paths it touches.
#
# Run by .github/ci3_post_checkout.sh right after checkout, before ci3/source computes COMMIT_HASH. A
# missing patch leaves the tree as tagged; any other failure, an empty patch included, fails the
# release.
set -euo pipefail

bucket=aztec-node-ci-private
key="${REF_NAME:?REF_NAME is required}.patch"
echo "Private release patch: s3://$bucket/$key"

patch=$(mktemp)
trap 'rm -f "$patch"' EXIT

# Read access comes from the private release's instance profile (CI3_INSTANCE_PROFILE_NAME on the
# release-private environment). The owner check keeps a bucket of the same name in another account
# from serving a patch.
owner=$(aws sts get-caller-identity --region eu-west-2 --query Account --output text)
if ! err=$(aws s3api get-object --region eu-west-2 --bucket "$bucket" --key "$key" \
--expected-bucket-owner "$owner" "$patch" 2>&1 >/dev/null); then
# Only a missing key means there is no patch: a missing bucket or lost access must fail.
if [[ "$err" == *"(NoSuchKey)"* ]]; then
echo "No private release patch at s3://$bucket/$key; building the tagged tree."
exit 0
fi
echo "$err" >&2
echo "Failed to download the private release patch s3://$bucket/$key." >&2
exit 1
fi

sha=$(sha256sum "$patch" | cut -d' ' -f1)
echo "Private release patch sha256: $sha"

if [ ! -s "$patch" ]; then
echo "The private release patch s3://$bucket/$key is empty." >&2
exit 1
fi

# git apply's warnings and errors quote paths and lines from the patch, so its output is dropped.
if ! git apply --index "$patch" &>/dev/null; then
echo "The private release patch (sha256 $sha) does not apply cleanly to $(git rev-parse HEAD)." >&2
exit 1
fi
# -q: without it commit prints "create mode <path>" for each new file.
git -c user.name="Aztec Private Release" -c user.email=tech@aztecprotocol.com \
commit -q --no-verify -m "Private release patch sha256:$sha"
109 changes: 109 additions & 0 deletions scripts/source_release_target
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# The release target: where a release reads its packages from, and where it publishes.
#
# Sourced by `bootstrap.sh ci-release` before the build and again by `bootstrap.sh release`, so a
# misconfigured environment fails in seconds instead of after a full build, and by release-image
# for its registry. RELEASE_TARGET is a
# literal in the release workflow, never a GitHub variable, so no variable edit can flip a flow;
# everything else is either supplied by the workflow's environment or derived here.
#
# public npmjs + DockerHub, plus the aztec-up and playground assets. release.yml states both
# URLs as literals rather than GitHub variables, so no variable edit can retarget a
# public release.
# private one GCP Artifact Registry for both the @aztec-foundation reads and the @aztec-labs
# writes, and nothing public. Its credentials and npm URL come from the release-private
# environment, its docker URL from the repo-level INTERNAL_DOCKER_REGISTRY the deploy
# workflows also read.
#
# The two targets share no credential: an environment that can read private packages holds nothing
# that can publish publicly, and vice versa. The assertions here are the backstop for the cases
# GitHub cannot see — a hand-run release, a mis-wired workflow, a half-configured environment.

export RELEASE_TARGET=${RELEASE_TARGET:-public}

# Both URLs are required, whatever the target: an unset value is a configuration error, never a
# silent fall back to a default destination. Exported so ci3/bootstrap_ec2 forwards them to the
# build container however the caller happened to set them.
: "${NPM_REGISTRY:?NPM_REGISTRY is required}"
: "${DOCKER_REGISTRY:?DOCKER_REGISTRY is required}"
export NPM_REGISTRY DOCKER_REGISTRY

case "$RELEASE_TARGET" in
public)
# The aztec-nr mirror goes first: a failure there aborts the whole release, since a CLI whose
# scaffold pins an aztec-nr tag that does not exist is worse than no release at all.
export RELEASE_PROJECTS="noir-projects/aztec-nr yarn-project aztec-up playground release-image"

# Sanity check the registry. NPM_REGISTRY is both where the build reads our scopes from and
# where it publishes them, so a public release pointed elsewhere would bake private packages
# into the images it pushes to DockerHub and the assets it uploads to the public buckets.
if ! is_npmjs "$NPM_REGISTRY"; then
echo_stderr "A public release must read and publish npm from npmjs, not $NPM_REGISTRY."
exit 1
fi

# Never the shared build cache, which any CI build can write. Only ci-release switches to it:
# the network jobs source this file for the registry, on instances that cannot read it.
export RELEASE_CACHE_BUCKET=aztec-ci-release-cache
;;
private)
# What gets published is code, not configuration: the projects that publish public artifacts
# (aztec-up, playground) are not in the list, so their release functions are never invoked.
export RELEASE_PROJECTS="yarn-project release-image"

# Sanity check the registries. Deliberately broader than is_npmjs: this one refuses a
# destination, so anything that so much as looks like npmjs should fail here.
if [[ "$NPM_REGISTRY" == *npmjs.org* ]] || [[ "$DOCKER_REGISTRY" == docker.io/* ]]; then
echo_stderr "A private release must not publish to npmjs or DockerHub ($NPM_REGISTRY, $DOCKER_REGISTRY)."
exit 1
fi

# The credential is required, not just the URL. ci3/source_npm_auth writes its whole
# configuration only when a credential is set, so a private release without one routes no
# scope at all: the build resolves @aztec-foundation from npmjs, succeeds, and fails at the
# publish. Every reader of the private arm publishes, so there is no case to be lenient for.
: "${NPM_USERNAME:?NPM_USERNAME is required for a private release (INTERNAL_NPM_USERNAME, on release-private)}"
: "${NPM_PASSWORD:?NPM_PASSWORD is required for a private release (INTERNAL_NPM_PASSWORD, on release-private)}"
: "${DOCKER_USERNAME:?DOCKER_USERNAME is required for a private release (INTERNAL_DOCKER_USERNAME, on release-private)}"
: "${DOCKER_PASSWORD:?DOCKER_PASSWORD is required for a private release (INTERNAL_DOCKER_PASSWORD, on release-private)}"

# These should not be reachable.
for var in NPM_TOKEN DOCKERHUB_USERNAME DOCKERHUB_PASSWORD; do
if [ -n "${!var:-}" ]; then
echo_stderr "$var must not be set for a $RELEASE_TARGET release; it belongs to the other target."
exit 1
fi
done

# A private release always comes from a private/v* tag, so the channel check below is not
# optional here: an absent version has nothing to publish under, and skipping the check is
# how a private build would end up on a public channel.
if ! semver check "${REF_NAME:-}" >/dev/null 2>&1; then
echo_stderr "A private release needs REF_NAME to be a version; got '${REF_NAME:-}'."
exit 1
fi

# The private tag carries its own channel, so the version says which flow produced it.
if semver check "${REF_NAME:-}" >/dev/null 2>&1; then
release_channel=$(dist_tag)
if [ "$release_channel" != private ]; then
echo_stderr "A private release needs a <version>-private.<n> tag; $REF_NAME is '$release_channel'."
exit 1
fi
unset release_channel
fi

# The private cache, which nothing public can read or write. It has to be a cache of its own,
# not only for privacy: no cache key mentions the registry. node_modules is keyed on yarn.lock
# plus package.json and the release-image base layer on the Dockerfiles plus yarn.lock, all
# identical between a public and a private build of the same tree, so a private run reading the
# public cache would restore a public run's entries and skip both installs, publishing
# artifacts built against npmjs while reporting success. Its other writer, the
# aztec-packages-private CI, builds this tree only with its manifests rewritten, so under other
# keys.
export RELEASE_CACHE_BUCKET=aztec-ci-private-cache
;;
*)
echo_stderr "Unknown RELEASE_TARGET '$RELEASE_TARGET' (expected public or private)."
exit 1
;;
esac
Loading