Split builds into base and distro
Some checks failed
Publish Builder Images / build-base (push) Successful in 1m45s
Publish Builder Images / build-windows (push) Failing after 3m30s

This commit is contained in:
2025-12-02 10:26:25 +01:00
parent f19a927548
commit 59480d83a6
5 changed files with 111 additions and 114 deletions

View File

@ -2,32 +2,50 @@ name: Publish Builder Images
on:
push:
paths:
- 'Dockerfile.base'
- 'Dockerfile.windows'
- 'build.sh'
- 'Dockerfile.*'
- '*.sh'
jobs:
build-and-push:
# JOB 1: Handles the Fedora Base
build-base:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Make script executable
run: chmod +x build.sh
- name: Make scripts executable
run: chmod +x *.sh
# Optional: Restore DNF Cache (if you are using the cache strategy)
- name: Run Build Script
- name: Build/Cache Base
uses: docker://quay.io/buildah/stable
env:
# Standard Gitea env vars
USERNAME: ${{ gitea.repository_owner }}
PASSWORD: ${{ secrets.USER_PACKAGE_PASSWORD }}
REGISTRY: gitea.212.63.210.91.nip.io
# We use the short SHA for the tag
with:
entrypoint: /bin/sh
args: ./build-base.sh
# JOB 2: Handles the Windows Builder
# Only runs if Base succeeds.
build-windows:
needs: build-base
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Make scripts executable
run: chmod +x *.sh
- name: Build Windows Target
uses: docker://quay.io/buildah/stable
env:
USERNAME: ${{ gitea.repository_owner }}
PASSWORD: ${{ secrets.USER_PACKAGE_PASSWORD }}
REGISTRY: gitea.212.63.210.91.nip.io
# We pass the Git SHA here for the final image tag
TAG: ${{ gitea.sha }}
with:
entrypoint: /bin/sh
args: ./build.sh
args: ./build-windows.sh

View File

@ -1,32 +0,0 @@
# We use Fedora because it has the most up-to-date MinGW packages for Godot 4
FROM fedora:39
# Install Build Tools (GCC, MinGW, SCons, Yasm, Git)
# This covers Linux (GCC) and Windows (MinGW) compilation
RUN dnf -y install \
git \
scons \
make \
automake \
gcc \
gcc-c++ \
kernel-headers \
libX11-devel \
libXcursor-devel \
libXrandr-devel \
libXinerama-devel \
libXi-devel \
mesa-libGL-devel \
alsa-lib-devel \
pulseaudio-libs-devel \
libudev-devel \
mingw64-gcc \
mingw64-gcc-c++ \
mingw64-winpthreads-static \
mingw64-hidapi \
yasm \
which \
nodejs \
&& dnf clean all
CMD ["/bin/bash"]

37
build-base.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/sh
set -e
# --- Configuration ---
IMAGE_NAME="godot-builder-base"
# Calculate a short hash based purely on the file content
# If you don't change the file, this hash stays the same!
FILE_HASH=$(sha256sum Dockerfile.base | cut -c 1-8)
FULL_TAG="$REGISTRY/$USERNAME/$IMAGE_NAME:$FILE_HASH"
LATEST_TAG="$REGISTRY/$USERNAME/$IMAGE_NAME:latest"
echo "Logging in..."
buildah login -u "$USERNAME" -p "$PASSWORD" --tls-verify=false --storage-driver=vfs "$REGISTRY"
echo "Checking if base image $FULL_TAG exists..."
# Try to pull the specific hash. If it works, we are done!
if buildah pull --tls-verify=false --storage-driver=vfs "$FULL_TAG"; then
echo "✅ Cache Hit! Image already exists. Skipping build."
# Retag it as 'latest' just to be safe for other jobs
buildah tag --storage-driver=vfs "$FULL_TAG" "$LATEST_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$LATEST_TAG"
exit 0
fi
echo "⚠️ Cache Miss. Building new base image..."
buildah build \
--tls-verify=false \
--storage-driver=vfs \
-f Dockerfile.base \
-t "$FULL_TAG" \
-t "$LATEST_TAG" \
.
echo "Pushing new base image..."
buildah push --tls-verify=false --storage-driver=vfs "$FULL_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$LATEST_TAG"

43
build-windows.sh Normal file
View File

