2023-08-26 02:06:51 -07:00
name : Build Bazzite
2023-02-09 11:08:39 -08:00
on :
2023-06-18 19:22:17 +00:00
schedule :
2024-07-22 19:30:15 -07:00
- cron : "40 4 * * 2,5" # 4:40 utc tues thurs
2023-02-09 11:08:39 -08:00
pull_request :
branches :
2023-11-20 09:54:13 -07:00
- testing
- unstable
2023-06-18 19:22:17 +00:00
paths-ignore :
2024-07-22 19:30:15 -07:00
- "**.md"
- "**.txt"
- "installer/**"
- "repo_content/**"
- "spec_files/**"
- "post_install_files/**"
- "press_kit/**"
- ".github/workflows/build_iso.yml"
2023-02-09 11:08:39 -08:00
push :
branches :
2023-11-01 12:25:24 -06:00
- testing
- unstable
2023-06-18 19:22:17 +00:00
paths-ignore :
2024-07-22 19:30:15 -07:00
- "**.md"
- "**.txt"
- "repo_content/**"
- "spec_files/**"
- "post_install_files/**"
- "press_kit/**"
- ".github/workflows/build_iso.yml"
2023-06-18 19:22:17 +00:00
merge_group :
workflow_dispatch :
2023-02-09 11:08:39 -08:00
env :
2023-11-01 12:25:24 -06:00
IMAGE_REGISTRY : ghcr.io/${{ github.repository_owner }}
2023-02-09 11:08:39 -08:00
2023-11-05 08:31:41 -08:00
concurrency :
group : ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress : true
2023-02-09 11:08:39 -08:00
jobs :
push-ghcr :
2023-09-28 17:27:53 -07:00
name : Make
2024-05-16 08:28:10 -06:00
runs-on : ubuntu-24.04
2024-04-02 12:15:26 -05:00
continue-on-error : false
2023-02-09 11:08:39 -08:00
permissions :
contents : read
packages : write
id-token : write
strategy :
fail-fast : false
matrix :
2024-04-22 12:15:28 -05:00
base_image_flavor : [ main]
2023-11-30 08:48:31 -07:00
base_name : [ bazzite, bazzite-deck, bazzite-nvidia]
2023-08-01 19:07:29 -06:00
base_image_name : [ kinoite, silverblue]
2024-04-22 12:15:28 -05:00
target_image_flavor : [ main, asus]
fedora_version : [ 40 ]
2023-02-09 11:08:39 -08:00
include :
2024-04-22 12:15:28 -05:00
- fedora_version : 40
2023-10-13 14:35:10 -06:00
is_latest_version : true
2023-06-18 19:22:17 +00:00
is_stable_version : true
2024-07-22 19:30:15 -07:00
kernel_flavor : fsync # must match a kernel_flavor from akmods repo
2023-05-23 13:11:45 -06:00
steps :
2024-04-22 12:15:28 -05:00
- name : Define env.IMAGE_FLAVOR
2023-06-18 19:22:17 +00:00
run : |
2023-11-30 08:48:31 -07:00
if [[ "${{ matrix.base_name }}" == "bazzite-nvidia" ]]; then
2024-04-22 12:15:28 -05:00
if [[ "${{ matrix.target_image_flavor }}" == "main" ]]; then
2023-11-30 08:48:31 -07:00
echo "IMAGE_FLAVOR=nvidia" >> $GITHUB_ENV
else
2024-04-22 12:15:28 -05:00
echo "IMAGE_FLAVOR=${{ format('{0}-{1}', matrix.target_image_flavor, 'nvidia') }}" >> $GITHUB_ENV
2023-11-30 08:48:31 -07:00
fi
else
2024-04-22 12:15:28 -05:00
echo "IMAGE_FLAVOR=${{ matrix.target_image_flavor }}" >> $GITHUB_ENV
2023-11-30 08:48:31 -07:00
fi
2024-04-22 12:15:28 -05:00
- name : Define env.IMAGE_NAME
2023-11-30 08:48:31 -07:00
run : |
2023-11-30 18:36:32 -07:00
DESKTOP=""
if [[ "${{ matrix.base_image_name }}" == "silverblue" ]]; then
DESKTOP="-gnome"
fi
2023-09-28 20:29:19 -06:00
if [[ "${{ matrix.base_name }}" == "bazzite-deck" ]]; then
2024-04-22 12:15:28 -05:00
if [[ "${{ matrix.target_image_flavor }}" == "asus" ]]; then
2023-09-28 20:29:19 -06:00
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-ally', '${DESKTOP}') }}" >> $GITHUB_ENV
2023-08-01 19:07:29 -06:00
else
2023-09-28 20:29:19 -06:00
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-deck', '${DESKTOP}') }}" >> $GITHUB_ENV
2023-08-01 19:07:29 -06:00
fi
2023-06-18 19:22:17 +00:00
else
2023-11-30 08:48:31 -07:00
if [[ "${{ env.IMAGE_FLAVOR }}" == "main" ]]; then
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite', '${DESKTOP}') }}" >> $GITHUB_ENV
2023-08-01 19:07:29 -06:00
else
2023-11-30 08:48:31 -07:00
echo "IMAGE_NAME=${{ format('{0}{1}-{2}', 'bazzite', '${DESKTOP}', env.IMAGE_FLAVOR) }}" >> $GITHUB_ENV
2023-08-01 19:07:29 -06:00
fi
2023-06-18 19:22:17 +00:00
fi
2024-07-13 09:49:22 -07:00
- name : Define env.SHA_HEAD_SHORT
run : |
echo "SHA_HEAD_SHORT=${GITHUB_SHA::7}" >> $GITHUB_ENV
2024-04-22 12:15:28 -05:00
- name : Verify main image
2024-07-15 11:06:57 -04:00
uses : EyeCantCU/cosign-action/verify@v0.3.0
2024-04-22 12:15:28 -05:00
with :
containers : ${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }}
pubkey : https://raw.githubusercontent.com/ublue-os/${{ matrix.base_image_flavor }}/main/cosign.pub
registry : ${{ env.IMAGE_REGISTRY }}
- name : Verify akmods image
2024-07-15 11:06:57 -04:00
uses : EyeCantCU/cosign-action/verify@v0.3.0
2024-04-22 12:15:28 -05:00
with :
2024-06-27 09:41:57 -07:00
containers : akmods:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}
pubkey : https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
2024-04-22 12:15:28 -05:00
registry : ${{ env.IMAGE_REGISTRY }}
2024-06-27 09:41:57 -07:00
- name : Verify akmods-nvidia image
2024-07-15 11:06:57 -04:00
uses : EyeCantCU/cosign-action/verify@v0.3.0
2024-04-22 12:15:28 -05:00
with :
2024-06-27 09:41:57 -07:00
containers : akmods-nvidia:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}
pubkey : https://raw.githubusercontent.com/ublue-os/akmods/main/cosign.pub
2024-04-22 12:15:28 -05:00
registry : ${{ env.IMAGE_REGISTRY }}
# Checkout push-to-registry action GitHub repository
- name : Checkout Push to Registry action
uses : actions/checkout@v4
- name : Check just syntax
uses : ublue-os/just-action@v1
- name : Maximize build space
2024-05-16 10:43:05 -06:00
uses : ublue-os/remove-unwanted-software@v7
2024-04-22 12:15:28 -05:00
2023-06-18 19:22:17 +00:00
- name : Generate tags
id : generate-tags
shell : bash
run : |
# Generate a timestamp for creating an image version history
TIMESTAMP="$(date +%Y%m%d)"
2024-04-22 12:15:28 -05:00
FEDORA_VERSION="${{ matrix.fedora_version }}"
2023-06-18 19:22:17 +00:00
COMMIT_TAGS=()
BUILD_TAGS=()
# Have tags for tracking builds during pull request
SHA_SHORT="${GITHUB_SHA::7}"
2024-04-22 12:15:28 -05:00
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}-${FEDORA_VERSION}")
COMMIT_TAGS+=("${SHA_SHORT}-${FEDORA_VERSION}")
2023-06-18 19:22:17 +00:00
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[ [ "${{ matrix.is_stable_version }}" == "true" ]]; then
2023-08-16 15:17:13 -06:00
COMMIT_TAGS+=("pr-${{ github.event.pull_request.number }}")
2023-06-18 19:22:17 +00:00
COMMIT_TAGS+=("${SHA_SHORT}")
fi
2023-11-01 12:25:24 -06:00
if [[ ${{ github.ref_name }} == "unstable" ]]; then
2024-04-22 12:15:28 -05:00
BUILD_TAGS=("${FEDORA_VERSION}-unstable" "${FEDORA_VERSION}-unstable-${TIMESTAMP}")
2023-11-01 12:25:24 -06:00
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[ [ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("unstable")
2024-05-18 16:04:02 -06:00
echo "DEFAULT_TAG=unstable" >> $GITHUB_ENV
2023-11-01 12:25:24 -06:00
fi
elif [[ ${{ github.ref_name }} == "testing" ]]; then
2024-04-22 12:15:28 -05:00
BUILD_TAGS=("${FEDORA_VERSION}-testing" "${FEDORA_VERSION}-testing-${TIMESTAMP}")
2023-11-01 12:25:24 -06:00
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[ [ "${{ matrix.is_stable_version }}" == "true" ]]; then
BUILD_TAGS+=("testing")
2024-05-18 16:04:02 -06:00
echo "DEFAULT_TAG=testing" >> $GITHUB_ENV
2023-11-01 12:25:24 -06:00
fi
else
2024-04-22 12:15:28 -05:00
BUILD_TAGS=("${FEDORA_VERSION}" "${FEDORA_VERSION}-${TIMESTAMP}")
BUILD_TAGS+=("${FEDORA_VERSION}-stable" "${FEDORA_VERSION}-stable-${TIMESTAMP}")
2023-11-01 12:25:24 -06:00
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
[ [ "${{ matrix.is_stable_version }}" == "true" ]]; then
2024-01-24 19:45:34 -07:00
BUILD_TAGS+=("latest" "stable")
2024-05-18 16:04:02 -06:00
echo "DEFAULT_TAG=latest" >> $GITHUB_ENV
2023-11-01 12:25:24 -06:00
fi
2023-06-18 19:22:17 +00:00
fi
2023-08-29 08:31:51 -06:00
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
2023-06-18 19:22:17 +00:00
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
2024-04-22 12:15:28 -05:00
- name : Pull main and akmods images
2024-05-13 13:56:45 -07:00
uses : Wandalen/wretry.action@v3.5.0
2024-04-22 12:15:28 -05:00
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.IMAGE_REGISTRY }}/${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }}
2024-06-27 09:41:57 -07:00
podman pull ${{ env.IMAGE_REGISTRY }}/akmods:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}
podman pull ${{ env.IMAGE_REGISTRY }}/akmods-nvidia:${{ matrix.kernel_flavor}}-${{ matrix.fedora_version }}
2024-04-22 12:15:28 -05:00
2024-04-27 14:42:15 -05:00
- name : Get source versions
2023-03-30 05:18:47 +00:00
id : labels
2024-05-13 13:56:45 -07:00
uses : Wandalen/wretry.action@v3.5.0
2024-04-27 14:42:15 -05:00
with :
attempt_limit : 3
attempt_delay : 15000
command : |
set -eo pipefail
2024-04-27 15:33:32 -05:00
skopeo inspect docker://${{ env.IMAGE_REGISTRY }}/${{ matrix.base_image_name }}-${{ matrix.base_image_flavor }}:${{ matrix.fedora_version }} > source.json
2024-04-27 14:42:15 -05:00
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
2024-06-27 09:41:57 -07:00
skopeo inspect docker://${{ env.IMAGE_REGISTRY }}/akmods:${{ matrix.kernel_flavor }}-${{ matrix.fedora_version }} > akmods.json
2024-04-27 14:42:15 -05:00
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
2023-03-30 05:18:47 +00:00
2023-02-15 13:48:36 -08:00
# Build metadata
- name : Image Metadata
2023-09-18 11:54:29 +00:00
uses : docker/metadata-action@v5
2023-02-15 13:48:36 -08:00
id : meta
with :
images : |
2023-06-18 19:22:17 +00:00
${{ env.IMAGE_NAME }}
2023-02-15 13:48:36 -08:00
labels : |
2023-06-18 19:22:17 +00:00
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
2023-09-22 17:10:52 -07:00
org.opencontainers.image.description=Bazzite is an OCI image that serves as an alternative operating system for the Steam Deck, and a ready-to-game SteamOS-like for desktop computers, living room home theater PCs, and numerous other handheld PCs.
2024-04-27 14:42:15 -05:00
org.opencontainers.image.version=${{ env.SOURCE_IMAGE_VERSION }}
ostree.linux=${{ env.KERNEL_VERSION }}
2023-09-22 17:10:52 -07:00
io.artifacthub.package.readme-url=https://bazzite.gg/
2023-07-18 00:19:12 -07:00
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/ublue-os/bazzite/main/repo_content/logo.png
2023-02-09 11:08:39 -08:00
# Build image using Buildah action
- name : Build Image
id : build_image
2024-02-14 22:14:03 -08:00
uses : redhat-actions/buildah-build@v2
2023-02-09 11:08:39 -08:00
with :
containerfiles : |
2023-06-18 19:22:17 +00:00
./Containerfile
image : ${{ env.IMAGE_NAME }}
2023-02-09 11:08:39 -08:00
tags : |
${{ steps.generate-tags.outputs.alias_tags }}
build-args : |
2023-06-18 19:22:17 +00:00
IMAGE_NAME=${{ env.IMAGE_NAME }}
2023-11-30 08:48:31 -07:00
IMAGE_FLAVOR=${{ env.IMAGE_FLAVOR }}
2023-10-20 19:01:52 +02:00
IMAGE_VENDOR=${{ github.repository_owner }}
2023-08-01 19:07:29 -06:00
BASE_IMAGE_NAME=${{ matrix.base_image_name }}
2024-04-22 12:15:28 -05:00
BASE_IMAGE_FLAVOR=${{ matrix.base_image_flavor }}
FEDORA_VERSION=${{ matrix.fedora_version }}
KERNEL_FLAVOR=${{ matrix.kernel_flavor }}
2024-01-05 17:59:55 -08:00
IMAGE_BRANCH=${{ github.ref_name }}
2024-07-13 09:49:22 -07:00
SHA_HEAD_SHORT=${{ env.SHA_HEAD_SHORT }}
2023-02-15 13:48:36 -08:00
labels : ${{ steps.meta.outputs.labels }}
oci : false
2023-06-18 19:22:17 +00:00
extra-args : |
--target=${{ matrix.base_name }}
2023-02-09 11:08:39 -08:00
2024-07-22 19:30:15 -07:00
- name : Check Secureboot
shell : bash
run : |
set -x
if [[ ! $(command -v sbverify) || ! $(command -v curl) || ! $(command -v openssl) ]]; then
sudo apt update
sudo apt install sbsigntool curl openssl
fi
podman run -d --rm --name ${{env.IMAGE_NAME}}-$(echo "${{ steps.generate-tags.outputs.alias_tags }}" | cut -d " " -f 1) "${{ env.IMAGE_NAME }}":$(echo "${{ steps.generate-tags.outputs.alias_tags }}" | cut -d " " -f 1) sleep 1000
podman cp ${{env.IMAGE_NAME}}-$(echo "${{ steps.generate-tags.outputs.alias_tags }}" | cut -d " " -f 1):/usr/lib/modules/${{ env.KERNEL_VERSION }}/vmlinuz .
podman rm -f ${{env.IMAGE_NAME}}-$(echo "${{ steps.generate-tags.outputs.alias_tags }}" | cut -d " " -f 1)
sbverify --list vmlinuz
curl --retry 3 -Lo kernel-sign.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key.der
curl --retry 3 -Lo akmods.der https://github.com/ublue-os/kernel-cache/raw/main/certs/public_key_2.der
openssl x509 -in kernel-sign.der -out kernel-sign.crt
openssl x509 -in akmods.der -out akmods.crt
sbverify --cert kernel-sign.crt vmlinuz || exit 1
sbverify --cert akmods.crt vmlinuz || exit 1
2023-02-09 11:08:39 -08:00
# 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
2023-10-30 12:30:50 -07:00
uses : ASzc/change-string-case-action@v6
2023-02-09 11:08:39 -08:00
with :
string : ${{ env.IMAGE_REGISTRY }}
# Push the image to GHCR (Image Registry)
- name : Push To GHCR
2024-05-13 13:56:45 -07:00
uses : Wandalen/wretry.action@v3.5.0
2023-02-09 11:08:39 -08:00
id : push
2023-08-29 08:31:51 -06:00
if : github.event_name != 'pull_request'
2023-02-09 11:08:39 -08:00
env :
REGISTRY_USER : ${{ github.actor }}
REGISTRY_PASSWORD : ${{ github.token }}
with :
2024-04-22 12:15:28 -05:00
action : redhat-actions/push-to-registry@v2
attempt_limit : 3
attempt_delay : 15000
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 : |
2024-07-30 14:01:58 -07:00
--compression-format=zstd:chunked
2023-06-18 19:22:17 +00:00
2023-03-04 16:45:59 -08:00
- name : Sign container image
2024-07-15 11:06:57 -04:00
uses : EyeCantCU/cosign-action/sign@v0.3.0
2023-08-29 08:31:51 -06:00
if : github.event_name != 'pull_request'
2023-12-18 21:06:05 -07:00
with :
2023-12-24 07:46:02 -07:00
containers : ${{ env.IMAGE_NAME }}
2023-12-18 21:06:05 -07:00
registry-token : ${{ secrets.GITHUB_TOKEN }}
signing-secret : ${{ secrets.SIGNING_SECRET }}
2024-04-22 13:05:44 -05:00
tags : ${{ steps.push.outputs.outputs && fromJSON(steps.push.outputs.outputs).digest }}
2023-02-09 11:08:39 -08:00
- name : Echo outputs
2023-08-29 08:31:51 -06:00
if : github.event_name != 'pull_request'
2023-02-09 11:08:39 -08:00
run : |
2023-03-30 05:18:47 +00:00
echo "${{ toJSON(steps.push.outputs) }}"
2024-04-02 12:15:26 -05:00
build_iso :
name : build iso
needs : [ push-ghcr]
if : github.ref_name == 'testing'
# Eventually would be nice for building images in PRs
#if: ${{ endsWith(github.event.pull_request.title, '[ISO]') }}
uses : ./.github/workflows/build_iso.yml
secrets : inherit