From 5476a5db284e81d96b0925fbfa0131fb16f08fc0 Mon Sep 17 00:00:00 2001 From: Christian Werner Date: Fri, 19 Jun 2026 03:00:59 +0200 Subject: [PATCH] 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. --- .gitea/workflows/build-kernel.yml | 92 +++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .gitea/workflows/build-kernel.yml diff --git a/.gitea/workflows/build-kernel.yml b/.gitea/workflows/build-kernel.yml new file mode 100644 index 0000000..6be7f47 --- /dev/null +++ b/.gitea/workflows/build-kernel.yml @@ -0,0 +1,92 @@ +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 (/.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 + # / 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 / 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 / tree. + merge-multiple: true + + - name: Assemble release package + run: | + repo="${{ github.event.repository.name }}" + root="package/$repo" + mkdir -p "$root" + cp -r modules/. "$root"/ # /.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