Skip to content

Commit

Permalink
Merge branch 'main' into fedora-41-builds
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 authored Sep 26, 2024
2 parents 26159cc + 013738f commit 83f3da5
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .github/actions/build-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ runs:
run: |
echo "image=${{ inputs.image-name }}" >> $GITHUB_OUTPUT
if [ "$BUILDER" == "podman" ]; then
# Reading space-separated list into an array
IFS=' ' read -r -a tag_array <<< "${{ inputs.image-tags }}"
single_tag="${tag_array[0]}"
echo "tags=${{ inputs.image-tags }}" >> $GITHUB_OUTPUT
digest=$(podman image inspect ${{ inputs.image-name }} --format '{{.Digest}}')
digest=$(podman image inspect ${{ inputs.image-name }}:$single_tag --format '{{.Digest}}')
echo "digest=$digest" >> $GITHUB_OUTPUT
else
echo "tags=${{ inputs.image-tags }}" >> $GITHUB_OUTPUT
Expand Down
48 changes: 42 additions & 6 deletions .github/actions/generate-image-tags/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ outputs:
primary-name-full:
description: 'Full name of the OCI image with primary tag'
value: ${{ steps.set-outputs.outputs.PRIMARY_NAME_FULL }}
stable-tag:
description: 'Stable tag for the OCI image'
value: ${{ steps.set-outputs.outputs.STABLE_TAG }}
stable-name-full:
description: 'Full name of the OCI image with stable tag'
value: ${{ steps.set-outputs.outputs.STABLE_NAME_FULL }}

