-
Notifications
You must be signed in to change notification settings - Fork 13
159 lines (153 loc) · 4.33 KB
/
cicd.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: CI/CD
on:
pull_request:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: true
matrix:
os: [ubuntu-22.04, macos-13, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./
with:
nix_archives_url: https://github.com/nixbuild/nix-quick-install-action/releases/download/v29
nix_version: 2.24.9
- uses: cachix/cachix-action@v15
with:
name: nixbuild
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Build nix archives
id: build-nix-archives
run: |
nix build .#nix-archives
echo "result=$(readlink result)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: nix-archives-${{ runner.os }}-${{ runner.arch }}
path: ${{ steps.build-nix-archives.outputs.result }}/
test:
needs: build
strategy:
fail-fast: true
matrix:
os:
- ubuntu-22.04
- macos-14
- macos-13
nix_version:
- 2.24.9
- 2.23.3
- 2.22.3
- 2.21.4
- 2.20.8
- 2.19.6
- 2.18.8
- 2.3.18
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
id: nix-archives
with:
name: nix-archives-${{ runner.os }}-${{ runner.arch }}
- uses: ./
with:
nix_archives_url: file://${{steps.nix-archives.outputs.download-path}}
nix_version: ${{ matrix.nix_version }}
nix_on_tmpfs: true
- name: Test nix
run: nix-build -v --version
- name: Add to store
run: |
file="$RANDOM"
echo "$RANDOM" > "$file"
path="$(nix-store --add "./$file")"
test-cachix:
needs: build
strategy:
fail-fast: true
matrix:
os:
- ubuntu-22.04
- macos-14
- macos-13
nix_version:
- 2.24.9
- 2.23.3
- 2.22.3
- 2.21.4
- 2.20.8
- 2.19.6
- 2.18.8
- 2.3.18
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
id: nix-archives
with:
name: nix-archives-${{ runner.os }}-${{ runner.arch }}
- uses: ./
with:
nix_archives_url: file://${{steps.nix-archives.outputs.download-path}}
nix_version: ${{ matrix.nix_version }}
nix_conf: ${{ matrix.nix_conf }}
- uses: cachix/cachix-action@v15
with:
name: nixbuild
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
skipPush: true
- name: Verify nix config
run: |
if ! egrep -q "^substituters = https://cache.nixos.org https://nixbuild.cachix.org$" "$HOME/.config/nix/nix.conf"; then
echo "Invalid substituters config"
exit 1
fi
- name: Push to Cachix
if: github.event_name == 'push' && github.repository_owner == 'nixbuild'
run: |
dd if=/dev/urandom of=random count=1
cachix push nixbuild "$(nix add-to-store random)"
release:
runs-on: ubuntu-latest
needs:
- build
- test
- test-cachix
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: nix-archives-Linux-X64
path: /tmp/archives
- uses: actions/download-artifact@v4
with:
name: nix-archives-macOS-X64
path: /tmp/archives
- uses: actions/download-artifact@v4
with:
name: nix-archives-macOS-ARM64
path: /tmp/archives
- uses: ./
with:
nix_archives_url: file:///tmp/archives
nix_version: 2.24.9
- uses: cachix/cachix-action@v15
with:
name: nixbuild
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Build release script
run: nix build .#release
- name: Release if needed
run: ./result/bin/release /tmp/archives ./RELEASE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}