diff --git a/.gitea/workflows/build-engine.yaml b/.gitea/workflows/build-engine.yaml index 2151298ce1d..75fa5286e44 100644 --- a/.gitea/workflows/build-engine.yaml +++ b/.gitea/workflows/build-engine.yaml @@ -2,29 +2,52 @@ name: Build Godot Engine on: push: branches: [ "customized-moa" ] + create: + tags: + - 'v*' jobs: - build-windows: - name: Build Windows ${{ matrix.name }} + # --- BUILD JOBS (Parallel Matrix) --- + build-engine: + name: Build ${{ matrix.platform }} ${{ matrix.target }} runs-on: ubuntu-latest - # Run on Host (so Checkout works) - strategy: fail-fast: false matrix: include: - - name: Editor + # Windows (Double Precision) + - platform: windows target: editor production: yes artifact_name: godot-windows-editor - - name: Debug Template + builder: windows + - platform: windows target: template_debug production: no artifact_name: godot-windows-debug - - name: Release Template + builder: windows + - platform: windows target: template_release production: yes artifact_name: godot-windows-release + builder: windows + + # Linux (Double Precision) + - platform: linuxbsd + target: editor + production: yes + artifact_name: godot-linux-editor + builder: linux + - platform: linuxbsd + target: template_debug + production: no + artifact_name: godot-linux-debug + builder: linux + - platform: linuxbsd + target: template_release + production: yes + artifact_name: godot-linux-release + builder: linux steps: - name: Checkout Source @@ -32,33 +55,40 @@ jobs: with: submodules: recursive - - name: Compile with SCons + - name: Make scripts executable + run: chmod +x .gitea/workflows/scripts/*.sh + + - name: Compile (${{ matrix.platform }}) uses: docker://quay.io/buildah/stable env: + # Registry Config REGISTRY: gitea.212.63.210.91.nip.io OWNER: ${{ gitea.repository_owner }} - IMAGE_NAME: godot-builder-windows - IMAGE_TAG: 513d6efc259bb974ee2078adfa5f0994d0796a57 USERNAME: ${{ gitea.actor }} PASSWORD: ${{ secrets.USER_PACKAGE_PASSWORD }} - # Build Arguments (From Matrix) - PLATFORM: windows + + # Which builder image to use? (windows or linux) + BUILDER_TYPE: ${{ matrix.builder }} + IMAGE_TAG: latest + + # SCons Arguments + PLATFORM: ${{ matrix.platform }} TARGET: ${{ matrix.target }} PRODUCTION: ${{ matrix.production }} with: entrypoint: /bin/sh - # Just run the file! No messy YAML strings. args: .gitea/workflows/scripts/build-with-buildah.sh - name: Upload Artifacts uses: actions/upload-artifact@v3 with: name: ${{ matrix.artifact_name }} - path: bin/*.exe + # Uploads executables (Windows) and binaries (Linux has no extension) + path: bin/godot.* - # --- JOB 2: PUBLISH (Serial) --- + # --- PUBLISH JOB (Runs after all builds finish) --- publish: - needs: build-windows + needs: build-engine runs-on: ubuntu-latest steps: - name: Checkout Source @@ -71,15 +101,16 @@ jobs: with: path: dist + - name: Make script executable + run: chmod +x .gitea/workflows/scripts/publish.sh + - name: Package and Publish uses: docker://alpine:latest env: - # Pass config & secrets API_URL: https://gitea.212.63.210.91.nip.io/api/packages/${{ gitea.repository_owner }}/generic TOKEN: ${{ secrets.USER_PACKAGE_PASSWORD }} ACTOR: ${{ gitea.actor }} VERSION: ${{ gitea.sha }} with: entrypoint: /bin/sh - # The workspace (containing 'dist' and 'scripts') is automatically mounted args: .gitea/workflows/scripts/publish.sh \ No newline at end of file diff --git a/.gitea/workflows/scripts/build-with-buildah.sh b/.gitea/workflows/scripts/build-with-buildah.sh index b22b46b93ea..37c7acf66b8 100644 --- a/.gitea/workflows/scripts/build-with-buildah.sh +++ b/.gitea/workflows/scripts/build-with-buildah.sh @@ -1,55 +1,45 @@ #!/bin/sh -set -e # Exit on error +set -e -# --- 1. CONFIGURATION --- -# We read these from Environment Variables passed by the workflow -# This makes the script reusable for Windows, Linux, etc. -FULL_IMAGE_URL="$REGISTRY/$OWNER/$IMAGE_NAME:$IMAGE_TAG" +# --- Configuration --- +FULL_IMAGE_URL="$REGISTRY/$OWNER/godot-builder-$BUILDER_TYPE:$IMAGE_TAG" echo "------------------------------------------------" -echo "Task Runner: Starting Buildah Orchestration" -echo "Target: $PLATFORM / $TARGET" -echo "Image: $FULL_IMAGE_URL" +echo "Starting Build for: $PLATFORM / $TARGET" +echo "Using Builder: $FULL_IMAGE_URL" echo "------------------------------------------------" -# --- 2. LOGIN --- echo "Logging into registry..." # Note: We use --password-stdin for security so the secret isn't in process list -echo "$PASSWORD" | buildah login -u "$USERNAME" --password-stdin --tls-verify=false --storage-driver=vfs "$REGISTRY" +echo "$PASSWORD" | buildah login -u "$USERNAME" --password-stdin --tls-verify=false "$REGISTRY" -# --- 3. CREATE CONTAINER --- echo "Pulling image and creating working container..." # We capture the Container ID (CTR) -CTR=$(buildah from --tls-verify=false --storage-driver=vfs "$FULL_IMAGE_URL") +CTR=$(buildah from --tls-verify=false "$FULL_IMAGE_URL") -# --- 4. CONFIGURE CONTAINER --- -# FIX: buildah run doesn't have --working-dir. -# We use 'buildah config' to set it on the container instance instead. -buildah config --storage-driver=vfs --workingdir /src "$CTR" +# 3. Clean up on exit (Trap) +cleanup() { + echo "Cleaning up container..." + buildah rm "$CTR" || true +} +trap cleanup EXIT -# --- 5. EXECUTE BUILD --- -echo "Running SCons inside container..." +# 4. Determine SCons Flags based on Platform +# Windows needs LLVM/MinGW flags. Linux just needs defaults. +SCONS_FLAGS="platform=$PLATFORM target=$TARGET arch=x86_64 precision=double production=$PRODUCTION -j$(nproc)" -# Explaining the flags: -# -v "$PWD":/src -> Mounts the host workspace (your code) into the container at /src -# -w /src -> Sets working directory to /src -# --env ... -> Passes variables needed strictly for the build (optional) -# scons ... -> The actual compile command +if [ "$PLATFORM" = "windows" ]; then + # Add Windows-specific flags (LLVM toolchain, disable D3D12) + SCONS_FLAGS="$SCONS_FLAGS use_llvm=yes use_mingw=yes d3d12=no" +fi +echo "Running: scons $SCONS_FLAGS" + +# 5. Run Build buildah run \ --volume "$PWD":/src \ - --storage-driver=vfs \ + --working-dir /src \ "$CTR" \ - scons platform="$PLATFORM" \ - target="$TARGET" \ - d3d12=no \ - arch=x86_64 \ - precision=double \ - production="$PRODUCTION" \ - use_llvm=yes \ - use_mingw=yes \ - -j$(nproc) + scons $SCONS_FLAGS -# --- 6. CLEANUP --- -echo "Build successful. Removing container..." -buildah rm --storage-driver=vfs "$CTR" \ No newline at end of file +echo "✅ Build Complete" \ No newline at end of file diff --git a/.gitea/workflows/scripts/publish.sh b/.gitea/workflows/scripts/publish.sh index f4f58adb5ca..7952153ed06 100644 --- a/.gitea/workflows/scripts/publish.sh +++ b/.gitea/workflows/scripts/publish.sh @@ -1,47 +1,48 @@ #!/bin/sh set -e -# --- 0. SETUP --- -# We install dependencies because we are running in a minimal Alpine container -echo "Installing tools..." +# Install tools (Alpine container) apk add --no-cache curl zip echo "------------------------------------------------" -echo "Publishing Packages for: $VERSION" -echo "Registry API: $API_URL" +echo "Publishing Packages for Version: $VERSION" echo "------------------------------------------------" -# --- 1. PUBLISH EDITOR --- -echo "Processing Editor..." -# Zip both .exe and .console.exe +# --- 1. WINDOWS EDITOR --- +echo "Packaging Windows Editor..." zip -j godot-editor-windows.zip dist/godot-windows-editor/*.exe -echo "Uploading Editor..." curl --fail --user "$ACTOR:$TOKEN" \ --upload-file "godot-editor-windows.zip" \ "$API_URL/godot-editor-windows/$VERSION/godot-editor-windows.zip" -# --- 2. PUBLISH TEMPLATES --- -echo "Processing Templates..." +# --- 2. LINUX EDITOR --- +echo "Packaging Linux Editor..." +# Find the linux binary (it has no extension, so we grep for 'godot.') +LINUX_BIN=$(find dist/godot-linux-editor -type f -name "godot.linuxbsd.editor*" | head -n 1) +zip -j godot-editor-linux.zip "$LINUX_BIN" + +curl --fail --user "$ACTOR:$TOKEN" \ + --upload-file "godot-editor-linux.zip" \ + "$API_URL/godot-editor-linux/$VERSION/godot-editor-linux.zip" + +# --- 3. EXPORT TEMPLATES (Windows + Linux) --- +echo "Packaging Templates (.tpz)..." mkdir -p templates -# Select specific binaries (ignoring console wrapper) -DEBUG_SRC=$(find dist/godot-windows-debug -name "*.exe" | grep -v "console.exe" | head -n 1) -RELEASE_SRC=$(find dist/godot-windows-release -name "*.exe" | grep -v "console.exe" | head -n 1) +# Windows Templates (Filter out console wrapper) +cp $(ls dist/godot-windows-debug/*.exe | grep -v "console") templates/windows_debug_x86_64.exe +cp $(ls dist/godot-windows-release/*.exe | grep -v "console") templates/windows_release_x86_64.exe -echo "Found Debug: $DEBUG_SRC" -echo "Found Release: $RELEASE_SRC" +# Linux Templates +cp $(find dist/godot-linux-debug -type f -name "godot.*") templates/linux_debug.x86_64 +cp $(find dist/godot-linux-release -type f -name "godot.*") templates/linux_release.x86_64 -# Rename to standard Godot export names -cp "$DEBUG_SRC" templates/windows_debug_x86_64.exe -cp "$RELEASE_SRC" templates/windows_release_x86_64.exe - -# Zip into TPZ +# Create TPZ zip -j templates.tpz templates/* -echo "Uploading Templates..." curl --fail --user "$ACTOR:$TOKEN" \ --upload-file "templates.tpz" \ - "$API_URL/godot-templates/$VERSION/windows_templates.tpz" + "$API_URL/godot-templates/$VERSION/templates.tpz" -echo "✅ Success! All packages published." \ No newline at end of file +echo "✅ All packages published successfully!" \ No newline at end of file