@ -0,0 +1,43 @@
#!/bin/sh
set -e
# --- Configuration ---
BASE_IMAGE_NAME="godot-builder-base"
WIN_IMAGE_NAME="godot-builder-windows"
# We need the SAME hash logic to find the right base
BASE_HASH=$(sha256sum Dockerfile.base | cut -c 1-8)
BASE_TAG="$REGISTRY/$USERNAME/$BASE_IMAGE_NAME:$BASE_HASH"
# For the Windows image, we still use the Git SHA (passed from workflow)
# because we want a new Windows builder for every code commit.
WIN_TAG="$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:$TAG"
echo "Logging in..."
buildah login -u "$USERNAME" -p "$PASSWORD" --tls-verify=false --storage-driver=vfs "$REGISTRY"
echo "---------------------------------------"
echo "Preparing Base Image..."
echo "---------------------------------------"
# Pull the base (which build-base.sh guaranteed exists)
buildah pull --tls-verify=false --storage-driver=vfs "$BASE_TAG"
# Create the local alias so Dockerfile.windows finds it
# This satisfies: FROM godot-fedora:custom
buildah tag --storage-driver=vfs "$BASE_TAG" "godot-fedora:custom"
echo "---------------------------------------"
echo "Building Windows Image..."
echo "---------------------------------------"
buildah build \
--tls-verify=false \
--storage-driver=vfs \
--build-arg img_version=custom \
-f Dockerfile.windows \
-t "$WIN_TAG" \
-t "$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:latest" \
.
echo "Pushing Windows image..."
buildah push --tls-verify=false --storage-driver=vfs "$WIN_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:latest"

View File

@ -1,69 +0,0 @@
#!/bin/sh
set -e # Stop on any error
# --- Configuration ---
# 1. Image Names for your Registry
BASE_IMAGE_NAME="godot-builder-base"
WIN_IMAGE_NAME="godot-builder-windows"
# 2. Construct full registry paths
# Uses variables passed from the workflow env: $REGISTRY, $USERNAME, $TAG
FULL_BASE_TAG="$REGISTRY/$USERNAME/$BASE_IMAGE_NAME:$TAG"
LATEST_BASE_TAG="$REGISTRY/$USERNAME/$BASE_IMAGE_NAME:latest"
FULL_WIN_TAG="$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:$TAG"
LATEST_WIN_TAG="$REGISTRY/$USERNAME/$WIN_IMAGE_NAME:latest"
# 3. Login
echo "Logging in to $REGISTRY..."
buildah login -u "$USERNAME" -p "$PASSWORD" --tls-verify=false --storage-driver=vfs "$REGISTRY"
# --- STEP 1: Build Base Image ---
echo "---------------------------------------"
echo "Building BASE image (Fedora)..."
echo "---------------------------------------"
# Build and tag for the registry
buildah build \
--tls-verify=false \
--storage-driver=vfs \
-f Dockerfile.base \
-t "$FULL_BASE_TAG" \
-t "$LATEST_BASE_TAG" \
.
# CRITICAL STEP: Create the local alias
# The Windows Dockerfile expects "FROM godot-fedora:custom"
# So we tag our just-built image to match that expectation.
buildah tag --storage-driver=vfs "$FULL_BASE_TAG" "godot-fedora:custom"
# Push Base to registry (Checkpoint)
echo "Pushing Base image..."
buildah push --tls-verify=false --storage-driver=vfs "$FULL_BASE_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$LATEST_BASE_TAG"
# --- STEP 2: Build Windows Image ---
echo "---------------------------------------"
echo "Building WINDOWS image..."
echo "---------------------------------------"
# We pass 'img_version=custom' to match the tag we just created.
buildah build \
--tls-verify=false \
--storage-driver=vfs \
--build-arg img_version=custom \
-f Dockerfile.windows \
-t "$FULL_WIN_TAG" \
-t "$LATEST_WIN_TAG" \
.
# Push Windows Image
echo "Pushing Windows image..."
buildah push --tls-verify=false --storage-driver=vfs "$FULL_WIN_TAG"
buildah push --tls-verify=false --storage-driver=vfs "$LATEST_WIN_TAG"
echo "---------------------------------------"
echo "SUCCESS!"
echo "Base Image: $FULL_BASE_TAG"
echo "Windows Image: $FULL_WIN_TAG"
echo "---------------------------------------"