Give every file a header (title, empty line, explanation), wrap comments at 80 columns and keep them to the why. Only comments change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
3.1 KiB
YAML
74 lines
3.1 KiB
YAML
# OS image
|
|
#
|
|
# Builds the OS image and publishes it as version "latest". VMs fetch the
|
|
# built images as updates (mkosi.extra/usr/lib/sysupdate.d). Runs on every
|
|
# push, weekly for package updates, and by hand for critical CVEs.
|
|
#
|
|
# Values used below:
|
|
# - PKG upload location, <server>/api/packages/<owner>/generic/
|
|
# agent/latest. Path= in mkosi.extra/usr/lib/sysupdate.d/
|
|
# *.transfer points at the same place.
|
|
# - AUTH the job's automatic token (gitea.token), which can write
|
|
# the owner's packages.
|
|
# - SECUREBOOT_KEY repository secret: the private key of mkosi.crt, written
|
|
# to mkosi.key.
|
|
# - SIGNING_KEY repository secret: the armored private gpg key whose
|
|
# public half is mkosi.extra/usr/lib/systemd/
|
|
# import-pubring.pgp, which systemd-sysupdate checks.
|
|
# - zstd -19 -T0 the root and verity partitions have a fixed size (1 GiB,
|
|
# 64 MiB) and are mostly zero padding: zstd shrinks them
|
|
# from ~1.1 GB to ~245 MB. -19 is ~11% smaller than the
|
|
# default -3, for ~35 s more build time. -T0 uses all
|
|
# cores; --rm deletes the .raw files. systemd-sysupdate
|
|
# decompresses .raw.zst as it downloads.
|
|
# - qemu-img -c agent.qcow2, the whole disk compressed, for creating new
|
|
# VMs (not for updates).
|
|
# - SHA256SUMS checksums of the update files, signed as SHA256SUMS.gpg
|
|
# (Verify=yes in sysupdate.d).
|
|
name: os
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
schedule:
|
|
- cron: "0 2 * * 0" # weekly (Sunday), picks up package updates
|
|
workflow_dispatch: # run by hand, e.g. for a CVE
|
|
|
|
jobs:
|
|
os:
|
|
runs-on: linux
|
|
env:
|
|
PKG: ${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/agent/latest
|
|
AUTH: "Authorization: token ${{ gitea.token }}"
|
|
steps:
|
|
- name: Install tools
|
|
run: dnf install -yq mkosi sbsigntools
|
|
- name: Check out
|
|
uses: builtin:checkout
|
|
- name: Build
|
|
env:
|
|
KEY: ${{ secrets.SECUREBOOT_KEY }}
|
|
run: |
|
|
(umask 077 && printf '%s\n' "$KEY" > mkosi.key)
|
|
mkosi build
|
|
- name: Compress
|
|
working-directory: mkosi.output
|
|
run: |
|
|
zstd -q --rm -T0 -19 agent_*.root-*.raw
|
|
qemu-img convert -c -O qcow2 "$(basename agent_*.efi .efi).raw" agent.qcow2
|
|
sha256sum agent_*.efi agent_*.root-*.raw.zst > SHA256SUMS
|
|
- name: Sign
|
|
working-directory: mkosi.output
|
|
env:
|
|
KEY: ${{ secrets.SIGNING_KEY }}
|
|
run: |
|
|
export GNUPGHOME=$(mktemp -d)
|
|
gpg -q --batch --import <<< "$KEY"
|
|
gpg -q --batch -o SHA256SUMS.gpg --detach-sign SHA256SUMS
|
|
- name: Publish
|
|
working-directory: mkosi.output
|
|
run: |
|
|
curl -fsS -H "$AUTH" -X DELETE "$PKG" || true
|
|
for f in agent_*.efi agent_*.root-*.raw.zst agent.qcow2 SHA256SUMS.gpg SHA256SUMS; do
|
|
curl -fsS -o /dev/null -H "$AUTH" --upload-file "$f" "$PKG/$f"
|
|
done
|