name: Unreal Engine Build on: workflow_dispatch: push: branches: [main, develop] jobs: build-and-release: runs-on: windows if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' steps: - name: Checkout repository uses: actions/checkout@v3 with: lfs: true fetch-depth: 0 - name: Setup environment run: | # Set environment variables for Unreal Engine echo "UE_ROOT=E:/Games/UE_5.5" >> $GITHUB_ENV # Set environment variables for Linux toolchain $env:LINUX_MULTIARCH_ROOT="C:/UnrealToolchains/v23_clang-18.1.0-rockylinux8" echo "LINUX_MULTIARCH_ROOT=${LINUX_MULTIARCH_ROOT}" >> $GITHUB_ENV # Create directories for builds (with error handling) if (!(Test-Path "Builds/Windows")) { New-Item -ItemType Directory -Path "Builds/Windows" -Force } if (!(Test-Path "Builds/Linux")) { New-Item -ItemType Directory -Path "Builds/Linux" -Force } if (!(Test-Path "PackagedReleases")) { New-Item -ItemType Directory -Path "PackagedReleases" -Force } - name: Build for Windows run: | # Make sure the script exists if (Test-Path "./win_build.sh") { # Use bash to run the shell script in Git Bash & 'C:\Program Files\Git\bin\bash.exe' -c "./win_build.sh" } else { echo "Error: win_build.sh not found" exit 1 } - name: Build for Linux run: | # Make sure the script exists if (Test-Path "./linux_build.sh") { # Use bash to run the shell script in Git Bash & 'C:\Program Files\Git\bin\bash.exe' -c "./linux_build.sh" } else { echo "Error: linux_build.sh not found" exit 1 } - name: Package builds run: | echo "Preparing Windows and Linux builds for release..." # Create directories for chunks mkdir -p PackagedReleases/windows-chunks mkdir -p PackagedReleases/linux-chunks # Process Windows build if (Test-Path "Builds/Windows") { echo "Packaging Windows build with chunking..." $WIN_CHUNK_DIR="PackagedReleases/windows-chunks" # Use PowerShell to create archive and split it # First create a temporary tar file Push-Location Builds/Windows # Use 7zip to create the tar file (needs to be installed) if (!(Get-Command "7z.exe" -ErrorAction SilentlyContinue)) { echo "Installing 7-Zip..." choco install 7zip -y } echo "Creating archive of Windows build..." 7z a -ttar "../windows-build.tar" * Pop-Location # Now split the tar file echo "Splitting into chunks..." $chunkSize = 1800MB $inputFile = "Builds/windows-build.tar" $outputFile = "$WIN_CHUNK_DIR/LuckyRobots-Windows-part" $buffer = [byte[]]::new($chunkSize) $inputStream = [System.IO.File]::OpenRead($inputFile) $index = 0 while ($true) { $bytesRead = $inputStream.Read($buffer, 0, $chunkSize) if ($bytesRead -eq 0) { break } $outputStream = [System.IO.File]::Create("$outputFile$index") $outputStream.Write($buffer, 0, $bytesRead) $outputStream.Close() $index++ } $inputStream.Close() # Clean up the temporary tar file Remove-Item "Builds/windows-build.tar" # Create a checksum file for integrity verification echo "Creating checksums file..." Get-ChildItem "$WIN_CHUNK_DIR/LuckyRobots-Windows-part*" | ForEach-Object { $hash = Get-FileHash -Path $_.FullName -Algorithm MD5 "$($hash.Hash) $($_.Name)" | Out-File -FilePath "$WIN_CHUNK_DIR/LuckyRobots-Windows-checksums.md5" -Append } # Create download scripts echo "Creating download scripts..." # Windows batch script @" @echo off echo LuckyRobots Windows Build Downloader echo ================================== echo. REM Get the release tag from command line or prompt user set TAG=%1 if "%TAG%"=="" ( echo Enter the release tag (e.g. v1.0.0): set /p TAG= ) echo Downloading Windows build parts for %TAG%... echo. REM Create directory for downloads mkdir windows-build 2>nul cd windows-build REM Get the list of files to download curl -s -L -O https://luckyrobots.com/luckyrobots/luckyworld/releases/download/%TAG%/LuckyRobots-Windows-checksums.md5 REM Extract filenames from the checksums file for /f "tokens=2 delims= " %%f in (LuckyRobots-Windows-checksums.md5) do ( echo Downloading %%f... curl -L -O https://luckyrobots.com/luckyrobots/luckyworld/releases/download/%TAG%/%%f ) echo All parts downloaded. Combining... copy /b LuckyRobots-Windows-part* LuckyRobots-Windows.tar echo Extracting files... tar -xf LuckyRobots-Windows.tar echo Done! Windows build downloaded and extracted. cd .. "@ | Out-File -FilePath "PackagedReleases/download-windows-build.bat" -Encoding ASCII # Copy the checksum file to the main directory Copy-Item "$WIN_CHUNK_DIR/LuckyRobots-Windows-checksums.md5" -Destination "PackagedReleases/LuckyRobots-Windows-checksums.md5" # Create a README for Windows @" # LuckyRobots Windows Build This build is split into multiple files due to size limitations. ## Easy Download For the easiest download experience: - Download and run download-windows-build.bat The script will automatically download all needed files, combine them, and extract the build to a folder called "windows-build". ## Manual Download If you prefer to download manually: 1. Download all the part files (LuckyRobots-Windows-part*) 2. Combine them: - Windows: copy /b LuckyRobots-Windows-part* LuckyRobots-Windows.tar 3. Extract the tar file: - Using tar -xf LuckyRobots-Windows.tar Enjoy playing! "@ | Out-File -FilePath "PackagedReleases/README-Windows.txt" -Encoding ASCII # Create a downloader zip Compress-Archive -Path "PackagedReleases/README-Windows.txt","PackagedReleases/download-windows-build.bat" -DestinationPath "PackagedReleases/LuckyRobots-Windows-downloader.zip" -Force echo "Windows build packaged successfully" } else { echo "No Windows build directory found" } # Process Linux build using Git Bash if (Test-Path "Builds/Linux") { echo "Packaging Linux build with chunking..." & 'C:\Program Files\Git\bin\bash.exe' -c ' LINUX_CHUNK_DIR="PackagedReleases/linux-chunks" # Create the tar file and split it echo "Creating archive of Linux build..." cd Builds/Linux tar -cf ../../linux-build.tar * cd ../.. # Split the tar file echo "Splitting into chunks..." split -b 1800m linux-build.tar "$LINUX_CHUNK_DIR/LuckyRobots-Linux-part" # Clean up temporary tar file rm linux-build.tar # Create checksums echo "Creating checksums file..." cd "$LINUX_CHUNK_DIR" md5sum LuckyRobots-Linux-part* > LuckyRobots-Linux-checksums.md5 cd ../.. # Copy the checksum file to the main directory cp "$LINUX_CHUNK_DIR/LuckyRobots-Linux-checksums.md5" "PackagedReleases/LuckyRobots-Linux-checksums.md5" # Create download scripts echo "Creating download scripts..." # Bash script for Linux cat > "PackagedReleases/download-linux-build.sh" << 'EOLBASH #!/bin/bash echo "LuckyRobots Linux Build Downloader" echo "==================================" echo # Get the release tag from command line or prompt user TAG=$1 if [ -z "$TAG" ]; then echo "Enter the release tag (e.g. v1.0.0):" read TAG fi echo "Downloading Linux build parts for $TAG..." echo # Create directory for downloads mkdir -p linux-build cd linux-build # Get the list of files to download curl -s -L -O "https://luckyrobots.com/luckyrobots/luckyworld/releases/download/$TAG/LuckyRobots-Linux-checksums.md5" # Extract filenames from the checksums file for file in $(awk '{print $2}' LuckyRobots-Linux-checksums.md5); do echo "Downloading $file..." curl -L -O "https://luckyrobots.com/luckyrobots/luckyworld/releases/download/$TAG/$file" done echo "All parts downloaded. Combining..." cat LuckyRobots-Linux-part* > LuckyRobots-Linux.tar echo "Extracting files..." tar -xf LuckyRobots-Linux.tar echo "Done! Linux build downloaded and extracted." cd .. EOLBASH # Make the script executable chmod +x "PackagedReleases/download-linux-build.sh" # Create README for Linux cat > "PackagedReleases/README-Linux.txt" << 'EOLREADME # LuckyRobots Linux Build This build is split into multiple files due to size limitations. ## Easy Download For the easiest download experience: - Download and run download-linux-build.sh (make it executable first with chmod +x) The script will automatically download all needed files, combine them, and extract the build to a folder called "linux-build". ## Manual Download If you prefer to download manually: 1. Download all the part files (LuckyRobots-Linux-part*) 2. Combine them: - Linux: cat LuckyRobots-Linux-part* > LuckyRobots-Linux.tar 3. Extract the tar file: - Using tar -xf LuckyRobots-Linux.tar Enjoy playing! EOLREADME # Create a ZIP with the instructions and downloader zip -j "PackagedReleases/LuckyRobots-Linux-downloader.zip" \ "PackagedReleases/README-Linux.txt" \ "PackagedReleases/download-linux-build.sh" echo "Linux build packaged successfully" ' } else { echo "No Linux build directory found" } echo "=== Packaged releases ===" ls -la PackagedReleases/ - name: Create Tag if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' run: | # Fetch all tags git fetch --tags # Get the latest version tag, if any LATEST_TAG=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" | sort -V | tail -n1) if [ -z "$LATEST_TAG" ]; then # No previous version tag, start with 1.0.0 NEW_VERSION="1.0.0" echo "No previous version tags found, starting with 1.0.0" else # Strip 'v' prefix if it exists VERSION=${LATEST_TAG#v} # Split version into parts MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) PATCH=$(echo $VERSION | cut -d. -f3) # Auto-increment patch version PATCH=$((PATCH + 1)) NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" echo "Auto-incremented patch version from ${VERSION} to ${NEW_VERSION}" fi # Final tag with v prefix TAG="v${NEW_VERSION}" echo "Creating git tag: $TAG" # Configure git with token authentication git config --global user.email "actions@gitea.com" git config --global user.name "Gitea Actions" # Direct token approach - simplest method git remote set-url origin "https://goran:${{ secrets.GITEATOKEN }}@luckyrobots.com/luckyrobots/luckyworld.git" # Set git to not prompt for input $env:GIT_TERMINAL_PROMPT=0 # Check if tag exists if ! git rev-parse "$TAG" >/dev/null 2>&1; then # Create tag without opening editor (-m flag) git tag -a "$TAG" -m "Release $TAG" # Push with timeout and debug echo "Pushing tag $TAG to origin..." git push --verbose origin "$TAG" || { echo "Error: Failed to push tag. Check your token permissions." exit 1 } echo "Successfully created and pushed tag: $TAG" else echo "Tag $TAG already exists, skipping tag creation" fi echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV - name: Create Release uses: https://gitea.com/actions/gitea-release-action@main with: files: |- PackagedReleases/*.zip PackagedReleases/*.md5 PackagedReleases/windows-chunks/* PackagedReleases/linux-chunks/* token: '${{ secrets.GITEA_TOKEN }}' title: 'Release ${{ env.RELEASE_TAG }}' body: | ## Automated release from CI build #${{ github.run_number }} ### Build Instructions All builds (Windows, Linux, macOS) are split into parts due to size limitations. **For easy installation:** 1. Download the appropriate downloader ZIP for your platform: - LuckyRobots-Windows-downloader.zip - LuckyRobots-Linux-downloader.zip - LuckyRobots-macOS-downloader.zip 2. Extract and run the download script which will: - Automatically download all chunks - Combine them into a single file - Extract the game files Built from commit: ${{ github.sha }} prerelease: ${{ github.ref != 'refs/heads/main' }} tag_name: '${{ env.RELEASE_TAG }}' macos-build: runs-on: macos if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' steps: - name: Checkout repository uses: actions/checkout@v3 with: lfs: true fetch-depth: 0 - name: Get Release Tag run: | # Fetch all tags git fetch --tags # Get the latest version tag LATEST_TAG=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" | sort -V | tail -n1) if [ -z "$LATEST_TAG" ]; then NEW_VERSION="1.0.0" else VERSION=${LATEST_TAG#v} MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) PATCH=$(echo $VERSION | cut -d. -f3) PATCH=$((PATCH + 1)) NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" fi TAG="v${NEW_VERSION}" echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV echo "Using release tag: $TAG" - name: Setup Unreal Engine run: | # Use the correct path where Unreal Engine is installed UE_PATH="/Users/Shared/Epic Games/UE_5.5" if [ ! -d "$UE_PATH" ]; then echo "Error: Unreal Engine is not installed in the expected location" echo "Please ensure Unreal Engine is installed at $UE_PATH" exit 1 fi # Set environment variable with the correct Engine path echo "UE_ROOT=$UE_PATH/Engine" >> $GITHUB_ENV echo "Using Unreal Engine 5.5" - name: Build Unreal Project run: | chmod +x ./mac_build.sh ./mac_build.sh - name: Prepare Mac release with chunking run: | echo "Preparing packaged files for release..." # Create directories for packaging mkdir -p PackagedReleases/chunks # Find the app bundle in the Builds directory APP_PATH=$(find Builds -type d -name "*.app" | head -1) BUILD_DIR="" ZIP_BASE_NAME="" if [ -n "$APP_PATH" ]; then echo "Found app bundle: $APP_PATH" BUILD_DIR=$(dirname "$APP_PATH") APP_NAME=$(basename "$APP_PATH") ZIP_BASE_NAME="${APP_NAME%.app}-macOS" else echo "No .app bundle found, searching for other build directories" # Look for a directory that might be a build output MAIN_BUILD_DIR=$(find Builds -mindepth 1 -maxdepth 1 -type d | head -1) if [ -n "$MAIN_BUILD_DIR" ]; then echo "Found main build directory: $MAIN_BUILD_DIR" BUILD_DIR="$MAIN_BUILD_DIR" DIR_NAME=$(basename "$MAIN_BUILD_DIR") ZIP_BASE_NAME="${DIR_NAME}-macOS" else echo "No build directory found, using entire Builds folder" BUILD_DIR="Builds" ZIP_BASE_NAME="LuckyRobots-macOS" fi fi # Create chunks directory if it doesn't exist CHUNK_DIR="PackagedReleases/chunks" mkdir -p "$CHUNK_DIR" echo "Splitting build into 1.8GB chunks..." if [ -n "$BUILD_DIR" ]; then # Create a chunked tar archive directly - fixing the previous syntax error (cd "$BUILD_DIR" && tar -cf - * | split -b 1800m - "$CHUNK_DIR/${ZIP_BASE_NAME}-part") echo "Created chunked build files" # Create a checksum file (cd "$CHUNK_DIR" && md5 ${ZIP_BASE_NAME}-part* > ${ZIP_BASE_NAME}-checksums.md5) # Create download scripts for different platforms # Windows batch script cat > "PackagedReleases/download-mac-build.bat" << 'EOL' @echo off echo LuckyRobots macOS Build Downloader echo ================================== echo. REM Get the release tag from command line or prompt user set TAG=%1 if "%TAG%"=="" ( echo Enter the release tag (e.g. v1.0.0): set /p TAG= ) echo Downloading macOS build parts for %TAG%... echo. REM Create directory for downloads mkdir macos-build 2>nul cd macos-build REM Get the list of files to download curl -s -L -O https://luckyrobots.com/luckyrobots/luckyworld/releases/download/%TAG%/LuckyRobots-macOS-checksums.md5 REM Extract filenames from the checksums file for /f "tokens=2 delims= " %%f in (LuckyRobots-macOS-checksums.md5) do ( echo Downloading %%f... curl -L -O https://luckyrobots.com/luckyrobots/luckyworld/releases/download/%TAG%/%%f ) echo All parts downloaded. Combining... copy /b LuckyRobots-macOS-part* LuckyRobots-macOS.tar echo Extracting files... tar -xf LuckyRobots-macOS.tar echo Done! macOS build downloaded and extracted. cd .. EOL # macOS/Linux bash script cat > "PackagedReleases/download-mac-build.sh" << 'EOL' #!/bin/bash echo "LuckyRobots macOS Build Downloader" echo "==================================" echo # Get the release tag from command line or prompt user TAG=$1 if [ -z "$TAG" ]; then echo "Enter the release tag (e.g. v1.0.0):" read TAG fi echo "Downloading macOS build parts for $TAG..." echo # Create directory for downloads mkdir -p macos-build cd macos-build # Get the list of files to download curl -s -L -O "https://luckyrobots.com/luckyrobots/luckyworld/releases/download/$TAG/LuckyRobots-macOS-checksums.md5" # Extract filenames from the checksums file for file in $(awk '{print $2}' LuckyRobots-macOS-checksums.md5); do echo "Downloading $file..." curl -L -O "https://luckyrobots.com/luckyrobots/luckyworld/releases/download/$TAG/$file" done echo "All parts downloaded. Combining..." cat LuckyRobots-macOS-part* > LuckyRobots-macOS.tar echo "Extracting files..." tar -xf LuckyRobots-macOS.tar echo "Done! macOS build downloaded and extracted." cd .. EOL # Make the shell script executable chmod +x "PackagedReleases/download-mac-build.sh" # Create a simple README cat > "PackagedReleases/README-macOS.txt" << 'EOL' # LuckyRobots macOS Build This build is split into multiple files due to size limitations. ## Easy Download For the easiest download experience: - Windows: Download and run download-mac-build.bat - macOS/Linux: Download and run download-mac-build.sh Both scripts will automatically download all needed files, combine them, and extract the build to a folder called "macos-build". ## Manual Download If you prefer to download manually: 1. Download all the part files (LuckyRobots-macOS-part*) 2. Combine them: - Windows: copy /b LuckyRobots-macOS-part* LuckyRobots-macOS.tar - macOS/Linux: cat LuckyRobots-macOS-part* > LuckyRobots-macOS.tar 3. Extract the tar file: - Using tar -xf LuckyRobots-macOS.tar Enjoy playing! EOL # Zip the instructions and scripts for easy download zip -j "PackagedReleases/LuckyRobots-macOS-downloader.zip" \ "PackagedReleases/README-macOS.txt" \ "PackagedReleases/download-mac-build.bat" \ "PackagedReleases/download-mac-build.sh" # Also copy the checksum file up one level for the downloader cp "$CHUNK_DIR/${ZIP_BASE_NAME}-checksums.md5" "PackagedReleases/${ZIP_BASE_NAME}-checksums.md5" # List the files echo "Created files:" ls -la "$CHUNK_DIR" echo "Created downloader package:" ls -la "PackagedReleases" else echo "Error: Could not find any build directory to package" exit 1 fi - name: Create Gitea Release if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' uses: https://gitea.com/actions/gitea-release-action@main with: token: ${{ secrets.GITEATOKEN }} tag_name: ${{ env.RELEASE_TAG }} title: "Release ${{ env.RELEASE_TAG }}" body: | ## Automated release from CI build #${{ github.run_number }} ### macOS Build Instructions **Quick setup:** Download the LuckyRobots-macOS-downloader.zip file first! This contains scripts that will automatically download and extract all parts. For manual setup: 1. Download all part files 2. Combine them using: `cat LuckyRobots-macOS-part* > LuckyRobots-macOS.tar` 3. Extract with: `tar -xf LuckyRobots-macOS.tar` Built from commit: ${{ github.sha }} files: |- PackagedReleases/*.zip PackagedReleases/*.md5 PackagedReleases/chunks/*