-
Notifications
You must be signed in to change notification settings - Fork 9
334 lines (288 loc) · 11.7 KB
/
Copy pathci.yml
File metadata and controls
334 lines (288 loc) · 11.7 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
name: For each commit and PR
on:
push:
branches:
- "main"
pull_request:
permissions:
contents: read
packages: write
env:
DEFAULT_FLAVOR_ID: "trixie-slim"
FORCE_COLOR: "1"
jobs:
# -------------------------------------------------------------------
# Lint — ruff (lint + format) and pyright (type checking)
# -------------------------------------------------------------------
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install lint tools
run: make lint-install
- name: Lint
run: make lint
# -------------------------------------------------------------------
# Download tools (containerd, runc, nerdctl, CNI plugins)
# -------------------------------------------------------------------
download-tools:
needs: [ lint ]
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
env:
ARCH: ${{ matrix.arch }}
MKOSI_MODE: skip
TOOLS_MODE: native
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Restore tools cache
id: tools-cache
uses: actions/cache/restore@v5
with:
path: |
mkosi.output/tools/${{ matrix.arch }}/usr/local/bin
mkosi.output/tools/${{ matrix.arch }}/opt/cni
key: tools-${{ matrix.arch }}-${{ hashFiles('captain/tools.py') }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Download tools
env:
TOOLS_MODE: native
run: uv run captain tools
- name: Save tools cache
if: github.ref == 'refs/heads/main' && steps.tools-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
mkosi.output/tools/${{ matrix.arch }}/usr/local/bin
mkosi.output/tools/${{ matrix.arch }}/opt/cni
key: tools-${{ matrix.arch }}-${{ hashFiles('captain/tools.py') }}
- name: Upload tools artifacts
uses: actions/upload-artifact@v6
with:
name: tools-${{ matrix.arch }}
path: |
mkosi.output/tools/${{ matrix.arch }}/usr/local/bin
mkosi.output/tools/${{ matrix.arch }}/opt/cni
retention-days: 1
# -------------------------------------------------------------------
# Build Docker builder image, per-arch; pushes to ghcr.io.
# -------------------------------------------------------------------
build-dockerfile:
needs: [ lint ]
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix: { arch: [ amd64, arm64 ] }
env:
ARCH: ${{ matrix.arch }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Dockerfile
run: uv run captain builder
# only if a PR, since we don't want to push images for PRs from forks
if: github.event_name == 'pull_request'
- name: Build Dockerfile and push
run: uv run captain builder --push
# only if not a PR, since we don't want to push images for PRs from forks (no perms to push)
if: github.event_name != 'pull_request'
# -------------------------------------------------------------------
# Download tools (containerd, runc, nerdctl, CNI plugins)
# -------------------------------------------------------------------
build-captainos-kernel:
needs: [ build-dockerfile ]
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
env:
ARCH: ${{ matrix.arch }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Restore kernel cache
id: kernel-cache
uses: actions/cache/restore@v5
with:
path: |
mkosi.output/kernel/${{ matrix.arch }}
key: kernel-${{ matrix.arch }}-${{ hashFiles('**/*.py', 'kernel.configs/*', 'Dockerfile', 'pyproject.toml') }}
# any "previous" cache can also be useful; we'll just churn cache misses more often, but that's better than a complete cache miss and rebuild every time
restore-keys: |
kernel-${{ matrix.arch }}
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Build kernel
run: uv run captain --verbose kernel
- name: Save kernel cache
if: github.ref == 'refs/heads/main' && steps.tools-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
mkosi.output/kernel/${{ matrix.arch }}
key: kernel-${{ matrix.arch }}-${{ hashFiles('**/*.py', 'kernel.configs/*', 'Dockerfile', 'pyproject.toml') }}
- name: Upload kernel artifacts
uses: actions/upload-artifact@v6
with:
name: kernel-${{ matrix.arch }}
path: |
mkosi.output/kernel/${{ matrix.arch }}
retention-days: 1
build-captainos-with-kernel: # only for flavors that require the custom CaptainOS kernel; otherwise, just build-captainos
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
needs: [ download-tools, build-dockerfile, build-captainos-kernel ]
strategy:
fail-fast: false
matrix:
include:
- { arch: amd64, output_arch: x86_64, captainos_kernel: true, iso: true, FLAVOR_ID: "trixie-slim" }
- { arch: arm64, output_arch: aarch64, captainos_kernel: true, iso: true, FLAVOR_ID: "trixie-slim" }
env: &build_env
ARCH: ${{ matrix.arch }}
MKOSI_MODE: docker
ISO_MODE: docker
FLAVOR_ID: ${{ matrix.FLAVOR_ID }}
steps: &build_steps
- name: Checkout code
uses: actions/checkout@v6
- name: Download tools artifacts
uses: actions/download-artifact@v8
with:
name: tools-${{ matrix.arch }}
path: mkosi.output/tools/${{ matrix.arch }}
- name: Download kernel artifacts == ${{ matrix.captainos_kernel }}
uses: actions/download-artifact@v8
if: ${{ matrix.captainos_kernel }} # only if matrix entry had captainos_kernel: true
with:
name: kernel-${{ matrix.arch }}
path: mkosi.output/kernel/${{ matrix.arch }}
- name: Restore tool binary permissions
run: |
# GitHub Actions artifact upload/download strips execute permissions.
# Restore +x on all tool binaries so they work inside the initramfs.
chmod +x mkosi.output/tools/${{ matrix.arch }}/usr/local/bin/*
chmod +x mkosi.output/tools/${{ matrix.arch }}/opt/cni/bin/*
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Build initramfs
run: uv run captain build # full build, incl initramfs and iso when appropriate
- name: Upload initramfs artifacts
uses: actions/upload-artifact@v6
with:
name: initramfs-${{ matrix.FLAVOR_ID }}-${{ matrix.arch }}
# The full 'out/' directory contents, but not any .iso files (if any) since those are uploaded later
path: |
out/
!out/**/*.iso
retention-days: 1
# do not upload any .iso files (exclude)
# -------------------------------------------------------------------
# UEFI-bootable ISO - only for certain flavors (eg trixie-full)
# -------------------------------------------------------------------
- name: Upload ISO artifact
if: ${{ matrix.iso }} # only if matrix entry had iso: true
uses: actions/upload-artifact@v6
with:
name: iso-${{ matrix.FLAVOR_ID }}-${{ matrix.arch }}
path: out/captainos-${{ matrix.FLAVOR_ID }}-${{ matrix.output_arch }}.iso
retention-days: 1
# -------------------------------------------------------------------
# Publish per-arch artifacts and compute checksums
# -------------------------------------------------------------------
- name: Log in to GHCR
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish artifacts to GHCR
# only pushes to main, and not PR workflows, should try to push to OCI registry
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
env:
TARGET: ${{ matrix.arch }}
run: uv run captain release-publish
build-captainos: # those use regular Debian apt repos for kernels
steps: *build_steps
env: *build_env
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
needs: [ download-tools, build-dockerfile ]
strategy:
fail-fast: false
matrix:
include:
- { arch: amd64, output_arch: x86_64, captainos_kernel: false, iso: true, FLAVOR_ID: "trixie-full" }
- { arch: arm64, output_arch: aarch64, captainos_kernel: false, iso: true, FLAVOR_ID: "trixie-full" }
- { arch: arm64, output_arch: aarch64, captainos_kernel: false, iso: false, FLAVOR_ID: "trixie-rockchip64" }
- { arch: arm64, output_arch: aarch64, captainos_kernel: false, iso: false, FLAVOR_ID: "trixie-rockchip64-vendor" }
- { arch: arm64, output_arch: aarch64, captainos_kernel: false, iso: false, FLAVOR_ID: "trixie-meson64" }
- { arch: arm64, output_arch: aarch64, captainos_kernel: false, iso: false, FLAVOR_ID: "trixie-armbian-rpi" }
# -------------------------------------------------------------------
# Publish combined multi-arch image (reuses per-arch registry blobs)
# -------------------------------------------------------------------
publish-combined:
if: github.ref == 'refs/heads/main'
name: "publish-combined"
runs-on: ubuntu-latest
needs: [ build-captainos ]
env:
ARCH: amd64
TARGET: combined
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Load shared config
run: cat .github/config.env >> "$GITHUB_ENV"
- name: Download initramfs artifacts (amd64)
uses: actions/download-artifact@v8
with:
name: initramfs-${{ env.DEFAULT_FLAVOR_ID }}-amd64
path: out
- name: Download ISO artifact (amd64)
uses: actions/download-artifact@v8
with:
name: iso-${{ env.DEFAULT_FLAVOR_ID }}-amd64
path: out
- name: Download initramfs artifacts (arm64)
uses: actions/download-artifact@v8
with:
name: initramfs-${{ env.DEFAULT_FLAVOR_ID }}-arm64
path: out
- name: Download ISO artifact (arm64)
uses: actions/download-artifact@v8
with:
name: iso-${{ env.DEFAULT_FLAVOR_ID }}-arm64
path: out
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish combined image to GHCR
# only pushes to main, and not PR workflows, should try to push to OCI registry
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
env:
FLAVOR_ID: "${{ env.DEFAULT_FLAVOR_ID }}"
run: uv run captain release-publish