-
-
Notifications
You must be signed in to change notification settings - Fork 12
129 lines (120 loc) · 3.41 KB
/
nix-github-actions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Nix Flake actions
on:
pull_request:
push:
branches:
- master
- main
permissions:
contents: read
pages: write
id-token: write
jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: pyproject-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
echo "matrix=$(nix eval --json '.#githubActions.matrix')" >> "$GITHUB_OUTPUT"
nix-build:
name: ${{ matrix.name }} (${{ matrix.system }})
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: pyproject-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L ".#${{ matrix.attr }}"
nix-unit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: pyproject-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build shell
run: nix develop -c true
- name: Run tests
run: nix develop -c nix-unit --flake .#libTests
flake-templates:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: pyproject-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- id: set-matrix
name: Evaluate flake templates
run: |
set -Eeu
for template in templates/*; do
echo "Evaluating $template"
nix flake show --all-systems --override-input pyproject-nix . "./$template"
done
collect:
runs-on: ubuntu-latest
needs:
- nix-unit
- nix-build
- flake-templates
steps:
- run: true
build-pages:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: collect
steps:
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v15
with:
name: pyproject-nix
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- uses: actions/[email protected]
- name: Run build
run: nix build -L '.#doc'
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./result
deploy-pages:
if: github.ref == 'refs/heads/master'
needs: build-pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4