From 962abb77f901bfd78ee5f5800ca356b0dd6c8bbb Mon Sep 17 00:00:00 2001 From: Andre-Philippe Paquet Date: Wed, 2 Oct 2024 22:15:13 -0400 Subject: [PATCH] auto updater --- .github/workflows/updater.yaml | 392 ++++++++++++++++----------------- 1 file changed, 196 insertions(+), 196 deletions(-) diff --git a/.github/workflows/updater.yaml b/.github/workflows/updater.yaml index 34a7854..58873de 100644 --- a/.github/workflows/updater.yaml +++ b/.github/workflows/updater.yaml @@ -8,233 +8,233 @@ on: push: jobs: - # update_homes: - # strategy: - # matrix: - # pair: - # # - machine: "appaquet@deskapp" - # # os: ubuntu-latest - # - machine: "appaquet@servapp" - # os: ubuntu-latest - # # - machine: "appaquet@mbpapp" - # # os: macos-latest - # runs-on: ${{ matrix.pair.os }} - # steps: - # - uses: actions/checkout@v4 - - # - uses: DeterminateSystems/nix-installer-action@main - # with: - # extra-conf: | - # experimental-features = nix-command flakes - # access-tokens = github.com=${{ secrets.GH_PAT }} - # github-token: ${{ secrets.GH_PAT }} + update_homes: + strategy: + matrix: + pair: + # - machine: "appaquet@deskapp" + # os: ubuntu-latest + - machine: "appaquet@servapp" + os: ubuntu-latest + # - machine: "appaquet@mbpapp" + # os: macos-latest + runs-on: ${{ matrix.pair.os }} + steps: + - uses: actions/checkout@v4 - # - name: Add & update nixpkgs channel - # run: | - # nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs - # nix-channel --update nixpkgs - # nix profile install nixpkgs#nvd + - uses: DeterminateSystems/nix-installer-action@main + with: + extra-conf: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ secrets.GH_PAT }} + github-token: ${{ secrets.GH_PAT }} - # - name: Building Home Manager baseline... - # run: | - # set -xe - # MACHINE_KEY="${{ matrix.pair.machine }}" ./x home build - # mv result result-before + - name: Add & update nixpkgs channel + run: | + nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs + nix-channel --update nixpkgs + nix profile install nixpkgs#nvd - # - name: Update flakes - # run: | - # set -xe - # nix flake update + - name: Building Home Manager baseline... + run: | + set -xe + MACHINE_KEY="${{ matrix.pair.machine }}" ./x home build + mv result result-before - # - name: Building Home Manager new - # run: | - # set -xe - # MACHINE_KEY="${{ matrix.pair.machine }}" ./x home build - # mv result result-after + - name: Update flakes + run: | + set -xe + nix flake update - # - name: Diffing... - # run: | - # set -xe - # nvd diff result-before result-after | tee diff - - # # Only include if significant changes. Ex base output: - # # <<< result-before - # # >>> result-after - # # Version changes: - # # Closure size: 716 -> 716 (10 paths added, 10 paths removed, delta +0, disk usage +287.0KiB). - # NB_CHANGES=$(grep -vcE "(Version changes|Closure size|<<<|>>>)" diff || true) - # if [ $NB_CHANGES -gt 0 ]; then - # echo "Changes for ${{ matrix.pair.machine }} home:" > diff-out - # cat diff >> diff-out - # echo -n " " >> diff-out - # cat diff-out > "${{ matrix.pair.machine }}-home-diff" - # fi - - # - name: Add diff as artifact - # uses: actions/upload-artifact@v4 - # with: - # name: "${{ matrix.pair.machine }}-home-diff" - # path: "${{ matrix.pair.machine }}-home-diff" - # if-no-files-found: ignore # no files means no diff + - name: Building Home Manager new + run: | + set -xe + MACHINE_KEY="${{ matrix.pair.machine }}" ./x home build + mv result result-after - # - name: Add flake.lock - # uses: actions/upload-artifact@v4 - # with: - # name: "${{ matrix.pair.machine }}-flake" - # path: "flake.lock" + - name: Diffing... + run: | + set -xe + nvd diff result-before result-after | tee diff + + # Only include if significant changes. Ex base output: + # <<< result-before + # >>> result-after + # Version changes: + # Closure size: 716 -> 716 (10 paths added, 10 paths removed, delta +0, disk usage +287.0KiB). + NB_CHANGES=$(grep -vcE "(Version changes|Closure size|<<<|>>>)" diff || true) + if [ $NB_CHANGES -gt 0 ]; then + echo "Changes for ${{ matrix.pair.machine }} home:" > diff-out + cat diff >> diff-out + echo -n " " >> diff-out + cat diff-out > "${{ matrix.pair.machine }}-home-diff" + fi - # update_nixos: - # runs-on: ubuntu-latest - # strategy: - # matrix: - # machine: ["appaquet@deskapp"] - # steps: - # - uses: actions/checkout@v4 + - name: Add diff as artifact + uses: actions/upload-artifact@v4 + with: + name: "${{ matrix.pair.machine }}-home-diff" + path: "${{ matrix.pair.machine }}-home-diff" + if-no-files-found: ignore # no files means no diff - # - uses: DeterminateSystems/nix-installer-action@main - # with: - # extra-conf: | - # experimental-features = nix-command flakes - # access-tokens = github.com=${{ secrets.GH_PAT }} - # github-token: ${{ secrets.GH_PAT }} + - name: Add flake.lock + uses: actions/upload-artifact@v4 + with: + name: "${{ matrix.pair.machine }}-flake" + path: "flake.lock" - # - name: Add & update nixpkgs channel - # run: | - # nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs - # nix-channel --update nixpkgs - # nix profile install nixpkgs#nixos-rebuild nixpkgs#nvd + update_nixos: + runs-on: ubuntu-latest + strategy: + matrix: + machine: ["appaquet@deskapp"] + steps: + - uses: actions/checkout@v4 - # - name: Building NixOS baseline... - # run: | - # set -xe - # MACHINE_KEY="appaquet@deskapp" ./x nixos build - # mv result result-before + - uses: DeterminateSystems/nix-installer-action@main + with: + extra-conf: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ secrets.GH_PAT }} + github-token: ${{ secrets.GH_PAT }} - # - name: Update flakes - # run: | - # set -xe - # nix flake update + - name: Add & update nixpkgs channel + run: | + nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs + nix-channel --update nixpkgs + nix profile install nixpkgs#nixos-rebuild nixpkgs#nvd - # - name: Building NixOS new - # run: | - # set -xe - # MACHINE_KEY="appaquet@deskapp" ./x nixos build - # mv result result-after + - name: Building NixOS baseline... + run: | + set -xe + MACHINE_KEY="appaquet@deskapp" ./x nixos build + mv result result-before - # - name: Diffing... - # run: | - # set -xe - # nvd diff result-before result-after | tee diff - - # # Only include if significant changes. Ex base output: - # # <<< result-before - # # >>> result-after - # # Version changes: - # # [U.] #1 nixos-system-deskapp 24.05.20240928.fbca5e7 -> 24.05.20240930.1719f27 - # # Closure size: 1637 -> 1637 (29 paths added, 29 paths removed, delta +0, disk usage +7.5KiB). - # NB_CHANGES=$(grep -vcE "(Version changes|nixos-system|Closure size|<<<|>>>)" diff || true) - # if [ $NB_CHANGES -gt 0 ]; then - # echo "Changes for ${{ matrix.machine }} nixos:" > diff-out - # cat diff >> diff-out - # echo -n " " >> diff-out - # cat diff-out > "${{ matrix.machine }}-nixos-diff" - # fi + - name: Update flakes + run: | + set -xe + nix flake update - # - name: Add as artifact - # uses: actions/upload-artifact@v4 - # with: - # name: "${{ matrix.machine }}-nixos-diff" - # path: "${{ matrix.machine }}-nixos-diff" - # if-no-files-found: ignore # no files means no diff + - name: Building NixOS new + run: | + set -xe + MACHINE_KEY="appaquet@deskapp" ./x nixos build + mv result result-after - # update_darwin: - # runs-on: macos-latest - # strategy: - # matrix: - # machine: ["appaquet@mbpapp"] - # steps: - # - uses: actions/checkout@v4 + - name: Diffing... + run: | + set -xe + nvd diff result-before result-after | tee diff + + # Only include if significant changes. Ex base output: + # <<< result-before + # >>> result-after + # Version changes: + # [U.] #1 nixos-system-deskapp 24.05.20240928.fbca5e7 -> 24.05.20240930.1719f27 + # Closure size: 1637 -> 1637 (29 paths added, 29 paths removed, delta +0, disk usage +7.5KiB). + NB_CHANGES=$(grep -vcE "(Version changes|nixos-system|Closure size|<<<|>>>)" diff || true) + if [ $NB_CHANGES -gt 0 ]; then + echo "Changes for ${{ matrix.machine }} nixos:" > diff-out + cat diff >> diff-out + echo -n " " >> diff-out + cat diff-out > "${{ matrix.machine }}-nixos-diff" + fi - # - uses: DeterminateSystems/nix-installer-action@main - # with: - # extra-conf: | - # experimental-features = nix-command flakes - # access-tokens = github.com=${{ secrets.GH_PAT }} - # github-token: ${{ secrets.GH_PAT }} + - name: Add as artifact + uses: actions/upload-artifact@v4 + with: + name: "${{ matrix.machine }}-nixos-diff" + path: "${{ matrix.machine }}-nixos-diff" + if-no-files-found: ignore # no files means no diff - # - name: Add & update nixpkgs channel - # run: | - # nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs - # nix-channel --update nixpkgs - # nix profile install nixpkgs#nvd + update_darwin: + runs-on: macos-latest + strategy: + matrix: + machine: ["appaquet@mbpapp"] + steps: + - uses: actions/checkout@v4 - # - name: Building baseline... - # run: | - # set -xe - # MACHINE_KEY="${{ matrix.machine }}" ./x darwin build - # mv result darwin-result-before + - uses: DeterminateSystems/nix-installer-action@main + with: + extra-conf: | + experimental-features = nix-command flakes + access-tokens = github.com=${{ secrets.GH_PAT }} + github-token: ${{ secrets.GH_PAT }} - # - name: Update flakes - # run: | - # set -xe - # nix flake update + - name: Add & update nixpkgs channel + run: | + nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs + nix-channel --update nixpkgs + nix profile install nixpkgs#nvd - # - name: Building new... - # run: | - # set -xe - # MACHINE_KEY="${{ matrix.machine }}" ./x darwin build - # mv result darwin-result-after + - name: Building baseline... + run: | + set -xe + MACHINE_KEY="${{ matrix.machine }}" ./x darwin build + mv result darwin-result-before - # - name: Diffing... - # run: | - # set -xe - # nvd diff ./darwin-result-before ./darwin-result-after | tee diff - - # # Only include if significant changes. Ex base output: - # # <<< result-before - # # >>> result-after - # # Version changes: - # # [C.] #1 darwin-system 24.05pre-git+darwin4.4b43b68, 24.05pre-git+darwin5 -> 24.05pre-git+darwin4.f61d5f2, 24.05pre-git+darwin5 - # # Closure size: 169 -> 169 (10 paths added, 10 paths removed, delta +0, disk usage +3.7KiB). - # NB_CHANGES=$(grep -vcE "(Version changes|darwin-system|Closure size|<<<|>>>)" diff || true) - # if [ $NB_CHANGES -gt 0 ]; then - # echo "Changes for ${{ matrix.machine }} darwin:" > diff-out - # cat diff >> diff-out - # echo -n " " >> diff-out - # cat diff-out > "${{ matrix.machine }}-darwin-diff" - # fi + - name: Update flakes + run: | + set -xe + nix flake update - # - name: Add as artifact - # uses: actions/upload-artifact@v4 - # with: - # name: "${{ matrix.machine }}-darwin-diff" - # path: "${{ matrix.machine }}-darwin-diff" - # if-no-files-found: ignore # no files means no diff + - name: Building new... + run: | + set -xe + MACHINE_KEY="${{ matrix.machine }}" ./x darwin build + mv result darwin-result-after - test_incoming: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Create PR + - name: Diffing... run: | - echo "something" > something-diff - echo -n " " >> flake.lock + set -xe + nvd diff ./darwin-result-before ./darwin-result-after | tee diff + + # Only include if significant changes. Ex base output: + # <<< result-before + # >>> result-after + # Version changes: + # [C.] #1 darwin-system 24.05pre-git+darwin4.4b43b68, 24.05pre-git+darwin5 -> 24.05pre-git+darwin4.f61d5f2, 24.05pre-git+darwin5 + # Closure size: 169 -> 169 (10 paths added, 10 paths removed, delta +0, disk usage +3.7KiB). + NB_CHANGES=$(grep -vcE "(Version changes|darwin-system|Closure size|<<<|>>>)" diff || true) + if [ $NB_CHANGES -gt 0 ]; then + echo "Changes for ${{ matrix.machine }} darwin:" > diff-out + cat diff >> diff-out + echo -n " " >> diff-out + cat diff-out > "${{ matrix.machine }}-darwin-diff" + fi + - name: Add as artifact uses: actions/upload-artifact@v4 with: - name: diff - path: something-diff + name: "${{ matrix.machine }}-darwin-diff" + path: "${{ matrix.machine }}-darwin-diff" if-no-files-found: ignore # no files means no diff - - name: Add as artifact - uses: actions/upload-artifact@v4 - with: - name: flake.lock - path: flake.lock + + # test_incoming: + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - name: Create PR + # run: | + # echo "something" > something-diff + # echo -n " " >> flake.lock + # - name: Add as artifact + # uses: actions/upload-artifact@v4 + # with: + # name: diff + # path: something-diff + # if-no-files-found: ignore # no files means no diff + # - name: Add as artifact + # uses: actions/upload-artifact@v4 + # with: + # name: flake.lock + # path: flake.lock create_pr: runs-on: ubuntu-latest - # needs: [update_homes, update_nixos, update_darwin] - needs: [test_incoming] + needs: [update_homes, update_nixos, update_darwin] + # needs: [test_incoming] steps: - uses: actions/checkout@v4