comodore-iec-emu/.gitea/workflows/build-kernel.yml
Christian Werner 5476a5db28
Some checks failed
Build kernel module / build (linux-headers-rpi-v6) (push) Failing after 3m39s
Build kernel module / build (linux-headers-rpi-v7) (push) Failing after 57s
Build kernel module / build (linux-headers-rpi-v8) (push) Failing after 5m32s
Build kernel module / release (push) Has been skipped
feat(ci): Add kernel module build and release workflow
Introduce a workflow to build kernel modules for multiple header packages on PRs and releases. PR builds verify compilation, while release builds package outputs and publish them to a Gitea release. This enhances automation and ensures compatibility across target environments.
2026-06-19 03:00:59 +02:00

93 lines
3.4 KiB
YAML

name: Build kernel module
on:
# Release flow: triggered when a version tag is pushed (tag a commit on master).
# Builds every target and publishes the modules to a Gitea release.
push:
tags:
- 'v*'
# Compile-check flow: every PR that targets master. Builds only, no release.
pull_request:
branches:
- master
jobs:
# Build (and thereby compile-check) the module for each header package. Runs on
# both triggers — on a PR this is the whole story; on a tag the `release` job
# below consumes the artifacts. All packages build against the latest archive
# kernel; the exact version is auto-resolved from the image at build time.
build:
runs-on: ubuntu-latest
strategy:
# Don't cancel the other targets if one package fails to build.
fail-fast: false
matrix:
headers_pkg:
- linux-headers-rpi-v8 # 64-bit (Pi Zero 2 W)
- linux-headers-rpi-v7 # 32-bit
- linux-headers-rpi-v6 # 32-bit (older Pis)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build module (${{ matrix.headers_pkg }})
working-directory: kernel
env:
HEADERS_PKG: ${{ matrix.headers_pkg }}
run: ./build-in-docker.sh
- name: Stage build output (<kernel_version>/<headers_pkg>.ko)
working-directory: kernel
run: |
# Ask the just-built image which kernel tree it installed, then drop the
# -rpi-vN arch suffix so every package shares one version folder.
kver=$(docker run --rm --platform linux/arm64 --entrypoint sh \
"${IMAGE:-iec-kbuild}" -c 'ls -1 /lib/modules | sort -V | tail -n1')
ver="${kver%-rpi-*}"
echo "resolved kernel: $kver -> version folder: $ver"
mkdir -p "out/$ver"
mv iec_listener.ko "out/$ver/${{ matrix.headers_pkg }}.ko"
- name: Upload build output
uses: actions/upload-artifact@v4
with:
# Name by headers_pkg so artifact names stay unique; the shared
# <kernel_version>/ folder is reassembled at download via merge-multiple.
name: ${{ matrix.headers_pkg }}
path: kernel/out
if-no-files-found: error
# Release flow only: reassembles the <kernel_version>/ folders, wraps them in a
# single repo-named top folder alongside selftest.sh, zips it and attaches it to
# the Gitea release for the pushed tag. Skipped entirely on pull requests.
release:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all build output
uses: actions/download-artifact@v4
with:
path: modules
# Merge every artifact back into the shared <kernel_version>/ tree.
merge-multiple: true
- name: Assemble release package
run: |
repo="${{ github.event.repository.name }}"
root="package/$repo"
mkdir -p "$root"
cp -r modules/. "$root"/ # <kernel_version>/<headers_pkg>.ko
cp kernel/selftest.sh "$root"/ # selftest.sh only at the package root
(cd package && zip -r "../${repo}-${{ github.ref_name }}.zip" "$repo")
- name: Publish to Gitea release
uses: actions/gitea-release-action@v1.3.6
with:
api_key: ${{ secrets.GITEA_TOKEN }}
files: |-
*.zip