-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): fix linux version metadata and make builds more reliable (#171
) Signed-off-by: RJ Trujillo <[email protected]> Co-authored-by: RJ Trujillo <[email protected]>
- Loading branch information
Showing
6 changed files
with
120 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ on: | |
required: true | ||
type: string | ||
env: | ||
IMAGE_NAME: akmods | ||
IMAGE_BASE_NAME: akmods | ||
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | ||
|
||
concurrency: | ||
|
@@ -36,14 +36,7 @@ jobs: | |
cfile_suffix: | ||
- common | ||
- nvidia | ||
nvidia_version: | ||
- 0 | ||
- 550 | ||
exclude: | ||
- cfile_suffix: common | ||
nvidia_version: 550 | ||
- cfile_suffix: nvidia | ||
nvidia_version: 0 | ||
- kernel_flavor: asus | ||
fedora_version: 38 | ||
- kernel_flavor: surface | ||
|
@@ -56,7 +49,6 @@ jobs: | |
kernel_flavor: fsync # kernel-fsync packages are not being built for F40 yet. | ||
- fedora_version: 40 | ||
kernel_flavor: fsync-lts | ||
|
||
steps: | ||
# Checkout push-to-registry action GitHub repository | ||
- name: Checkout Push to Registry action | ||
|
@@ -65,26 +57,31 @@ jobs: | |
- name: Matrix Variables | ||
shell: bash | ||
run: | | ||
if [ "common" == "${{ matrix.cfile_suffix }}" ]; then | ||
echo "IMAGE_NAME=${{ env.IMAGE_BASE_NAME }}" >> $GITHUB_ENV | ||
else | ||
echo "IMAGE_NAME=${{ env.IMAGE_BASE_NAME }}-${{ matrix.cfile_suffix }}" >> $GITHUB_ENV | ||
fi | ||
if [[ "${{ matrix.fedora_version }}" -ge "41" ]]; then | ||
# when we are confident of official fedora images we can switch to them | ||
echo "SOURCE_IMAGE=fedora-silverblue" >> $GITHUB_ENV | ||
echo "SOURCE_ORG=fedora" >> $GITHUB_ENV | ||
export SOURCE_IMAGE=fedora-silverblue | ||
export SOURCE_ORG=fedora | ||
else | ||
echo "SOURCE_IMAGE=base" >> $GITHUB_ENV | ||
echo "SOURCE_ORG=fedora-ostree-desktops" >> $GITHUB_ENV | ||
export SOURCE_IMAGE=base | ||
export SOURCE_ORG=fedora-ostree-desktops | ||
fi | ||
echo "FQ_SOURCE_IMAGE=quay.io/${SOURCE_ORG}/${SOURCE_IMAGE}:${{ matrix.fedora_version }}" >> $GITHUB_ENV | ||
echo "SOURCE_IMAGE=${SOURCE_IMAGE}" >> $GITHUB_ENV | ||
echo "SOURCE_ORG=${SOURCE_ORG}" >> $GITHUB_ENV | ||
- name: Generate tags | ||
id: generate-tags | ||
shell: bash | ||
run: | | ||
# Generate a timestamp for creating an image version history | ||
TIMESTAMP="$(date +%Y%m%d)" | ||
if [[ "${{ matrix.cfile_suffix }}" == "nvidia" ]]; then | ||
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}-${{ matrix.nvidia_version }}" | ||
else | ||
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}" | ||
fi | ||
VARIANT="${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }}" | ||
COMMIT_TAGS=() | ||
BUILD_TAGS=() | ||
|
@@ -125,69 +122,103 @@ jobs: | |
# DEBUG: get character count of key | ||
wc -c certs/private_key.priv | ||
- name: Get current version | ||
id: labels | ||
- name: Pull build image | ||
uses: Wandalen/[email protected] | ||
with: | ||
attempt_limit: 3 | ||
attempt_delay: 15000 | ||
command: | | ||
set -eo pipefail | ||
skopeo inspect docker://quay.io/${{ env.SOURCE_ORG }}/${{ env.SOURCE_IMAGE }}:${{ matrix.fedora_version }} > inspect.json | ||
ver=$(jq -r '.Labels["org.opencontainers.image.version"]' inspect.json) | ||
# pull the base image used for FROM in containerfile so | ||
# we can retry on that unfortunately common failure case | ||
podman pull ${{ env.FQ_SOURCE_IMAGE }} | ||
- name: Get current version | ||
run: | | ||
set -eo pipefail | ||
# skopeo must always run to inspect image labels for build version | ||
skopeo inspect docker://${{ env.FQ_SOURCE_IMAGE }} > inspect.json | ||
ver=$(jq -r '.Labels["org.opencontainers.image.version"]' inspect.json) | ||
if [ -z "$ver" ] || [ "null" = "$ver" ]; then | ||
echo "inspected image version must not be empty or null" | ||
exit 1 | ||
fi | ||
if [ "main" == "${{ matrix.kernel_flavor }}" ]; then | ||
# main kernel_flavor: use ostree.linux to determine kernel version | ||
linux=$(jq -r '.Labels["ostree.linux"]' inspect.json) | ||
if [ -z "$ver" ] || [ "null" = "$ver" ]; then | ||
echo "inspected image version must not be empty or null" | ||
exit 1 | ||
fi | ||
if [ -z "$linux" ] || [ "null" = "$linux" ]; then | ||
echo "inspected image linux version must not be empty or null" | ||
exit 1 | ||
fi | ||
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV | ||
echo "SOURCE_IMAGE_LINUX=$linux" >> $GITHUB_ENV | ||
else | ||
# other kernel_flavor: start container use dnf to find kernel version | ||
container_name="fq-$(uuidgen)" | ||
podman run --entrypoint /bin/bash --name "$container_name" -dt "${{ env.FQ_SOURCE_IMAGE }}" | ||
podman exec $container_name rpm-ostree install dnf dnf-plugins-core | ||
# Fetch kernel version | ||
dnf="podman exec $container_name dnf" | ||
case "${{ matrix.kernel_flavor }}" in | ||
"asus") | ||
$dnf copr enable -y lukenukem/asus-kernel | ||
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:lukenukem:asus-kernel --whatprovides kernel | tail -n1 | sed 's/.*://') | ||
;; | ||
"fsync") | ||
$dnf copr enable -y sentry/kernel-fsync | ||
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:sentry:kernel-fsync --whatprovides kernel | tail -n1 | sed 's/.*://') | ||
;; | ||
"fsync-lts") | ||
$dnf copr enable -y sentry/kernel-ba | ||
linux=$($dnf repoquery --repoid copr:copr.fedorainfracloud.org:sentry:kernel-ba --whatprovides kernel | tail -n1 | sed 's/.*://') | ||
;; | ||
"main") | ||
linux=$($dnf repoquery --whatprovides kernel | tail -n1 | sed 's/.*://') | ||
;; | ||
"surface") | ||
$dnf config-manager --add-repo=https://pkg.surfacelinux.com/fedora/linux-surface.repo | ||
linux=$($dnf repoquery --repoid linux-surface --whatprovides kernel-surface | tail -n1 | sed 's/.*://') | ||
;; | ||
*) | ||
echo "unexpected kernel_flavor '${{ matrix.kernel_flavor }}' for dnf repoquery" | ||
;; | ||
esac | ||
fi | ||
if [ -z "$linux" ] || [ "null" = "$linux" ]; then | ||
echo "inspected image linux version must not be empty or null" | ||
exit 1 | ||
fi | ||
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV | ||
echo "KERNEL_VERSION=$linux" >> $GITHUB_ENV | ||
# Build metadata | ||
- name: Image Metadata | ||
uses: docker/metadata-action@v5 | ||
id: meta | ||
with: | ||
images: | | ||
${{ 'nvidia' == matrix.cfile_suffix && format('{0}-nvidia', env.IMAGE_NAME) || format('{0}', env.IMAGE_NAME) }} | ||
${{ env.IMAGE_NAME }} | ||
labels: | | ||
org.opencontainers.image.title=${{ env.IMAGE_NAME }} | ||
org.opencontainers.image.title=${{ env.IMAGE_BASE_NAME }} | ||
org.opencontainers.image.description=A caching layer for pre-built akmod RPMs | ||
org.opencontainers.image.version=${{ env.SOURCE_IMAGE_VERSION }} | ||
ostree.linux=${{ env.SOURCE_IMAGE_LINUX }} | ||
ostree.linux=${{ env.KERNEL_VERSION }} | ||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/main/README.md | ||
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/1728152?s=200&v=4 | ||
- name: Pull build image | ||
uses: Wandalen/[email protected] | ||
with: | ||
attempt_limit: 3 | ||
attempt_delay: 15000 | ||
command: | | ||
# pull the base image used for FROM in containerfile so | ||
# we can retry on that unfortunately common failure case | ||
podman pull quay.io/${{ env.SOURCE_ORG }}/${{ env.SOURCE_IMAGE }}:${{ matrix.fedora_version }} | ||
# Build image using Buildah action | ||
- name: Build Image | ||
id: build_image | ||
uses: redhat-actions/buildah-build@v2 | ||
with: | ||
containerfiles: | | ||
./Containerfile.${{ matrix.cfile_suffix }} | ||
image: ${{ 'nvidia' == matrix.cfile_suffix && format('{0}-nvidia', env.IMAGE_NAME) || format('{0}', env.IMAGE_NAME) }} | ||
image: ${{ env.IMAGE_NAME }} | ||
tags: | | ||
${{ steps.generate-tags.outputs.alias_tags }} | ||
build-args: | | ||
SOURCE_IMAGE=${{ env.SOURCE_IMAGE }} | ||
SOURCE_ORG=${{ env.SOURCE_ORG }} | ||
KERNEL_FLAVOR=${{ matrix.kernel_flavor }} | ||
KERNEL_VERSION=${{ env.KERNEL_VERSION }} | ||
FEDORA_MAJOR_VERSION=${{ matrix.fedora_version }} | ||
NVIDIA_MAJOR_VERSION=${{ matrix.nvidia_version }} | ||
RPMFUSION_MIRROR=${{ vars.RPMFUSION_MIRROR }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
oci: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters