Skip to content

Commit

Permalink
overhaul actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nzbr committed Nov 10, 2022
1 parent 54a2f75 commit 4f833be
Showing 1 changed file with 43 additions and 32 deletions.
75 changes: 43 additions & 32 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,112 @@ name: 'Build NixOS WSL tarball'
on: [push, pull_request, release]

jobs:
build:
find-tests:
name: Find tests πŸ”
runs-on: ubuntu-latest
outputs:
tests: ${{ steps.tests.outputs.tests }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Nix Flakes doesn't work on shallow clones
fetch-depth: 0

- name: Find tests
- name: Find tests πŸ”
id: tests
run: |
find tests -name '*.spec.ps1' -print0 | perl -pe 's|(.*?)\x0|"\1",|g;s|,$||;s|(.*)|tests=[\1]|' >> $GITHUB_OUTPUT
- name: Install nix
uses: cachix/install-nix-action@v16

- name: Run checks
run: |
nix flake check
- name: Build tarball
run: |
nix build '.#nixosConfigurations.mysystem.config.system.build.tarball'
- name: Upload tarball
uses: actions/upload-artifact@v3
build:
name: Build πŸ› οΈ
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
name: rootfs
path: result/tarball/nixos-wsl-x86_64-linux.tar.gz
fetch-depth: 0

- name: Build installer
- name: Install nix ❄️
uses: cachix/install-nix-action@v18

- name: Build installer πŸ› οΈ
run: |
nix build '.#nixosConfigurations.mysystem.config.system.build.installer'
- name: Upload installer
- name: Upload installer πŸ“€
uses: actions/upload-artifact@v3
with:
name: installer
path: result/tarball/nixos-wsl-installer.tar.gz

checks:
name: Run Flake Checks πŸ“‹
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install nix ❄️
uses: cachix/install-nix-action@v18

- name: Run checks πŸ“‹
run: |
nix flake check
tests:
needs:
- find-tests
- build
strategy:
matrix:
os:
- ubuntu-latest
# - windows-latest # doesn't work due to lack of nested virtualization on the runners, hopefully this will work one day
test: ${{ fromJSON(needs.build.outputs.tests) }}
test: ${{ fromJSON(needs.find-tests.outputs.tests) }}
name: Run Tests πŸ§ͺ
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
- name: Download installer πŸ“₯
uses: actions/download-artifact@v3
with:
name: installer

- name: Execute test
- name: Execute test πŸ§ͺ
run: |
pwsh ${{ matrix.test }}
release:
if: startsWith(github.ref, 'refs/tags/')
needs:
- checks
- build
- tests
name: Create Release πŸ“’
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: rootfs

- uses: actions/download-artifact@v3
- name: Download installer πŸ“₯
uses: actions/download-artifact@v3
with:
name: installer

- name: Generate checksums
- name: Generate checksums πŸ”‘
run: |
for x in *.tar.gz; do
sha256sum $x > ${x}.sha256
done
- name: Attach to release
- name: Attach to release πŸ“¦
uses: softprops/action-gh-release@v1
with:
files: |
nixos-wsl-x86_64-linux.tar.gz
nixos-wsl-x86_64-linux.tar.gz.sha256
nixos-wsl-installer.tar.gz
nixos-wsl-installer.tar.gz.sha256
env:
Expand Down

0 comments on commit 4f833be

Please sign in to comment.