diff --git a/.github/workflows/mirror-repos.yml b/.github/workflows/mirror-repos.yml index 80dd017518dc..a054f3e36ac0 100644 --- a/.github/workflows/mirror-repos.yml +++ b/.github/workflows/mirror-repos.yml @@ -33,51 +33,3 @@ jobs: git push fi - mirror-to-aztec-nr-repo: - runs-on: ubuntu-latest - # Force sequential. - needs: mirror-to-barretenberg-repo - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - with: - fetch-depth: 0 - token: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }} - - name: Push to aztec-nr repo - run: | - SUBREPO_PATH=noir-projects/aztec-nr - git config --global user.name AztecBot - git config --global user.email tech@aztecprotocol.com - - monorepo_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" - # list all aztec-packages tags, take the "highest" version - monorepo_tag="$(git tag --list v* | sort --version-sort | tail -1)" - monorepo_protocol_circuits_path="noir-projects/noir-protocol-circuits" - - # take all Nargo.toml files that reference noir-protocol-circuits - nargo_files="$(find $SUBREPO_PATH -name 'Nargo.toml' | xargs grep --files-with-matches 'noir-protocol-circuits')" - - # match lines like this: - # protocol_types = { path = "../../noir-protocol-circuits/crates/types" } - # and replace with - # protocol_types = { git="https://github.com/aztecprotocol/aztec-packages", tag="v0.16.9", directory="noir-projects/noir-protocol-circuits/crates/types" } - for nargo_file in $nargo_files; do - sed --regexp-extended --in-place \ - "s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$monorepo_tag\", directory=\"$monorepo_protocol_circuits_path\1\";" \ - $nargo_file - done - - git commit --all --message "chore: replace relative paths to noir-protocol-circuits" - - if ./scripts/git_subrepo.sh push $SUBREPO_PATH --branch=master; then - git fetch # in case a commit came after this - git rebase origin/master - - # restore old files - for nargo_file in $nargo_files; do - git restore --source=origin/master -- $nargo_file - done - git commit --all --amend -m "$(git log -1 --pretty=%B)" - - git push - fi diff --git a/bootstrap.sh b/bootstrap.sh index 7b247b00bc80..64c950d1dcfa 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -343,7 +343,7 @@ function release { # aztec-up => upload scripts to prod if dist tag is latest # playground => publish if dist tag is latest. # release-image => push docker image to dist tag. - # boxes/l1-contracts => mirror repo to branch equal to dist tag (master if latest). Also mirror to tag equal to REF_NAME. + # boxes/l1-contracts/aztec-nr => mirror repo to branch equal to dist tag (master if latest). Also mirror to tag equal to REF_NAME. echo_header "release all" set -x @@ -359,6 +359,7 @@ function release { barretenberg/ts noir l1-contracts + noir-projects/aztec-nr yarn-project boxes aztec-up diff --git a/noir-projects/aztec-nr/.gitrepo b/noir-projects/aztec-nr/.gitrepo deleted file mode 100644 index 0a5f92ea63d5..000000000000 --- a/noir-projects/aztec-nr/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme -; -[subrepo] -remote = https://github.com/AztecProtocol/aztec-nr - branch = master - commit = db149038a5c32acf052ac0c4c796f99ebadf95ff - method = merge - cmdver = 0.4.6 - parent = d4b06c052140e3350a160b9e30c1cd892bc29ed5 diff --git a/noir-projects/aztec-nr/bootstrap.sh b/noir-projects/aztec-nr/bootstrap.sh index 7dd74125000d..b3ef9fc60f07 100755 --- a/noir-projects/aztec-nr/bootstrap.sh +++ b/noir-projects/aztec-nr/bootstrap.sh @@ -43,6 +43,79 @@ function format { $NARGO fmt } +function release { + if semver check $REF_NAME; then + echo_stderr "Release tag must be a valid semver version. Found: $REF_NAME" + exit 1 + fi + + release_git_push "master" $REF_NAME +} + +function release_git_push { + local branch_name=$1 + local tag_name=$2 + local mirrored_repo_url="https://github.com/AztecProtocol/aztec-nr.git" + + # Clean up our release directory. + rm -rf release-out && mkdir release-out + + # Copy our git files to our release directory. + git archive HEAD -- . | tar -x -C release-out + + cd release-out + + # Update Nargo.toml files to reference noir-protocol-circuits from the monorepo tag + monorepo_url="https://github.com/AztecProtocol/aztec-packages" + monorepo_protocol_circuits_path="noir-projects/noir-protocol-circuits" + + # Find all Nargo.toml files that reference noir-protocol-circuits + nargo_files="$(find . -name 'Nargo.toml' | xargs grep --files-with-matches 'noir-protocol-circuits' || true)" + + # Replace relative paths with git references + for nargo_file in $nargo_files; do + sed --regexp-extended --in-place \ + "s;path\s*=\s*\".*noir-protocol-circuits(.*)\";git=\"$monorepo_url\", tag=\"$tag_name\", directory=\"$monorepo_protocol_circuits_path\1\";" \ + $nargo_file + done + + # CI needs to authenticate from GITHUB_TOKEN. + gh auth setup-git &>/dev/null || true + + git init &>/dev/null + git remote add origin "$mirrored_repo_url" &>/dev/null + git fetch origin --quiet + + # Checkout the existing branch or create it if it doesn't exist. + if git ls-remote --heads origin "$branch_name" | grep -q "$branch_name"; then + # Update branch reference without checkout. + git branch -f "$branch_name" origin/"$branch_name" + # Point HEAD to the branch. + git symbolic-ref HEAD refs/heads/"$branch_name" + # Move to latest commit, keep working tree. + git reset --soft origin/"$branch_name" + else + git checkout -b "$branch_name" + fi + + if git rev-parse "$tag_name" >/dev/null 2>&1; then + echo "Tag $tag_name already exists. Skipping release." + else + git add . + git commit -m "Release $tag_name." >/dev/null + git tag -a "$tag_name" -m "Release $tag_name." + do_or_dryrun git push origin "$branch_name" --quiet + do_or_dryrun git push origin --quiet --force "$tag_name" --tags + + echo "Release complete ($tag_name) on branch $branch_name." + fi + + do_or_dryrun git push origin "$branch_name" --quiet + do_or_dryrun git push origin --quiet --force "$tag_name" --tags + + echo "Release complete ($tag_name) on branch $branch_name." +} + case "$cmd" in ""|"fast"|"full") build @@ -51,7 +124,7 @@ case "$cmd" in build test ;; - test|test_cmds|format) + test|test_cmds|format|release) $cmd ;; "test-macro-compilation-failure")