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