runs:
using: composite
Expand All @@ -53,9 +59,10 @@ runs:
run: |
echo "Generating tags for pull request..."
STABLE_TAG_PRE_SUFFIX="pr$PR_NUMBER-$MAJOR_VERSION"
PRIMARY_TAG_PRE_SUFFIX="pr$PR_NUMBER-$(git rev-parse --short HEAD)-$MAJOR_VERSION"
TAGS_PRE_SUFFIX=(
"pr$PR_NUMBER-$MAJOR_VERSION"
"pr$PR_NUMBER-$(git rev-parse --short HEAD)-$MAJOR_VERSION"
)
TAG_SUFFIXES=()
Expand All @@ -78,16 +85,27 @@ runs:
fi
done
PRIMARY_TAG="pr$PR_NUMBER-$(git rev-parse --short HEAD)-$MAJOR_VERSION"
if [[ "$IS_NVIDIA_DRIVER" == true ]]; then
PRIMARY_TAG="$PRIMARY_TAG-nvidia"
STABLE_TAG="$STABLE_TAG_PRE_SUFFIX-nvidia"
else
STABLE_TAG="$STABLE_TAG_PRE_SUFFIX"
fi
echo "Generated stable tag: $STABLE_TAG"
TAGS+=("$STABLE_TAG")
if [[ "$IS_NVIDIA_DRIVER" == true ]]; then
PRIMARY_TAG="$PRIMARY_TAG_PRE_SUFFIX-nvidia"
else
PRIMARY_TAG="$PRIMARY_TAG_PRE_SUFFIX"
fi
echo "Generated primary tag: $PRIMARY_TAG"
TAGS+=("$PRIMARY_TAG")
echo "Generated tags: ${TAGS[*]}"
echo "TAGS=${TAGS[*]}" >> "$GITHUB_OUTPUT"
echo "TAGS_CONCAT=$(IFS=, ; echo "${TAGS[*]}")" >> "$GITHUB_OUTPUT"
echo "PRIMARY_TAG=$PRIMARY_TAG" >> "$GITHUB_OUTPUT"
echo "STABLE_TAG=$STABLE_TAG" >> "$GITHUB_OUTPUT"
NAMES_FULL=()
for TAG in "${TAGS[@]}"; do
Expand All @@ -98,6 +116,7 @@ runs:
echo "NAMES_FULL=${NAMES_FULL[*]}" >> "$GITHUB_OUTPUT"
echo "NAMES_FULL_CONCAT=$(IFS=, ; echo "${NAMES_FULL[*]}")" >> "$GITHUB_OUTPUT"
echo "PRIMARY_NAME_FULL=$IMAGE_NAME:$PRIMARY_TAG" >> "$GITHUB_OUTPUT"
echo "STABLE_NAME_FULL=$IMAGE_NAME:$STABLE_TAG" >> "$GITHUB_OUTPUT"
- name: Generate Tags
if: inputs.is-release == 'true'
Expand All @@ -111,9 +130,10 @@ runs:
run: |
echo "Generating tags for release..."
STABLE_TAG_PRE_SUFFIX="$MAJOR_VERSION"
PRIMARY_TAG_PRE_SUFFIX="$(git rev-parse --short HEAD)-$MAJOR_VERSION"
TAGS_PRE_SUFFIX=(
"$MAJOR_VERSION"
"$(git rev-parse --short HEAD)-$MAJOR_VERSION"
)
TAG_SUFFIXES=()
Expand All @@ -136,16 +156,27 @@ runs:
fi
done
PRIMARY_TAG="$(git rev-parse --short HEAD)-$MAJOR_VERSION"
if [[ "$IS_NVIDIA_DRIVER" == true ]]; then
PRIMARY_TAG="$PRIMARY_TAG-nvidia"
STABLE_TAG="$STABLE_TAG_PRE_SUFFIX-nvidia"
else
STABLE_TAG="$STABLE_TAG_PRE_SUFFIX"
fi
echo "Generated stable tag: $STABLE_TAG"
TAGS+=("$STABLE_TAG")
if [[ "$IS_NVIDIA_DRIVER" == true ]]; then
PRIMARY_TAG="$PRIMARY_TAG_PRE_SUFFIX-nvidia"
else
PRIMARY_TAG="$PRIMARY_TAG_PRE_SUFFIX"
fi
echo "Generated primary tag: $PRIMARY_TAG"
TAGS+=("$PRIMARY_TAG")
echo "Generated tags: ${TAGS[*]}"
echo "TAGS=${TAGS[*]}" >> "$GITHUB_OUTPUT"
echo "TAGS_CONCAT=$(IFS=, ; echo "${TAGS[*]}")" >> "$GITHUB_OUTPUT"
echo "PRIMARY_TAG=$PRIMARY_TAG" >> "$GITHUB_OUTPUT"
echo "STABLE_TAG=$STABLE_TAG" >> "$GITHUB_OUTPUT"
NAMES_FULL=()
for TAG in "${TAGS[@]}"; do
Expand All @@ -156,6 +187,7 @@ runs:
echo "NAMES_FULL=${NAMES_FULL[*]}" >> "$GITHUB_OUTPUT"
echo "NAMES_FULL_CONCAT=$(IFS=, ; echo "${NAMES_FULL[*]}")" >> "$GITHUB_OUTPUT"
echo "PRIMARY_NAME_FULL=$IMAGE_NAME:$PRIMARY_TAG" >> "$GITHUB_OUTPUT"
echo "STABLE_NAME_FULL=$IMAGE_NAME:$STABLE_TAG" >> "$GITHUB_OUTPUT"
- name: Set Outputs
id: set-outputs
Expand All @@ -171,11 +203,15 @@ runs:
echo "NAMES_FULL_CONCAT=${{ steps.generate-tags.outputs.NAMES_FULL_CONCAT }}" >> $GITHUB_OUTPUT
echo "PRIMARY_TAG=${{ steps.generate-tags.outputs.PRIMARY_TAG }}" >> $GITHUB_OUTPUT
echo "PRIMARY_NAME_FULL=${{ steps.generate-tags.outputs.PRIMARY_NAME_FULL }}" >> $GITHUB_OUTPUT
echo "STABLE_TAG=${{ steps.generate-tags.outputs.STABLE_TAG }}" >> $GITHUB_OUTPUT
echo "STABLE_NAME_FULL=${{ steps.generate-tags.outputs.STABLE_NAME_FULL }}" >> $GITHUB_OUTPUT
else
echo "TAGS=${{ steps.generate-tags-pull-request.outputs.TAGS }}" >> $GITHUB_OUTPUT
echo "TAGS_CONCAT=${{ steps.generate-tags-pull-request.outputs.TAGS_CONCAT }}" >> $GITHUB_OUTPUT
echo "NAMES_FULL=${{ steps.generate-tags-pull-request.outputs.NAMES_FULL }}" >> $GITHUB_OUTPUT
echo "NAMES_FULL_CONCAT=${{ steps.generate-tags-pull-request.outputs.NAMES_FULL_CONCAT }}" >> $GITHUB_OUTPUT
echo "PRIMARY_TAG=${{ steps.generate-tags-pull-request.outputs.PRIMARY_TAG }}" >> $GITHUB_OUTPUT
echo "PRIMARY_NAME_FULL=${{ steps.generate-tags-pull-request.outputs.PRIMARY_NAME_FULL }}" >> $GITHUB_OUTPUT
echo "STABLE_TAG=${{ steps.generate-tags-pull-request.outputs.STABLE_TAG }}" >> $GITHUB_OUTPUT
echo "STABLE_NAME_FULL=${{ steps.generate-tags-pull-request.outputs.STABLE_NAME_FULL }}" >> $GITHUB_OUTPUT
fi
83 changes: 83 additions & 0 deletions .github/actions/rechunk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Rechunk Image

inputs:
builder:
description: 'The name of the builder to use (docker or podman)'
required: false
default: 'podman'
ref:
description: 'The reference to the image to rechunk'
required: true
prev-ref:
description: 'The reference to the previous image'
required: false
tags:
description: 'The tags to apply to the rechunked image'
required: false
default: ''

