Skip to content

build-quantix

build-quantix #96

Workflow file for this run

name: Build Quantix
on:
schedule:
- cron: '30 17 * * 1,3,5' # 17:30 Monday/Wednesday/Friday
pull_request:
branches:
- testing
paths-ignore:
- '**.md'
- '**.txt'
- 'repo_content/**'
push:
branches:
- testing
paths-ignore:
- '**.md'
- '**.txt'
- 'repo_content/**'
merge_group:
workflow_dispatch:
env:
BASE_IMAGE_REGISTRY: ghcr.io/ublue-os
BASE_IMAGE_NAME: kinoite
BASE_IMAGE_FLAVOR: main
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
FEDORA_VERSION: 40
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
push-ghcr:
name: Build
runs-on: ubuntu-24.04
continue-on-error: false
permissions:
contents: read
packages: write
id-token: write
strategy:
fail-fast: false
matrix:
base_name: [quantix, quantix-nvidia]
include:
- is_latest_version: true
is_stable_version: true
kernel_flavor: fsync # must match a kernel_flavor from akmods repo
steps:
- name: Define env.IMAGE_FLAVOR
run: |
if [[ "${{ matrix.base_name }}" == "quantix-nvidia" ]]; then
echo "IMAGE_FLAVOR=nvidia" >> $GITHUB_ENV
else
echo "IMAGE_FLAVOR=${{ env.BASE_IMAGE_FLAVOR }}" >> $GITHUB_ENV
fi
- name: Define env.IMAGE_NAME
run: |
if [[ "${{ env.IMAGE_FLAVOR }}" == "main" ]]; then
echo "IMAGE_NAME=${{ format('{0}', 'quantix') }}" >> $GITHUB_ENV
else
echo "IMAGE_NAME=${{ format('{0}-{1}', 'quantix', env.IMAGE_FLAVOR) }}" >> $GITHUB_ENV
fi
- name: Verify main image
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: ${{ env.BASE_IMAGE_NAME }}-${{ env.IMAGE_FLAVOR }}:${{ env.FEDORA_VERSION }}
pubkey: https://raw.githubusercontent.com/ublue-os/${{ env.IMAGE_FLAVOR }}/main/cosign.pub
registry: ${{ env.BASE_IMAGE_REGISTRY }}
- name: Verify akmods image
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: akmods:${{ matrix.kernel_flavor}}-${{ env.FEDORA_VERSION }}
pubkey: https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
registry: ${{ env.BASE_IMAGE_REGISTRY }}
- name: Verify akmods-extra image
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: akmods-extra:${{ matrix.kernel_flavor}}-${{ env.FEDORA_VERSION }}
pubkey: https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
registry: ${{ env.BASE_IMAGE_REGISTRY }}
- name: Verify akmods-nvidia image
uses: EyeCantCU/cosign-action/verify@v0.2.2
with:
containers: akmods-nvidia:${{ matrix.kernel_flavor}}-${{ env.FEDORA_VERSION }}
pubkey: https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
registry: ${{ env.BASE_IMAGE_REGISTRY }}
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
uses: actions/checkout@v4
- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v7
- name: Generate tags
id: generate-tags
shell: bash
run: |
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
FEDORA_VERSION="${{ env.FEDORA_VERSION }}"
COMMIT_TAGS=()
BUILD_TAGS=()
# Have tags for tracking builds during pull request
SHA_SHORT="${GITHUB_SHA::7}"
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}-${FEDORA_VERSION}")
COMMIT_TAGS+=("${SHA_SHORT}-${FEDORA_VERSION}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}")
COMMIT_TAGS+=("${SHA_SHORT}")
fi
if [[ ${{ github.ref_name }} == "testing" ]]; then
BUILD_TAGS=("${FEDORA_VERSION}-testing" "${FEDORA_VERSION}-testing-${TIMESTAMP}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("testing")
echo "DEFAULT_TAG=testing" >> $GITHUB_ENV
fi
else
BUILD_TAGS=("${FEDORA_VERSION}" "${FEDORA_VERSION}-${TIMESTAMP}")
BUILD_TAGS+=("${FEDORA_VERSION}-stable" "${FEDORA_VERSION}-stable-${TIMESTAMP}")
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("latest" "stable")
echo "DEFAULT_TAG=latest" >> $GITHUB_ENV
fi
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "Generated the following commit tags: "
for TAG in "${COMMIT_TAGS[@]}"; do
echo "${TAG}"
done
alias_tags=("${COMMIT_TAGS[@]}")
else
alias_tags=("${BUILD_TAGS[@]}")
fi
echo "Generated the following build tags: "
for TAG in "${BUILD_TAGS[@]}"; do
echo "${TAG}"
done
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
- name: Pull main and akmods images
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 3
attempt_delay: 15000
command: |
# pull the base images used for FROM in Containerfile so
# we can retry on that unfortunately common failure case
podman pull ${{ env.BASE_IMAGE_REGISTRY }}/${{ env.BASE_IMAGE_NAME }}-${{ env.BASE_IMAGE_FLAVOR }}:${{ env.FEDORA_VERSION }}
podman pull ${{ env.BASE_IMAGE_REGISTRY }}/akmods:${{ matrix.kernel_flavor}}-${{ env.FEDORA_VERSION }}
podman pull ${{ env.BASE_IMAGE_REGISTRY }}/akmods-extra:${{ matrix.kernel_flavor}}-${{ env.FEDORA_VERSION }}
podman pull ${{ env.BASE_IMAGE_REGISTRY }}/akmods-nvidia:${{ matrix.kernel_flavor}}-${{ env.FEDORA_VERSION }}
- name: Get source versions
id: labels
uses: Wandalen/wretry.action@v3.5.0
with:
attempt_limit: 3
attempt_delay: 15000
command: |
set -eo pipefail
skopeo inspect docker://${{ env.BASE_IMAGE_REGISTRY }}/${{ env.BASE_IMAGE_NAME }}-${{ env.BASE_IMAGE_FLAVOR }}:${{ env.FEDORA_VERSION }} > source.json
ver=$(jq -r '.Labels["org.opencontainers.image.version"]' source.json)
if [ -z "$ver" ] || [ "null" = "$ver" ]; then
echo "inspected image version must not be empty or null"
exit 1
fi
echo "SOURCE_IMAGE_VERSION=$ver" >> $GITHUB_ENV
skopeo inspect docker://${{ env.BASE_IMAGE_REGISTRY }}/akmods:${{ matrix.kernel_flavor }}-${{ env.FEDORA_VERSION }} > akmods.json
linux=$(jq -r '.Labels["ostree.linux"]' akmods.json)
if [ -z "$linux" ] || [ "null" = "$linux" ]; then
echo "inspected image linux version must not be empty or null"
exit 1
fi
echo "KERNEL_VERSION=$linux" >> $GITHUB_ENV
# Build metadata
- name: Image Metadata
uses: docker/metadata-action@v5
id: meta
with:
images: |
${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.description=Modified version of Bazzite by EpicOfficer.
org.opencontainers.image.version=${{ env.SOURCE_IMAGE_VERSION }}
ostree.linux=${{ env.KERNEL_VERSION }}
# Build image using Buildah action
- name: Build Image
id: build_image
uses: redhat-actions/buildah-build@v2
with:
containerfiles: |
./Containerfile
image: ${{ env.IMAGE_NAME }}
tags: |
${{ steps.generate-tags.outputs.alias_tags }}
build-args: |
IMAGE_NAME=${{ env.IMAGE_NAME }}
IMAGE_FLAVOR=${{ env.IMAGE_FLAVOR }}
IMAGE_VENDOR=${{ github.repository_owner }}
BASE_IMAGE_NAME=${{ env.BASE_IMAGE_NAME }}
BASE_IMAGE_FLAVOR=${{ env.BASE_IMAGE_FLAVOR }}
FEDORA_VERSION=${{ env.FEDORA_VERSION }}
KERNEL_FLAVOR=${{ matrix.kernel_flavor }}
IMAGE_BRANCH=${{ github.ref_name }}
labels: ${{ steps.meta.outputs.labels }}
oci: false
extra-args: |
--target=${{ matrix.base_name }}
# Workaround bug where capital letters in your GitHub username make it impossible to push to GHCR.
# https://github.com/macbre/push-to-ghcr/issues/12
- name: Lowercase Registry
id: registry_case
uses: ASzc/change-string-case-action@v6
with:
string: ${{ env.IMAGE_REGISTRY }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Image to GHCR
uses: redhat-actions/push-to-registry@v2
id: push
env:
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ steps.registry_case.outputs.lowercase }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
extra-args: |
--disable-content-trust
# Sign container
- uses: sigstore/cosign-installer@v3.5.0
if: github.event_name != 'pull_request'
- name: Sign container image
if: github.event_name != 'pull_request'
run: |
cosign sign -y --key env://COSIGN_PRIVATE_KEY ${{ steps.registry_case.outputs.lowercase }}/${{ steps.build_image.outputs.image }}@${TAGS}
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
- name: Echo outputs
if: github.event_name != 'pull_request'
run: |
echo "${{ toJSON(steps.push.outputs) }}"