This repository has been archived by the owner on Dec 11, 2023. It is now read-only.
Build Everything #127
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
name: Build Everything | |
on: | |
schedule: | |
- cron: "0 15 * * *" | |
workflow_dispatch: | |
inputs: | |
skip-build-base: | |
description: Enable to skip building Fedora and Universal Blue image | |
type: boolean | |
fedora-major-version: | |
description: Fedora major version | |
default: "39" | |
fedora-variant: | |
description: Fedora variant | |
default: kinoite | |
ublue-main-repo: | |
description: ublue-os/main repository to use | |
default: ublue-os/main | |
ublue-main-repo-ref: | |
description: ublue-os/main branch/commit to use | |
default: "" | |
ublue-flavor: | |
description: Universal Blue flavor | |
default: main | |
bazzite-repo: | |
description: ublue-os/bazzite repository to use | |
default: ublue-os/bazzite | |
bazzite-repo-ref: | |
description: ublue-os/bazzite branch/commit to use | |
default: "" | |
bazzite-variant: | |
description: Bazzite variant | |
default: bazzite-deck | |
env: | |
FEDORA_MAJOR_VERSION: ${{ github.event.inputs.fedora-major-version || '39' }} | |
FEDORA_VARIANT: ${{ github.event.inputs.fedora-variant || 'kinoite' }} | |
UBLUE_MAIN_REPO: ${{ github.event.inputs.ublue-main-repo || 'ublue-os/main' }} | |
UBLUE_FLAVOR: ${{ github.event.inputs.ublue-flavor || 'main' }} | |
BAZZITE_REPO: ${{ github.event.inputs.bazzite-repo || 'ublue-os/bazzite' }} | |
BAZZITE_VARIANT: ${{ github.event.inputs.bazzite-variant || 'bazzite-deck' }} | |
jobs: | |
# FIXME: Remove once https://github.com/ublue-os/main/commit/bfd786e8988faa374438d632fa1e34282a59a067 is reverted | |
build-fedora: | |
name: Build Fedora container image | |
if: ${{ github.event.inputs.skip-build-base != 'true' }} | |
permissions: | |
packages: write | |
runs-on: ubuntu-latest | |
container: | |
image: quay.io/fedora-ostree-desktops/buildroot:latest | |
options: --privileged | |
steps: | |
- name: Clone repository | |
run: git clone --branch f${{ env.FEDORA_MAJOR_VERSION }} --depth 1 --single-branch https://gitlab.com/fedora/ostree/ci-test.git . | |
- name: Verify CI script checksum | |
if: ${{ vars.FEDORA_SCRIPT_CHECKSUM }} | |
run: echo "${{ vars.FEDORA_SCRIPT_CHECKSUM }} .gitlab-ci.yml" | sha1sum -c - | |
- name: Build image | |
run: just compose-image ${{ env.FEDORA_VARIANT }} | |
- name: Upload image | |
run: | | |
skopeo login --username "${{ github.actor }}" --password "${{ github.token }}" ghcr.io | |
skopeo copy --retry-times 3 "oci-archive:fedora-${{ env.FEDORA_VARIANT }}.ociarchive" "docker://ghcr.io/${{ github.repository_owner }}/fedora-${{ env.FEDORA_VARIANT }}:${{ env.FEDORA_MAJOR_VERSION }}" | |
build-ublue: | |
name: Build Universal Blue container image | |
needs: build-fedora | |
if: ${{ github.event.inputs.skip-build-base != 'true' && !failure() && !cancelled() }} | |
permissions: | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Maximize build space | |
uses: ublue-os/remove-unwanted-software@v6 | |
- name: Fetch repository LICENSE information | |
uses: actions/github-script@v6 | |
id: license | |
env: | |
REPOSITORY: ${{ env.UBLUE_MAIN_REPO }} | |
with: | |
script: | | |
const { REPOSITORY } = process.env | |
const owner = REPOSITORY.split("/")[0] | |
const repo = REPOSITORY.split("/")[1] | |
const resp = await github.rest.repos.get({ | |
owner, | |
repo | |
}); | |
return resp.data.license.spdx_id | |
result-encoding: string | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.UBLUE_MAIN_REPO }} | |
ref: ${{ github.event.inputs.ublue-main-repo-ref }} | |
- name: Verify CI script checksum | |
if: ${{ vars.UBLUE_SCRIPT_CHECKSUM }} | |
run: echo "${{ vars.UBLUE_SCRIPT_CHECKSUM }} .github/workflows/build.yml" | sha1sum -c - | |
# FIXME: Remove once https://github.com/ublue-os/main/commit/bfd786e8988faa374438d632fa1e34282a59a067 is reverted | |
- name: Modify image source | |
run: sed -i 's,^ARG BASE_IMAGE="quay.io/\${SOURCE_ORG}/,ARG BASE_IMAGE="ghcr.io/${{ github.repository_owner }}/fedora-,g' ./Containerfile | |
- name: Generate build variables | |
shell: bash | |
run: | | |
echo "IMAGE_NAME=${{ env.FEDORA_VARIANT }}-${{ env.UBLUE_FLAVOR }}" >> $GITHUB_ENV | |
if [[ "${{ env.FEDORA_MAJOR_VERSION }}" -ge "39" ]] && \ | |
grep "${{ env.FEDORA_VARIANT }}" <<< "silverblue, kinoite, sericea"; then | |
echo "SOURCE_ORG=fedora" >> $GITHUB_ENV | |
echo "SOURCE_IMAGE=fedora-${{ env.FEDORA_VARIANT }}" >> $GITHUB_ENV | |
else | |
if [[ "${{ env.FEDORA_VARIANT }}" == "lxqt" || "${{ env.FEDORA_VARIANT }}" == "mate" ]]; then | |
echo "SOURCE_IMAGE=base" >> $GITHUB_ENV | |
else | |
echo "SOURCE_IMAGE=${{ env.FEDORA_VARIANT }}" >> $GITHUB_ENV | |
fi | |
echo "SOURCE_ORG=fedora-ostree-desktops" >> $GITHUB_ENV | |
fi | |
# FIXME: https://github.com/ublue-os/main/commit/4bec2a4283f17c8a2e3e0dfe4617e9bd23d90560 | |
if [[ "${{ env.FEDORA_MAJOR_VERSION }}" -ge "39" || "${{ env.UBLUE_FLAVOR }}" == "nokmods" ]]; then | |
echo "UBLUE_TARGET=nokmods" >> $GITHUB_ENV | |
else | |
echo "UBLUE_TARGET=kmods" >> $GITHUB_ENV | |
fi | |
- name: Get revision and base image version | |
id: labels | |
run: | | |
# FIXME: Update once https://github.com/ublue-os/main/commit/bfd786e8988faa374438d632fa1e34282a59a067 is reverted | |
ver=$(skopeo inspect docker://ghcr.io/${{ github.repository_owner }}/fedora-${{ env.FEDORA_VARIANT }}:${{ env.FEDORA_MAJOR_VERSION }} | jq -r '.Labels["org.opencontainers.image.version"]') | |
echo "VERSION=$ver" >> $GITHUB_OUTPUT | |
sha=$(git show --format=%H HEAD --quiet --) | |
echo "REVISION=$sha" >> $GITHUB_OUTPUT | |
- name: Generate image metadata | |
uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: ublue-${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.source=https://github.com/${{ env.UBLUE_MAIN_REPO }} | |
org.opencontainers.image.url=https://github.com/${{ env.UBLUE_MAIN_REPO }} | |
org.opencontainers.image.licenses=${{ steps.license.outputs.result }} | |
org.opencontainers.image.revision=${{ steps.labels.outputs.REVISION }} | |
org.opencontainers.image.title=${{ env.IMAGE_NAME }} | |
org.opencontainers.image.version=${{ steps.labels.outputs.VERSION }} | |
org.opencontainers.image.description=A base Universal Blue ${{ env.FEDORA_VARIANT }} image with batteries included | |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/main/main/README.md | |
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4 | |
- name: Build image | |
id: build_image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
containerfiles: | | |
./Containerfile | |
image: ublue-${{ env.IMAGE_NAME }} | |
tags: ${{ env.FEDORA_MAJOR_VERSION }} | |
# FIXME: Update SOURCE_IMAGE https://github.com/ublue-os/main/commit/bfd786e8988faa374438d632fa1e34282a59a067 is reverted | |
build-args: | | |
IMAGE_NAME=${{ env.FEDORA_VARIANT }} | |
SOURCE_ORG=${{ env.SOURCE_ORG }} | |
SOURCE_IMAGE=${{ env.FEDORA_VARIANT }} | |
FEDORA_MAJOR_VERSION=${{ env.FEDORA_MAJOR_VERSION }} | |
labels: ${{ steps.meta.outputs.labels }} | |
oci: false | |
extra-args: | | |
--target=${{ env.UBLUE_TARGET }} | |
- name: Upload image | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
image: ${{ steps.build_image.outputs.image }} | |
tags: ${{ steps.build_image.outputs.tags }} | |
registry: ghcr.io/${{ github.repository_owner }} | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
extra-args: | | |
--disable-content-trust | |
build-bazzite: | |
name: Build Bazzite container image | |
needs: build-ublue | |
if: ${{ always() && !failure() && !cancelled() }} | |
permissions: | |
packages: write | |
runs-on: ubuntu-latest | |
outputs: | |
image: ${{ steps.build_image.outputs.image }} | |
steps: | |
- name: Maximize build space | |
uses: ublue-os/remove-unwanted-software@v6 | |
- name: Fetch repository LICENSE information | |
uses: actions/github-script@v6 | |
id: license | |
env: | |
REPOSITORY: ${{ env.BAZZITE_REPO }} | |
with: | |
script: | | |
const { REPOSITORY } = process.env | |
const owner = REPOSITORY.split("/")[0] | |
const repo = REPOSITORY.split("/")[1] | |
const resp = await github.rest.repos.get({ | |
owner, | |
repo | |
}); | |
return resp.data.license.spdx_id | |
result-encoding: string | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ env.BAZZITE_REPO }} | |
ref: ${{ github.event.inputs.bazzite-repo-ref }} | |
- name: Verify CI script checksum | |
if: ${{ vars.BAZZITE_SCRIPT_CHECKSUM }} | |
run: echo "${{ vars.BAZZITE_SCRIPT_CHECKSUM }} .github/workflows/build.yml" | sha1sum -c - | |
- name: Modify image source | |
run: sed -i 's,^ARG BASE_IMAGE="ghcr.io/ublue-os/,ARG BASE_IMAGE="ghcr.io/${{ github.repository_owner }}/ublue-,g' ./Containerfile | |
- name: Generate build variables | |
run: | | |
echo "BASE_IMAGE_NAME=${{ env.FEDORA_VARIANT }}" >> $GITHUB_ENV | |
DESKTOP="" | |
if [[ "${{ env.FEDORA_VARIANT }}" == "silverblue" ]]; then | |
DESKTOP="-gnome" | |
fi | |
if [[ "${{ env.BAZZITE_VARIANT }}" == "bazzite-deck" ]]; then | |
if [[ "${{ env.UBLUE_FLAVOR }}" == "asus" ]]; then | |
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-ally', '${DESKTOP}') }}" >> $GITHUB_ENV | |
elif [[ "${{ env.UBLUE_FLAVOR }}" == "framework" ]]; then | |
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-framegame', '${DESKTOP}') }}" >> $GITHUB_ENV | |
else | |
echo "IMAGE_NAME=${{ format('{0}{1}', 'bazzite-deck', '${DESKTOP}') }}" >> $GITHUB_ENV | |
fi | |
else | |
if [[ "${{ env.UBLUE_FLAVOR }}" == "main" ]]; then | |
echo "IMAGE_NAME=${{ format('{0}{1}', env.BAZZITE_VARIANT, '${DESKTOP}') }}" >> $GITHUB_ENV | |
else | |
echo "IMAGE_NAME=${{ format('{0}{1}-{2}', env.BAZZITE_VARIANT, '${DESKTOP}', env.UBLUE_FLAVOR) }}" >> $GITHUB_ENV | |
fi | |
fi | |
if [[ "${{ env.UBLUE_FLAVOR }}" =~ "asus" ]]; then | |
echo "AKMODS_FLAVOR=asus" >> $GITHUB_ENV | |
elif [[ "${{ env.UBLUE_FLAVOR }}" =~ "surface" ]]; then | |
echo "AKMODS_FLAVOR=surface" >> $GITHUB_ENV | |
else | |
echo "AKMODS_FLAVOR=main" >> $GITHUB_ENV | |
fi | |
echo "BAZZITE_VENDOR=${{ env.BAZZITE_REPO }}" | cut -d'/' -f1 >> $GITHUB_ENV | |
- name: Get revision and base image version | |
id: labels | |
run: | | |
ver=$(skopeo inspect docker://ghcr.io/${{ github.repository_owner }}/ublue-${{ env.FEDORA_VARIANT }}-${{ env.UBLUE_FLAVOR }}:${{ env.FEDORA_MAJOR_VERSION }} | jq -r '.Labels["org.opencontainers.image.version"]') | |
echo "VERSION=$ver" >> $GITHUB_OUTPUT | |
sha=$(git show --format=%H HEAD --quiet --) | |
echo "REVISION=$sha" >> $GITHUB_OUTPUT | |
- name: Generate image metadata | |
uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: ublue-${{ env.IMAGE_NAME }} | |
labels: | | |
org.opencontainers.image.source=https://github.com/${{ env.BAZZITE_REPO }} | |
org.opencontainers.image.url=https://github.com/${{ env.BAZZITE_REPO }} | |
org.opencontainers.image.licenses=${{ steps.license.outputs.result }} | |
org.opencontainers.image.revision=${{ steps.labels.outputs.REVISION }} | |
org.opencontainers.image.title=${{ env.IMAGE_NAME }} | |
org.opencontainers.image.version=${{ steps.labels.outputs.VERSION }} | |
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. | |
io.artifacthub.package.readme-url=https://bazzite.gg/ | |
io.artifacthub.package.logo-url=https://raw.githubusercontent.com/ublue-os/bazzite/main/repo_content/logo.png | |
- name: Build image | |
id: build_image | |
uses: redhat-actions/buildah-build@v2 | |
with: | |
containerfiles: | | |
./Containerfile | |
image: ublue-${{ env.IMAGE_NAME }} | |
tags: ${{ env.FEDORA_MAJOR_VERSION }} latest | |
build-args: | | |
IMAGE_NAME=${{ env.IMAGE_NAME }} | |
IMAGE_FLAVOR=${{ env.UBLUE_FLAVOR }} | |
IMAGE_VENDOR=${{ env.BAZZITE_VENDOR }} | |
BASE_IMAGE_NAME=${{ env.FEDORA_VARIANT }} | |
FEDORA_MAJOR_VERSION=${{ env.FEDORA_MAJOR_VERSION }} | |
AKMODS_FLAVOR=${{ env.AKMODS_FLAVOR }} | |
labels: ${{ steps.meta.outputs.labels }} | |
oci: false | |
extra-args: | | |
--target=${{ env.BAZZITE_VARIANT }} | |
- name: Upload image to GHCR | |
uses: redhat-actions/push-to-registry@v2 | |
with: | |
image: ${{ steps.build_image.outputs.image }} | |
tags: ${{ steps.build_image.outputs.tags }} | |
registry: ghcr.io/${{ github.repository_owner }} | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
extra-args: | | |
--disable-content-trust | |
private-registry: | |
name: Upload image to private registry | |
needs: build-bazzite | |
if: ${{ always() && !failure() && !cancelled() }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Upload image to private registry | |
env: | |
PRIVATE_REGISTRY_DOCKER_REFERENCE_NAME: "${{ secrets.PRIVATE_REGISTRY_DOCKER_REFERENCE_NAME }}" | |
PRIVATE_REGISTRY_DOCKER_REFERENCE_TAG: "${{ secrets.PRIVATE_REGISTRY_DOCKER_REFERENCE_TAG }}" | |
if: ${{ env.PRIVATE_REGISTRY_DOCKER_REFERENCE_NAME && env.PRIVATE_REGISTRY_DOCKER_REFERENCE_TAG }} | |
run: skopeo copy --retry-times 10 --dest-creds "${{ secrets.PRIVATE_REGISTRY_USERNAME }}:${{ secrets.PRIVATE_REGISTRY_PASSWORD }}" docker://ghcr.io/${{ github.repository_owner }}/${{ needs.build-bazzite.outputs.image }}:latest docker://${{ env.PRIVATE_REGISTRY_DOCKER_REFERENCE_NAME }}:${{ env.PRIVATE_REGISTRY_DOCKER_REFERENCE_TAG }} |