From c65907b1fe6053246932eb64d39491e1fe90fa12 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 12 Aug 2023 16:48:20 +0300 Subject: [PATCH] CI: add reusable actions --- .github/workflows/commit.yml | 19 ++++++++ .github/workflows/man-update.yaml | 10 ++--- .github/workflows/nix-build-packages.yml | 7 +++ .github/workflows/nix-build.yaml | 26 ----------- .github/workflows/nix-build.yml | 17 +++++++ .github/workflows/nix-update-inputs.yaml | 54 +++++++++-------------- .github/workflows/nix-update-wlroots.yaml | 39 ++++------------ .github/workflows/nix.yml | 26 +++++++++++ 8 files changed, 103 insertions(+), 95 deletions(-) create mode 100644 .github/workflows/commit.yml create mode 100644 .github/workflows/nix-build-packages.yml delete mode 100644 .github/workflows/nix-build.yaml create mode 100644 .github/workflows/nix-build.yml create mode 100644 .github/workflows/nix.yml diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml new file mode 100644 index 000000000000..4643f75bc0a9 --- /dev/null +++ b/.github/workflows/commit.yml @@ -0,0 +1,19 @@ +name: Commit + +on: + workflow_call: + inputs: + message: + required: true + type: string + +jobs: + commit: + runs-on: ubuntu-latest + steps: + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: ${{ inputs.message }} + commit_user_name: Mihai Fufezan + commit_user_email: fufexan@protonmail.com + commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> diff --git a/.github/workflows/man-update.yaml b/.github/workflows/man-update.yaml index 224d81a4e3b6..2a2ff257839f 100644 --- a/.github/workflows/man-update.yaml +++ b/.github/workflows/man-update.yaml @@ -22,8 +22,8 @@ jobs: # submodules: recursive - name: Build man pages run: make man - - uses: stefanzweifel/git-auto-commit-action@v4 - name: Commit - with: - commit_message: "[gha] build man pages" - commit_author: Mihai Fufezan + + push: + uses: ./.github/workflows/commit.yml + with: + message: "[gha] build man pages" diff --git a/.github/workflows/nix-build-packages.yml b/.github/workflows/nix-build-packages.yml new file mode 100644 index 000000000000..f1a589c9a2f1 --- /dev/null +++ b/.github/workflows/nix-build-packages.yml @@ -0,0 +1,7 @@ +name: Nix Packages + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + uses: ./.github/workflows/build.yml diff --git a/.github/workflows/nix-build.yaml b/.github/workflows/nix-build.yaml deleted file mode 100644 index 5e911a384fc5..000000000000 --- a/.github/workflows/nix-build.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build Hyprland (Nix) - -on: [push, pull_request, workflow_dispatch] -jobs: - nix: - name: "Build Hyprland (Nix)" - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v3 - with: - submodules: recursive - - name: Install nix - uses: cachix/install-nix-action@v20 - with: - install_url: https://nixos.org/nix/install - extra_nix_config: | - auto-optimise-store = true - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - experimental-features = nix-command flakes - - uses: cachix/cachix-action@v12 - with: - name: hyprland - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: Build packages - run: nix flake check --print-build-logs --accept-flake-config diff --git a/.github/workflows/nix-build.yml b/.github/workflows/nix-build.yml new file mode 100644 index 000000000000..0199a48d7553 --- /dev/null +++ b/.github/workflows/nix-build.yml @@ -0,0 +1,17 @@ +name: Nix Build + +on: + workflow_call: + +jobs: + build: + strategy: + matrix: + package: + - hyprland + - hyprland-nvidia + - xdg-desktop-portal-hyprland + + uses: ./.github/workflows/nix.yml + with: + command: nix build -L .#${{ matrix.package }} diff --git a/.github/workflows/nix-update-inputs.yaml b/.github/workflows/nix-update-inputs.yaml index 13dc499c041e..339e8a4299fe 100644 --- a/.github/workflows/nix-update-inputs.yaml +++ b/.github/workflows/nix-update-inputs.yaml @@ -2,40 +2,26 @@ name: "Nix update" on: schedule: - - cron: '0 0 * * *' + - cron: '0 0 * * *' # daily jobs: update: - name: "inputs" - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v3 - - - name: Install nix - uses: cachix/install-nix-action@v20 - with: - install_url: https://nixos.org/nix/install - extra_nix_config: | - auto-optimise-store = true - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - experimental-features = nix-command flakes - - - name: Update lockfile - run: nix/update-inputs.sh - - - uses: cachix/cachix-action@v12 - with: - name: hyprland - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - - name: Build packages - run: nix flake check --print-build-logs --accept-flake-config - - - name: Build Waybar-Hyprland - run: nix build .#waybar-hyprland --print-build-logs - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "Nix: bump inputs" - commit_author: Mihai Fufezan + uses: ./.github/workflows/nix.yml + with: + command: nix/update-inputs.sh + + build: + needs: update + uses: ./.github/workflows/nix-build.yml + + build-waybar: + needs: update + uses: ./.github/workflosw/nix.yml + with: + command: nix build -L .#waybar-hyprland + + push: + needs: [build, build-waybar] + uses: ./.github/workflows/commit.yml + with: + message: "Nix: bump inputs" diff --git a/.github/workflows/nix-update-wlroots.yaml b/.github/workflows/nix-update-wlroots.yaml index 3a9f69982b60..6d6b0c55e8a7 100644 --- a/.github/workflows/nix-update-wlroots.yaml +++ b/.github/workflows/nix-update-wlroots.yaml @@ -4,33 +4,12 @@ on: [push, workflow_dispatch] jobs: update: - name: "wlroots" - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v3 - - - name: Install nix - uses: cachix/install-nix-action@v20 - with: - install_url: https://nixos.org/nix/install - extra_nix_config: | - auto-optimise-store = true - access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - experimental-features = nix-command flakes - - - name: Update lockfile - run: nix/update-wlroots.sh - - - uses: cachix/cachix-action@v12 - with: - name: hyprland - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - - name: Build packages - run: nix flake check --print-build-logs --accept-flake-config - - - uses: stefanzweifel/git-auto-commit-action@v4 - with: - commit_message: "Nix: bump wlroots" - commit_author: Mihai Fufezan + uses: ./.github/workflows/nix.yml + with: + command: nix/update-wlroots.sh + + push: + needs: update + uses: ./.github/workflows/commit.yml + with: + message: "Nix: bump wlroots" diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 000000000000..fd00ace71114 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,26 @@ +name: Nix + +on: + workflow_call: + inputs: + command: + required: true + type: string + +jobs: + nix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + with: + install_url: https://nixos.org/nix/install + extra_nix_config: | + auto-optimise-store = true + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} + experimental-features = nix-command flakes + - uses: cachix/cachix-action@v12 + with: + name: hyprland + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: ${{ inputs.command }}