|
| 1 | +name: Dependencies Bump |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + # Run this job everyday at 5:30 AM UTC+8 |
| 5 | + - cron: '30 21 * * *' |
| 6 | + |
| 7 | +jobs: |
| 8 | + bump-deps: |
| 9 | + name: "Bump Chisel and CIRCT" |
| 10 | + if: ${{ !cancelled() }} |
| 11 | + runs-on: [self-hosted, linux, nixos] |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + defaults: |
| 15 | + run: |
| 16 | + working-directory: ./templates/chisel |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + ref: master |
| 22 | + - name: Bump nixpkgs |
| 23 | + run: | |
| 24 | + nix flake update |
| 25 | + - name: Bump Chisel |
| 26 | + run: | |
| 27 | + cd nix/pkgs/dependencies |
| 28 | + nix run '.#nvfetcher' -- -f '^chisel$' |
| 29 | + - name: Bump all mill deps |
| 30 | + run: | |
| 31 | + oldHash=$(nix derivation show .#gcd.gcd-compiled.millDeps | jq -r 'to_entries[0].value.env.outputHash') |
| 32 | + nix build '.#gcd.gcd-compiled.millDeps' --rebuild > milldeps-log.txt 2>&1 || true |
| 33 | + newHash=$(cat milldeps-log.txt \ |
| 34 | + | grep -P '^\s+got:\s+sha256-.*$' \ |
| 35 | + | cut -d':' -f2 \ |
| 36 | + | xargs) |
| 37 | + if [ -z "$newHash" ] || [ "$newHash" = "$oldHash" ]; then |
| 38 | + echo "Original build logs for debug: " |
| 39 | + cat milldeps-log.txt |
| 40 | + echo "Hash unchanged, exit" |
| 41 | + exit 0 |
| 42 | + fi |
| 43 | + echo "Updating hash $oldHash to $newHash" |
| 44 | + sed -i "s|$oldHash|$newHash|" nix/gcd/gcd.nix |
| 45 | + - name: Commit changes |
| 46 | + env: |
| 47 | + GITHUB_TOKEN: ${{ secrets.BIYUN_GITHUB_ACTION }} |
| 48 | + run: | |
| 49 | + git config user.name github-actions[bot] |
| 50 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 51 | +
|
| 52 | + currentDate=$(date +%F) |
| 53 | + branch="dependencies-bumping-$currentDate" |
| 54 | + git checkout -b "$branch" |
| 55 | +
|
| 56 | + git add 'nix/pkgs/dependencies' |
| 57 | + git add 'flake.lock' |
| 58 | +
|
| 59 | + if ! git diff --quiet --cached --exit-code; then |
| 60 | + updatedFiles=$(git diff --cached --name-only) |
| 61 | + echo "File changed" |
| 62 | + git commit -m "[deps] Bump dependencies" |
| 63 | + git push origin "$branch" --force-with-lease |
| 64 | + nix run '.#gh' -- \ |
| 65 | + pr create --title "Bump dependencies" --body "Updated: $updatedFiles" |
| 66 | + fi |
0 commit comments