|
| 1 | +name: Nightly Version Update |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "0 0 * * *" # Runs every night at midnight UTC |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + issues: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + update: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v5 |
| 19 | + |
| 20 | + - name: Set up Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: '22' |
| 24 | + cache: 'yarn' |
| 25 | + |
| 26 | + - name: Install Aztec CLI |
| 27 | + run: | |
| 28 | + curl -s https://install.aztec.network > tmp.sh |
| 29 | + bash tmp.sh <<< yes "yes" |
| 30 | +
|
| 31 | + - name: Update path |
| 32 | + run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH |
| 33 | + |
| 34 | + - name: Fetch latest release |
| 35 | + id: latest |
| 36 | + run: | |
| 37 | + latest=$(node .github/scripts/fetchRelease.js) |
| 38 | + echo "latest=$latest" >> $GITHUB_OUTPUT |
| 39 | +
|
| 40 | + - name: Get current version |
| 41 | + id: current |
| 42 | + run: | |
| 43 | + current=$(grep -oP 'tag\s*=\s*"\K[^\"]+' Nargo.toml | head -1) |
| 44 | + echo "current=$current" >> $GITHUB_OUTPUT |
| 45 | +
|
| 46 | + - name: Set up Aztec for latest version |
| 47 | + if: steps.latest.outputs.latest != steps.current.outputs.current |
| 48 | + run: | |
| 49 | + tag=${{ steps.latest.outputs.latest }} |
| 50 | + echo "TAG=$tag" >> $GITHUB_ENV |
| 51 | + aztec-up -v ${tag#v} |
| 52 | +
|
| 53 | + - name: Run yarn update |
| 54 | + if: steps.latest.outputs.latest != steps.current.outputs.current |
| 55 | + run: yarn update |
| 56 | + |
| 57 | + - name: Update sandbox workflow version |
| 58 | + if: steps.latest.outputs.latest != steps.current.outputs.current |
| 59 | + run: | |
| 60 | + sed -i "s/VERSION=[0-9.]*/VERSION=${TAG#v}/" .github/workflows/sandbox.yaml |
| 61 | +
|
| 62 | + - name: Clean up temporary files |
| 63 | + if: steps.latest.outputs.latest != steps.current.outputs.current |
| 64 | + run: rm -f tmp.sh |
| 65 | + |
| 66 | + - name: Commit changes |
| 67 | + if: steps.latest.outputs.latest != steps.current.outputs.current |
| 68 | + run: | |
| 69 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 70 | + git config user.name "github-actions[bot]" |
| 71 | + git add . |
| 72 | + git commit -m "chore: update to ${{ steps.latest.outputs.latest }}" || echo "No changes" |
| 73 | +
|
| 74 | + - name: Create Pull Request |
| 75 | + if: steps.latest.outputs.latest != steps.current.outputs.current |
| 76 | + uses: peter-evans/create-pull-request@v6 |
| 77 | + with: |
| 78 | + token: ${{ secrets.ACCESS_TOKEN }} |
| 79 | + branch: nightly/update-${{ steps.latest.outputs.latest }} |
| 80 | + title: "Update to ${{ steps.latest.outputs.latest }}" |
| 81 | + body: "Automated nightly update to aztec-packages ${{ steps.latest.outputs.latest }}" |
| 82 | + commit-message: "chore: update to ${{ steps.latest.outputs.latest }}" |
| 83 | + |
| 84 | + notify-failure: |
| 85 | + needs: update |
| 86 | + runs-on: ubuntu-latest |
| 87 | + if: failure() |
| 88 | + steps: |
| 89 | + - uses: actions/github-script@v7 |
| 90 | + with: |
| 91 | + github-token: ${{ secrets.ACCESS_TOKEN }} |
| 92 | + script: | |
| 93 | + await github.rest.issues.create({ |
| 94 | + owner: context.repo.owner, |
| 95 | + repo: context.repo.repo, |
| 96 | + title: 'Nightly update failed', |
| 97 | + body: '@critesjosh The nightly update workflow failed. Please investigate.' |
| 98 | + }) |
| 99 | +
|
0 commit comments