mirror of
https://github.com/suyu-emu/suyu-os.git
synced 2026-09-21 14:17:54 -07:00
Refactor build-iso workflow to improve script handling and add error checks. Optimize package installation and cleanup processes.
403 lines
13 KiB
YAML
403 lines
13 KiB
YAML
name: Build suyuOS ISO
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
workflow_dispatch:
|
|
inputs:
|
|
build_type:
|
|
description: 'Build type'
|
|
required: true
|
|
default: 'release'
|
|
type: choice
|
|
options:
|
|
- release
|
|
- debug
|
|
- testing
|
|
|
|
# Use the workflow_dispatch input when present, otherwise default to 'release'
|
|
env:
|
|
BUILD_TYPE: ${{ github.event.inputs.build_type || 'release' }}
|
|
|
|
jobs:
|
|
build-iso:
|
|
runs-on: ubuntu-latest
|
|
# Use an Arch Linux container for the job. Note: --privileged is not supported on GitHub-hosted containers,
|
|
# so we avoid that option here.
|
|
container:
|
|
image: archlinux:latest
|
|
|
|
steps:
|
|
- name: Prepare helper script (disk & cleanup functions)
|
|
run: |
|
|
cat > /tmp/ci_helpers.sh <<'EOF'
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
show_disk_usage() {
|
|
echo "=== Disk Usage Report ==="
|
|
df -h /
|
|
echo "=== Largest directories in /tmp ==="
|
|
du -sh /tmp/* 2>/dev/null | sort -hr | head -10 || true
|
|
echo "=== Memory usage ==="
|
|
free -h || true
|
|
echo "========================="
|
|
}
|
|
|
|
cleanup_pacman_cache() {
|
|
echo "Cleaning pacman cache..."
|
|
pacman -Scc --noconfirm || true
|
|
echo "Pacman cache cleaned"
|
|
}
|
|
|
|
cleanup_temp_files() {
|
|
echo "Cleaning temporary files..."
|
|
rm -rf /tmp/pacman-* /var/cache/pacman/pkg/* /tmp/tmp.* 2>/dev/null || true
|
|
echo "Temporary files cleaned"
|
|
}
|
|
EOF
|
|
chmod +x /tmp/ci_helpers.sh
|
|
|
|
- name: Install Git and base tools
|
|
run: |
|
|
# Source helpers
|
|
source /tmp/ci_helpers.sh
|
|
|
|
echo "Updating pacman keyring and system, installing git and bash..."
|
|
# Ensure keyring and updater state to avoid pacman errors in fresh container
|
|
pacman-key --init || true
|
|
pacman-key --populate archlinux || true
|
|
pacman -Syu --noconfirm
|
|
pacman -S --noconfirm git bash --needed || true
|
|
|
|
cleanup_pacman_cache
|
|
cleanup_temp_files
|
|
|
|
echo "After Git installation:"
|
|
show_disk_usage
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Setup Arch Linux environment (install build deps)
|
|
run: |
|
|
source /tmp/ci_helpers.sh
|
|
|
|
echo "Installing essential build packages..."
|
|
pacman -S --noconfirm --needed \
|
|
base-devel archiso squashfs-tools grub \
|
|
cmake ninja gcc clang llvm
|
|
|
|
cleanup_pacman_cache
|
|
cleanup_temp_files
|
|
show_disk_usage
|
|
|
|
echo "Installing development libraries..."
|
|
pacman -S --noconfirm --needed \
|
|
qt5-base qt5-tools qt5-multimedia \
|
|
vulkan-headers vulkan-validation-layers \
|
|
ffmpeg opus libzip zstd lz4 mbedtls \
|
|
boost catch2 fmt glslang nlohmann-json \
|
|
libusb hidapi libevdev || true
|
|
|
|
cleanup_pacman_cache
|
|
cleanup_temp_files
|
|
show_disk_usage
|
|
|
|
if [ "${BUILD_TYPE}" = "release" ]; then
|
|
echo "Installing gaming dependencies (release build only)..."
|
|
pacman -S --noconfirm --needed gamemode mangohud gamescope || true
|
|
cleanup_pacman_cache
|
|
cleanup_temp_files
|
|
else
|
|
echo "Skipping gaming dependencies for ${BUILD_TYPE} build to save space"
|
|
fi
|
|
|
|
# Create build user (archiso expects a non-root user in some flows)
|
|
useradd -m -G wheel -s /bin/bash builder || true
|
|
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
|
|
|
- name: Validate package list (if present)
|
|
run: |
|
|
set -euo pipefail
|
|
source /tmp/ci_helpers.sh
|
|
|
|
if [ -f packages.x86_64 ]; then
|
|
echo "Validating packages in packages.x86_64..."
|
|
while IFS= read -r package || [ -n "$package" ]; do
|
|
# Trim whitespace
|
|
package="${package%%#*}"
|
|
package="${package## }"
|
|
package="${package%% }"
|
|
[ -z "$package" ] && continue
|
|
|
|
if ! pacman -Si "$package" >/dev/null 2>&1; then
|
|
echo "WARNING: Package '$package' not found in repositories"
|
|
pacman -Ss "$package" | head -5 || true
|
|
else
|
|
echo "✓ Package '$package' found"
|
|
fi
|
|
done < packages.x86_64
|
|
else
|
|
echo "No packages.x86_64 found; skipping package validation"
|
|
fi
|
|
|
|
show_disk_usage
|
|
|
|
- name: Prepare emulator sources (lightweight)
|
|
run: |
|
|
source /tmp/ci_helpers.sh
|
|
|
|
mkdir -p /tmp/emulator-sources
|
|
cd /tmp/emulator-sources
|
|
|
|
echo "Creating suyu source reference..."
|
|
mkdir -p suyu
|
|
echo "https://git.suyu.dev/suyu/suyu.git" > suyu/source_url.txt
|
|
echo "https://github.com/suyu-emu/suyu.git" > suyu/fallback_url.txt
|
|
|
|
echo "Creating eden source reference..."
|
|
mkdir -p eden
|
|
echo "https://git.eden-emu.dev/eden-emu/eden.git" > eden/source_url.txt
|
|
|
|
echo "Creating horinux source reference..."
|
|
mkdir -p horinux
|
|
echo "https://github.com/suyu-emu/horinux.git" > horinux/source_url.txt
|
|
|
|
echo "Creating holoiso source reference..."
|
|
mkdir -p holoiso
|
|
echo "https://github.com/holoiso-eol/holoiso.git" > holoiso/source_url.txt
|
|
|
|
if [ "${BUILD_TYPE}" = "debug" ] || [ "${BUILD_TYPE}" = "testing" ]; then
|
|
echo "Cloning minimal horinux for testing build..."
|
|
git clone --depth 1 --single-branch https://github.com/suyu-emu/horinux.git horinux-actual || \
|
|
echo "Failed to clone horinux (non-critical for testing)"
|
|
fi
|
|
|
|
echo "Emulator source preparation complete:"
|
|
ls -la /tmp/emulator-sources/ || true
|
|
du -sh /tmp/emulator-sources/ || true
|
|
show_disk_usage
|
|
|
|
- name: Prepare emulator build scripts (no pre-building)
|
|
run: |
|
|
source /tmp/ci_helpers.sh
|
|
cd /tmp/emulator-sources || mkdir -p /tmp/emulator-sources && cd /tmp/emulator-sources
|
|
|
|
cat > build_suyu.sh <<'EOF'
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
SUYU_URL="https://git.suyu.dev/suyu/suyu.git"
|
|
SUYU_FALLBACK="https://github.com/suyu-emu/suyu.git"
|
|
|
|
echo "Building suyu emulator..."
|
|
cd /tmp
|
|
git clone --recursive --depth 1 "$SUYU_URL" suyu-build || git clone --recursive --depth 1 "$SUYU_FALLBACK" suyu-build || {
|
|
echo "Failed to clone suyu repository"
|
|
exit 1
|
|
}
|
|
|
|
cd suyu-build
|
|
mkdir -p build && cd build
|
|
|
|
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_QT_TRANSLATION=ON -DENABLE_SDL2=ON -DENABLE_VULKAN=ON -DYUZU_USE_BUNDLED_VCPKG=OFF -DYUZU_USE_BUNDLED_FFMPEG=OFF -DYUZU_ENABLE_LTO=ON -DYUZU_CRASH_DUMPS=OFF -DYUZU_USE_PRECOMPILED_HEADERS=OFF
|
|
|
|
ninja -j$(nproc)
|
|
ninja install
|
|
cd /tmp
|
|
rm -rf suyu-build
|
|
echo "Suyu build completed and installed"
|
|
EOF
|
|
|
|
cat > build_eden.sh <<'EOF'
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
EDEN_URL="https://git.eden-emu.dev/eden-emu/eden.git"
|
|
|
|
echo "Building eden emulator..."
|
|
cd /tmp
|
|
git clone --recursive --depth 1 "$EDEN_URL" eden-build || {
|
|
echo "Failed to clone eden repository"
|
|
exit 1
|
|
}
|
|
|
|
cd eden-build
|
|
mkdir -p build && cd build
|
|
|
|
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_QT_TRANSLATION=ON -DENABLE_SDL2=ON -DENABLE_VULKAN=ON
|
|
|
|
ninja -j$(nproc)
|
|
ninja install
|
|
cd /tmp
|
|
rm -rf eden-build
|
|
echo "Eden build completed and installed"
|
|
EOF
|
|
|
|
chmod +x build_suyu.sh build_eden.sh
|
|
echo "Build scripts created successfully:"
|
|
ls -la *.sh || true
|
|
show_disk_usage
|
|
|
|
- name: Prepare ISO build environment
|
|
run: |
|
|
source /tmp/ci_helpers.sh
|
|
|
|
mkdir -p airootfs/tmp/emulator-sources
|
|
cp -r /tmp/emulator-sources/* airootfs/tmp/emulator-sources/ 2>/dev/null || true
|
|
|
|
# Ensure scripts are placed into airootfs if desired (no-op if missing)
|
|
mkdir -p airootfs/usr/local/bin || true
|
|
cp /tmp/emulator-sources/*.sh airootfs/usr/local/bin/ 2>/dev/null || true
|
|
chmod +x airootfs/usr/local/bin/*.sh 2>/dev/null || true
|
|
|
|
mkdir -p build-iso /workspace/suyuos-build-work
|
|
|
|
du -sh airootfs/tmp/emulator-sources/ 2>/dev/null || echo "No emulator sources to measure"
|
|
du -sh /workspace/suyuos-build-work/ || true
|
|
show_disk_usage
|
|
|
|
- name: Build suyuOS ISO
|
|
run: |
|
|
set -euo pipefail
|
|
source /tmp/ci_helpers.sh
|
|
|
|
echo "Starting suyuOS ISO build with disk space monitoring..."
|
|
cleanup_pacman_cache
|
|
cleanup_temp_files
|
|
show_disk_usage
|
|
|
|
echo "Running mkarchiso with optimized settings..."
|
|
# Use a workspace directory (created above) as mkarchiso workdir
|
|
if ! command -v mkarchiso >/dev/null 2>&1; then
|
|
echo "mkarchiso not found. Installing archiso (may take a while)..."
|
|
pacman -S --noconfirm archiso || true
|
|
fi
|
|
|
|
set -o pipefail
|
|
if ! mkarchiso -v -w '/workspace/suyuos-build-work' -o 'build-iso' . 2>&1 | tee /workspace/suyuos-build-work/mkarchiso-output.log ; then
|
|
echo "ISO build failed, checking disk space and logs..."
|
|
show_disk_usage
|
|
find /workspace/suyuos-build-work -name "*.log" -exec tail -n 200 {} \; 2>/dev/null || true
|
|
exit 1
|
|
fi
|
|
|
|
echo "ISO build completed successfully:"
|
|
show_disk_usage
|
|
|
|
- name: Verify ISO build
|
|
run: |
|
|
set -euo pipefail
|
|
source /tmp/ci_helpers.sh
|
|
shopt -s nullglob
|
|
isos=(build-iso/*.iso)
|
|
if [ ${#isos[@]} -gt 0 ]; then
|
|
echo "✓ ISO build successful!"
|
|
ls -lh build-iso/*.iso || true
|
|
file build-iso/*.iso || true
|
|
|
|
cd build-iso
|
|
sha256sum *.iso > SHA256SUMS || true
|
|
md5sum *.iso > MD5SUMS || true
|
|
|
|
echo "Build artifacts:"
|
|
ls -la || true
|
|
show_disk_usage
|
|
else
|
|
echo "✗ ISO build failed!"
|
|
show_disk_usage
|
|
ls -la build-iso || true
|
|
exit 1
|
|
fi
|
|
|
|
- name: Cleanup build artifacts to save space
|
|
run: |
|
|
source /tmp/ci_helpers.sh
|
|
echo "Cleaning up build working directory to save space..."
|
|
rm -rf /workspace/suyuos-build-work 2>/dev/null || true
|
|
rm -rf /tmp/emulator-sources 2>/dev/null || true
|
|
cleanup_pacman_cache
|
|
cleanup_temp_files
|
|
show_disk_usage
|
|
|
|
- name: Upload ISO artifact
|
|
if: success()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: suyuos-iso-${{ env.BUILD_TYPE }}-${{ github.sha }}
|
|
path: |
|
|
build-iso/*.iso
|
|
build-iso/SHA256SUMS
|
|
build-iso/MD5SUMS
|
|
retention-days: 30
|
|
|
|
- name: Upload build logs
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: build-logs-${{ github.sha }}
|
|
path: |
|
|
/workspace/suyuos-build-work/work/*/build.log
|
|
/workspace/suyuos-build-work/work/*/airootfs.log
|
|
/workspace/suyuos-build-work/mkarchiso-output.log
|
|
retention-days: 7
|
|
|
|
create-release:
|
|
needs: build-iso
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download ISO artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: suyuos-iso-${{ env.BUILD_TYPE }}-${{ needs.build-iso.outputs[''] || github.sha }}
|
|
path: ./release-files
|
|
|
|
- name: Create release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: v${{ github.run_number }}
|
|
name: suyuOS Release v${{ github.run_number }}
|
|
body: |
|
|
## suyuOS Release v${{ github.run_number }}
|
|
|
|
**Build Information:**
|
|
- Commit: ${{ github.sha }}
|
|
- Build Type: ${{ env.BUILD_TYPE }}
|
|
- Build Date: ${{ github.event.head_commit.timestamp }}
|
|
|
|
**Features:**
|
|
- Handheld console game emulation support
|
|
- Gaming optimizations (GameMode, MangoHUD, Gamescope)
|
|
- Vulkan graphics acceleration
|
|
- Controller support
|
|
- Performance tuning utilities
|
|
|
|
**Installation:**
|
|
1. Download the ISO file
|
|
2. Create a bootable USB drive using tools like Rufus or dd
|
|
3. Boot from the USB drive
|
|
4. Follow the installation wizard
|
|
|
|
**Legal Notice:**
|
|
This software is for educational and research purposes. Users are responsible for ensuring they own legal copies of any games they use with this system.
|
|
|
|
**Checksums:**
|
|
See SHA256SUMS and MD5SUMS files for verification.
|
|
files: |
|
|
./release-files/*.iso
|
|
./release-files/SHA256SUMS
|
|
./release-files/MD5SUMS
|
|
draft: false
|
|
prerelease: ${{ env.BUILD_TYPE != 'release' }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|