runs:
using: 'composite'
steps:
- name: Prepare Rechunk (Podman)
if: ${{ inputs.builder == 'podman' }}
shell: bash
env:
SOURCE_IMAGE: ${{ inputs.ref }}
run: |
set -euox pipefail
sudo apt update && sudo apt install systemd-container
podman image ls
sudo podman image scp $(whoami)@localhost::${SOURCE_IMAGE} root@localhost::
sudo podman image ls
podman rmi $(podman image ls -qa) --force
- name: Prepare Rechunk (Docker)
if: ${{ inputs.builder == 'docker' }}
shell: bash
env:
SOURCE_IMAGE: ${{ inputs.ref }}
run: |
set -euox pipefail
docker save $(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep ${SOURCE_IMAGE}) | sudo podman load
sudo podman image ls
docker rmi $(docker image ls -qa) --force
- name: Rechunk Image
id: rechunk
uses: hhd-dev/[email protected]
with:
rechunk: ghcr.io/hhd-dev/rechunk:v0.8.6
ref: ${{ inputs.ref }}
skip_compression: true
prev-ref: ${{ inputs.prev-ref }}

- name: Load Rechunked Image (Podman)
if: ${{ inputs.builder == 'podman' }}
shell: bash
run: |
sudo podman rmi $(sudo podman image ls -qa) --force
IMAGE=$(podman pull ${{ steps.rechunk.outputs.ref }})
tags="${{ inputs.tags }}"
sudo rm -rf ${{ steps.rechunk.outputs.location }}
IFS=' ' read -r -a tag_array <<< "$tags"
for tag in "${tag_array[@]}"; do
podman tag $IMAGE ${{ env.IMAGE_NAME }}:${tag}
done
podman image ls
- name: Load Rechunked Image (Docker)
if: ${{ inputs.builder == 'docker' }}
shell: bash
run: |
set -euox pipefail
sudo podman rmi $(sudo podman image ls -qa) --force
IMAGE="temporary-image:latest"
sudo skopeo copy ${{ steps.rechunk.outputs.ref }} docker-daemon:${IMAGE}
tags="${{ inputs.tags }}"
sudo rm -rf ${{ steps.rechunk.outputs.location }}
IFS=' ' read -r -a tag_array <<< "$tags"
for tag in "${tag_array[@]}"; do
docker tag $IMAGE ${{ env.IMAGE_NAME }}:${tag}
done
docker image ls
36 changes: 30 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:

jobs:
build-base:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
Expand All @@ -43,8 +43,10 @@ jobs:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Optimize GHA Storage
uses: ./.github/actions/optimise-gha-storage
- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v7
with:
remove-codeql: true

- name: Generate Image Tags
uses: ./.github/actions/generate-image-tags
Expand Down Expand Up @@ -83,6 +85,16 @@ jobs:
FEDORA_EDITION=${{ matrix.fedora-edition }}
COREOS_KERNEL=${{ env.COREOS_KERNEL }}
- name: Rechunk
id: rechunk
if: false
uses: ./.github/actions/rechunk
with:
builder: ${{ steps.build.outputs.builder }}
ref: ${{ steps.build.outputs.image }}:${{ steps.generate-image-tags.outputs.primary-tag }}
prev-ref: ${{ env.IMAGE_REGISTRY }}/${{ steps.build.outputs.image }}:${{ steps.generate-image-tags.outputs.primary-tag }}
tags: ${{ steps.build.outputs.tags }}

- name: Push Image
id: push
uses: ./.github/actions/push-image
Expand All @@ -107,7 +119,7 @@ jobs:
private-key-passphrase: ${{ secrets.ETERNAL_LINUX_SIGNING_KEY_PASSPHRASE }}

build-nvidia:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: build-base
if: ${{ !cancelled() }}
strategy:
Expand All @@ -128,8 +140,10 @@ jobs:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Optimize GHA Storage
uses: ./.github/actions/optimise-gha-storage
- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v7
with:
remove-codeql: true

- name: Generate Image Tags
uses: ./.github/actions/generate-image-tags
Expand Down Expand Up @@ -186,6 +200,16 @@ jobs:
${{ matrix.nvidia-type == 'open' && format('NVIDIA_AKMODS_IMAGE={0}', 'ghcr.io/rsturla/akmods/nvidia-open') || '' }}
NVIDIA_AKMODS_TAG=${{ matrix.fedora-version }}
- name: Rechunk
id: rechunk
if: false
uses: ./.github/actions/rechunk
with:
builder: ${{ steps.build.outputs.builder }}
ref: ${{ steps.build.outputs.image }}:${{ steps.generate-image-tags.outputs.primary-tag }}
prev-ref: ${{ env.IMAGE_REGISTRY }}/${{ steps.build.outputs.image }}:${{ steps.generate-image-tags.outputs.primary-tag }}
tags: ${{ steps.build.outputs.tags }}

- name: Push Image
id: push
uses: ./.github/actions/push-image
Expand Down

0 comments on commit 83f3da5

Please sign in to comment.