mirror-ublue-os-akmods/.github/workflows/reusable-build.yml
m2 00880e48db
refactor: implement local builds (#356)
* refactor: implement local builds

This has a long way to go. But at least want to get the branch published.

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* disable all workflows while iterating

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* cleanup fetch-kernel.sh

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* enable local builds

Still need to generate tags. Removal of most of the suffix Containerfiles.

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add tags, images.yaml

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* use anchors more!

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* start on workflows

No Testing and Pushing in yet.

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* update workflows

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* more workflow modifications

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* don't cache during PRs

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* fix base64 decode

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* fix path name

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* name file

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* quotes?

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try again.

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try again

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* quote the env?

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* tell base64 to read from stdin

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* update workflows

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try different way for getting json file

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* fix conditional

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try github.workspace

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* just hardcode it

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* typo

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* main doesn't have zfs....

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* One button build

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* remove common from centos builds

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* handle defaults

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* fix package naming?

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* don't have ./

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try using swap instead

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* path names

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* remove dnf remove

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* missing decleration

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try allow-erasing instead

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try reinstalling instead

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* Add testing via multistage build

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add missing args

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* correct test tag name

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* fix VARS_KERNEL_VERSION now that the package is no longer messed up

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* always have json point to cache location

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* use a reusable cache workflow

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* Names

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* put generate workflow in justfile

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add startpoint for multiarch

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* change the names

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* dynamic names for generating workflow

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* start appeasing the linter

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* fix kernel version detection

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* try again

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* filter for arch

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* move system76 to common

Appease the linter

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* permissions

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* more permissions

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* move system76 back

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add arch to tags

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add push/sign/manifest

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* silly names

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* remove secureboot just recipe, it's internal to fetch-kernel.sh

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add CI=1 to scripts for debug output

* update warning for workflow within justfile

* remove for now

* Update dual-sign-check.sh

* Update Containerfile.in

* Update dual-sign-check.sh

* Add cosign fix

* Fix signing in push as well

* fix: hardcode internel kcwd for fetch-kernel.sh

* pass CI into fetch kernel, use cache version instead of get version for fetch kernel step

* split out bazzite workflow

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* rename name of reusable build

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* additional adds to manifest

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* allow workflow dispatch for cache/akmods build

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* add comments to Justfile

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* split mega workflow by flavors

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* Build Badges and README

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* appease the linter

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

* tiny AKMODS_VERSION string update

* fix manifest recipe

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>

---------

Signed-off-by: m2 <69128853+m2Giles@users.noreply.github.com>
Co-authored-by: Benjamin Sherman <benjamin@holyarmy.org>
2025-07-07 20:09:34 -04:00

161 lines
5.8 KiB
YAML

name: build-akmod
run-name: "Build ${{ inputs.akmods_target != 'common' && format('akmods-{0}', inputs.akmods_target) || 'akmods' }}:${{ inputs.kernel_flavor }}-${{ inputs.version }}"
on:
workflow_call:
inputs:
akmods_target:
description: "The akmods to build: common, extra, zfs, nvidia, nvidia-open"
required: true
type: string
bazzite_tag:
description: "The release tag for the bazzite kernel"
required: false
type: string
kernel_flavor:
description: "The Kernel flavor: main, bazzite, coreos-stable, centos-hsk, longterm-6.12, etc"
required: true
type: string
version:
description: "Release Version: 10, 41, 42, etc"
required: true
type: string
kernel_cache_key:
description: "The Key for the Kernel Cache"
required: true
type: string
workflow_dispatch:
inputs:
akmods_target:
description: "The akmods to build: common, extra, zfs, nvidia, nvidia-open"
required: true
type: string
bazzite_tag:
description: "The release tag for the bazzite kernel"
required: false
type: string
kernel_flavor:
description: "The Kernel flavor: main, bazzite, coreos-stable, centos-hsk, longterm-6.12, etc"
required: true
type: string
version:
description: "Release Version: 10, 41, 42, etc"
required: true
type: string
kernel_cache_key:
description: "The Key for the Kernel Cache"
required: true
type: string
env:
AKMODS_BAZZITE_TAG: ${{ inputs.bazzite_tag }}
AKMODS_KERNEL: ${{ inputs.kernel_flavor }}
AKMODS_TARGET: ${{ inputs.akmods_target }}
AKMODS_VERSION: ${{ inputs.version }}
KCKEY: ${{ inputs.kernel_cache_key }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-${{ inputs.version }}-${{ inputs.kernel_flavor }}-${{ inputs.akmods_target }}
cancel-in-progress: true
jobs:
build-akmods:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.platform == 'x86_64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
permissions:
actions: read
contents: read
packages: write
container:
image: "ghcr.io/ublue-os/devcontainer:latest"
options: "--privileged --volume /var/lib/containers:/var/lib/containers --security-opt seccomp=unconfined --security-opt label=disable --user 0:0"
strategy:
fail-fast: false
matrix:
platform:
- x86_64
# - aarch64
steps:
- name: Checkout Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Mark Directory as Safe
run: git config --system --ad safe.directory "$GITHUB_WORKSPACE"
- name: Export GITHUB_WORKSPACE
id: gh-workspace
run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> "$GITHUB_OUTPUT"
- name: Cache Kernel RPMs
id: cache-kernel
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ steps.gh-workspace.outputs.GITHUB_WORKSPACE }}/build/${{ env.AKMODS_KERNEL }}-${{ env.AKMODS_VERSION }}/KCWD/rpms
key: ${{ env.KCKEY }}-${{ matrix.platform }}
- name: Fail Absent Kernel Cache
if: steps.cache-kernel.outputs.cache-hit != 'true'
run: "echo 'Kernel Cache not found for key: ${{ env.KCKEY }}'; exit 1"
- name: Retrieve Signing Key
if: contains(fromJson('["schedule", "workflow_dispatch", "merge_group"]'), github.event_name)
shell: bash
run: |
mkdir -p certs
echo "${{ secrets.KERNEL_PRIVKEY }}" > certs/private_key.priv
echo "${{ secrets.AKMOD_PRIVKEY_20230518 }}" > certs/private_key_2.priv
# DEBUG: get character count of key
wc -c certs/private_key.priv
wc -c certs/private_key_2.priv
- name: Build Image
id: build
run: just build
- name: Test Image
run: just test
- name: Push and Sign Image
if: contains(fromJson('["schedule", "workflow_dispatch", "merge_group"]'), github.event_name)
run:
just login-to-ghcr
just push
env:
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
REGISTRY_ACTOR: ${{ github.actor }}
REGISTRY_TOKEN: ${{ github.token }}
manifest:
name: "Generate ${{ inputs.akmods_target != 'common' && format('akmods-{0}', inputs.akmods_target) || 'akmods' }}:${{ inputs.kernel_flavor }}-${{ inputs.version }} Manifest"
runs-on: ubuntu-latest
needs: [build-akmods]
container:
image: "ghcr.io/ublue-os/devcontainer:latest"
options: "--privileged --volume /var/lib/containers:/var/lib/containers --security-opt seccomp=unconfined --security-opt label=disable --user 0:0"
permissions:
actions: read
contents: read
packages: write
steps:
- name: Exit on failure
if: ${{ needs.build-akmods.result == 'failure' }}
run: exit 1
- name: Export GITHUB_WORKSPACE
id: gh-workspace
run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> "$GITHUB_OUTPUT"
- name: Cache Kernel RPMs
id: cache-kernel
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ steps.gh-workspace.outputs.GITHUB_WORKSPACE }}/build/${{ env.AKMODS_KERNEL }}-${{ env.AKMODS_VERSION }}/KCWD/rpms
key: ${{ env.KCKEY }}-x86_64
- name: Generate Manifest
if: contains(fromJson('["schedule", "workflow_dispatch", "merge_group"]'), github.event_name)
run:
just login-to-ghcr
just manifest
env:
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
REGISTRY_ACTOR: ${{ github.actor }}
REGISTRY_TOKEN: ${{ github.token }}