From c6bd8b5ae134cf82d802ede40e0bd09590fe586a Mon Sep 17 00:00:00 2001
From: Goran Lazarevski <goranmrd@gmail.com>
Date: Fri, 28 Mar 2025 18:14:53 +0100
Subject: [PATCH] Release workflow

---
 .gitea/workflows/create-release.yml | 130 +++++++
 .gitea/workflows/unreal-build.yml   | 531 +++++++++++++++++-----------
 2 files changed, 447 insertions(+), 214 deletions(-)
 create mode 100644 .gitea/workflows/create-release.yml

diff --git a/.gitea/workflows/create-release.yml b/.gitea/workflows/create-release.yml
new file mode 100644
index 00000000..ec8b0c56
--- /dev/null
+++ b/.gitea/workflows/create-release.yml
@@ -0,0 +1,130 @@
+name: Create Release
+
+on:
+  workflow_dispatch:
+    inputs:
+      version:
+        description: 'Version for this release (e.g. 1.0.0)'
+        required: true
+        default: ''
+      prerelease:
+        description: 'Is this a pre-release?'
+        required: true
+        default: 'false'
+        type: boolean
+      description:
+        description: 'Release description'
+        required: false
+        default: 'New release'
+
+jobs:
+  create-release:
+    runs-on: macos
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+        with:
+          lfs: true
+          fetch-depth: 0
+          
+      - name: Download build artifacts
+        run: |
+          mkdir -p Builds
+          echo "Downloading build artifacts..."
+          
+          # Try direct download from artifact URL using API
+          TOKEN="${{ secrets.GITEATOKEN }}"
+          REPO="goran/lyra_game_ue"
+          ARTIFACT_NAME="macos-build"
+          
+          echo "Directly downloading latest artifacts..."
+          curl -s -H "Authorization: token $TOKEN" \
+            -L "https://luckyrobots.com/api/v1/repos/$REPO/actions/artifacts/$ARTIFACT_NAME/zip" \
+            -o "Builds/macos-build.zip" || echo "Failed to download using API"
+          
+          # Check if we got anything
+          if [ -f "Builds/macos-build.zip" ] && [ $(stat -f%z "Builds/macos-build.zip") -gt 100 ]; then
+            echo "Successfully downloaded artifact via API"
+            mkdir -p Builds/extracted
+            unzip -o "Builds/macos-build.zip" -d "Builds/extracted" || echo "Failed to unzip artifact"
+            # Move extracted content up to Builds directory
+            mv Builds/extracted/* Builds/ 2>/dev/null || true
+          else
+            echo "API download failed or resulted in empty file"
+            # Try direct URL to the workflow artifact
+            rm -f "Builds/macos-build.zip" 2>/dev/null || true
+            curl -s -H "Authorization: token $TOKEN" \
+              -L "https://luckyrobots.com/$REPO/actions/artifacts/download/$ARTIFACT_NAME" \
+              -o "Builds/macos-build.zip" || echo "Direct download failed too"
+            
+            if [ -f "Builds/macos-build.zip" ] && [ $(stat -f%z "Builds/macos-build.zip") -gt 100 ]; then
+              echo "Successfully downloaded artifact via direct URL"
+              mkdir -p Builds/extracted
+              unzip -o "Builds/macos-build.zip" -d "Builds/extracted" || echo "Failed to unzip artifact"
+              # Move extracted content up to Builds directory
+              mv Builds/extracted/* Builds/ 2>/dev/null || true
+            else
+              echo "Could not download artifacts automatically"
+            fi
+          fi
+          
+          # First check if there are any build artifacts in the local Builds directory
+          if [ ! -d "Builds" ] || [ -z "$(ls -A Builds)" ]; then
+            echo "No build artifacts found in repository, creating empty directory"
+            mkdir -p Builds
+          else
+            echo "Found local build artifacts"
+          fi
+          
+          # Create .zip files of any .app directories
+          find Builds -type d -name "*.app" | while read app; do
+            echo "Creating zip of $app"
+            (cd $(dirname "$app") && zip -r "$(basename "$app").zip" "$(basename "$app")")
+          done
+          
+          echo "Available release files:"
+          find Builds -type f -name "*.zip" || echo "No zip files found"
+
+      - name: Create Tag
+        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
+        run: |
+          TAG="v${{ github.run_number }}"
+          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/goran/lyra_game_ue.git"
+          
+          # Set git to not prompt for input
+          export 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 Gitea Release
+        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
+        uses: https://luckyrobots.com/actions/gitea-release-action@main
+        with:
+          token: ${{ secrets.GITEATOKEN }}
+          tag_name: ${{ env.RELEASE_TAG }}
+          title: "Release ${{ env.RELEASE_TAG }}"
+          files: |
+            Builds/*.zip
+            Builds/**/*.zip
\ No newline at end of file
diff --git a/.gitea/workflows/unreal-build.yml b/.gitea/workflows/unreal-build.yml
index 43d20218..be25f1ac 100644
--- a/.gitea/workflows/unreal-build.yml
+++ b/.gitea/workflows/unreal-build.yml
@@ -5,164 +5,8 @@ on:
     branches: [ main, develop ]
 
 jobs:
-  windows-build:
-    runs-on: windows
-    steps:
-      - name: Checkout repository
-        uses: actions/checkout@v3
-        with:
-          lfs: true
-          fetch-depth: 0
-      
-      - name: Set Unreal Engine Path
-        run: |
-          echo "UE_ROOT=F:\LuckyRobots\LuckyRobots\Engine" >> $Env:GITHUB_ENV
-          echo "DOTNET_CLI_HOME=$env:TEMP" >> $Env:GITHUB_ENV
-          echo "MSBUILDDISABLENODEREUSE=1" >> $Env:GITHUB_ENV
-          echo "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1" >> $Env:GITHUB_ENV
-          echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $Env:GITHUB_ENV
-          echo "DOTNET_BUILD_OUTPUT_DIR=$env:TEMP\dotnet-build" >> $Env:GITHUB_ENV
-        
-      - name: Set up build environment
-        run: |
-          # Create a custom build output directory in temp
-          $buildRoot = Join-Path $env:TEMP "unreal-build"
-          $dotnetBuildDir = Join-Path $buildRoot "dotnet-build"
-          $buildOutputDir = Join-Path $buildRoot "output"
-          
-          # Create directories with full permissions
-          foreach ($dir in @($buildRoot, $dotnetBuildDir, $buildOutputDir)) {
-            New-Item -ItemType Directory -Force -Path $dir
-            icacls $dir /grant Everyone:F /T
-          }
-          
-          # Set environment variables for build paths
-          echo "DOTNET_BUILD_OUTPUT_DIR=$dotnetBuildDir" >> $Env:GITHUB_ENV
-          echo "DOTNET_CLI_HOME=$dotnetBuildDir" >> $Env:GITHUB_ENV
-          echo "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1" >> $Env:GITHUB_ENV
-          echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $Env:GITHUB_ENV
-          echo "DOTNET_USE_POLLING_FILE_WATCHER=true" >> $Env:GITHUB_ENV
-          echo "MSBUILDDISABLENODEREUSE=1" >> $Env:GITHUB_ENV
-          echo "MSBuildSDKsPath=$env:UE_ROOT\Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300\Sdks" >> $Env:GITHUB_ENV
-          
-          # Clean any existing build artifacts
-          Remove-Item -Path "$dotnetBuildDir\*" -Recurse -Force -ErrorAction SilentlyContinue
-          Remove-Item -Path "$buildOutputDir\*" -Recurse -Force -ErrorAction SilentlyContinue
-          
-          # Set up global.json to use the correct SDK version
-          $globalJson = @'
-          {
-            "sdk": {
-              "version": "8.0.300",
-              "rollForward": "latestFeature"
-            }
-          }
-          '@
-          Set-Content -Path "global.json" -Value $globalJson
-          
-          # Create Directory.Build.props to redirect all outputs
-          $buildPropsContent = @'
-          <?xml version="1.0" encoding="utf-8"?>
-          <Project>
-            <PropertyGroup>
-              <BaseIntermediateOutputPath>$(DOTNET_BUILD_OUTPUT_DIR)\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
-              <BaseOutputPath>$(DOTNET_BUILD_OUTPUT_DIR)\bin\$(MSBuildProjectName)\</BaseOutputPath>
-              <IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
-              <OutputPath>$(BaseOutputPath)</OutputPath>
-              <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-              <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
-              <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
-              <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
-              <RestoreNoCache>true</RestoreNoCache>
-              <EnforceWritePermissions>false</EnforceWritePermissions>
-            </PropertyGroup>
-          </Project>
-          '@
-          Set-Content -Path "Directory.Build.props" -Value $buildPropsContent -Encoding UTF8
-
-          # Create a temporary nuget.config file to use a local package cache
-          $nugetConfig = @'
-          <?xml version="1.0" encoding="utf-8"?>
-          <configuration>
-            <config>
-              <add key="globalPackagesFolder" value="$(DOTNET_BUILD_OUTPUT_DIR)\packages" />
-            </config>
-          </configuration>
-          '@
-          Set-Content -Path "nuget.config" -Value $nugetConfig -Encoding UTF8
-          
-          # Set MSBuild configuration to use the temp directory
-          $MSBuildPath = Join-Path $env:UE_ROOT "Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300"
-          $env:MSBuildExtensionsPath = $MSBuildPath
-          $env:MSBuildSDKsPath = Join-Path $MSBuildPath "Sdks"
-          echo "MSBuildExtensionsPath=$env:MSBuildExtensionsPath" >> $Env:GITHUB_ENV
-          echo "MSBuildSDKsPath=$env:MSBuildSDKsPath" >> $Env:GITHUB_ENV
-          echo "MSBUILD_EXE_PATH=$MSBuildPath\MSBuild.dll" >> $Env:GITHUB_ENV
-        
-      - name: Locate .uproject file
-        run: |
-          $projectPath = Get-ChildItem -Path ".\" -Filter "*.uproject" -Recurse | Select-Object -First 1 -ExpandProperty FullName
-          if (-not $projectPath) {
-            Write-Error "No .uproject file found in repository"
-            exit 1
-          }
-          echo "UPROJECT_PATH=$projectPath" >> $Env:GITHUB_ENV
-          Write-Host "Found project file: $projectPath"
-
-      - name: Build Unreal Project
-        run: |
-          # Create and set permissions for build output directory
-          $buildOutputDir = Join-Path $env:TEMP "unreal-build\output"
-          New-Item -ItemType Directory -Force -Path $buildOutputDir
-          icacls $buildOutputDir /grant Everyone:F
-          
-          # Register dotnet locally
-          $dotnetPath = Join-Path $env:UE_ROOT "Binaries\ThirdParty\DotNet\8.0.300\win-x64\dotnet.exe"
-          $env:PATH = "$env:UE_ROOT\Binaries\ThirdParty\DotNet\8.0.300\win-x64;$env:PATH"
-          
-          # Make a local copy of the MSBuild directory with write permissions
-          $customMSBuildDir = Join-Path $env:TEMP "msbuild-custom"
-          New-Item -ItemType Directory -Force -Path $customMSBuildDir
-          Copy-Item -Path "$env:UE_ROOT\Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300\*" -Destination $customMSBuildDir -Recurse -Force
-          icacls $customMSBuildDir /grant Everyone:F /T
-          
-          # Set environment variables for the custom MSBuild
-          $env:MSBuildExtensionsPath = $customMSBuildDir
-          $env:MSBuildSDKsPath = Join-Path $customMSBuildDir "Sdks"
-          
-          # Run the build with environment variables 
-          $uatPath = Join-Path $env:UE_ROOT "Build\BatchFiles\RunUAT.bat"
-          $envVars = "set DOTNET_CLI_HOME=$env:DOTNET_CLI_HOME && " +
-                     "set DOTNET_BUILD_OUTPUT_DIR=$env:DOTNET_BUILD_OUTPUT_DIR && " +
-                     "set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 && " +
-                     "set DOTNET_CLI_TELEMETRY_OPTOUT=1 && " +
-                     "set DOTNET_USE_POLLING_FILE_WATCHER=true && " +
-                     "set MSBuildExtensionsPath=$env:MSBuildExtensionsPath && " +
-                     "set MSBuildSDKsPath=$env:MSBuildSDKsPath && " +
-                     "set MSBUILD_EXE_PATH=$env:MSBUILD_EXE_PATH && "
-                     
-          # Find project file
-          $projectPath = Get-ChildItem -Path ".\" -Filter "*.uproject" -Recurse | Select-Object -First 1 -ExpandProperty FullName
-          if (-not $projectPath) {
-            Write-Error "No .uproject file found in repository"
-            exit 1
-          }
-          Write-Host "Using project file: $projectPath"
-          
-          # Run UAT with full command
-          $cmdLine = "$envVars cmd.exe /c `"$uatPath`" BuildCookRun -project=`"$projectPath`" -noP4 -platform=Win64 -clientconfig=Development -cook -build -stage -pak -archive -archivedirectory=`"$buildOutputDir`""
-          Write-Host "Running command: $cmdLine"
-          Invoke-Expression $cmdLine
-
-      - name: Upload build artifacts
-        uses: actions/upload-artifact@v3
-        with:
-          name: windows-build
-          path: BuildOutput/
-          retention-days: 7
-
-  # macos-build:
-  #   runs-on: macos
+  # windows-build:
+  #   runs-on: windows
   #   steps:
   #     - name: Checkout repository
   #       uses: actions/checkout@v3
@@ -170,72 +14,331 @@ jobs:
   #         lfs: true
   #         fetch-depth: 0
       
-  #     - name: Setup Unreal Engine
+  #     - name: Set Unreal Engine Path
   #       run: |
-  #         # Use the correct path where Unreal Engine is installed
-  #         UE_PATH="/Users/Shared/Epic Games/UE_5.5"
+  #         echo "UE_ROOT=F:\LuckyRobots\LuckyRobots\Engine" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_CLI_HOME=$env:TEMP" >> $Env:GITHUB_ENV
+  #         echo "MSBUILDDISABLENODEREUSE=1" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_BUILD_OUTPUT_DIR=$env:TEMP\dotnet-build" >> $Env:GITHUB_ENV
+        
+  #     - name: Set up build environment
+  #       run: |
+  #         # Create a custom build output directory in temp
+  #         $buildRoot = Join-Path $env:TEMP "unreal-build"
+  #         $dotnetBuildDir = Join-Path $buildRoot "dotnet-build"
+  #         $buildOutputDir = Join-Path $buildRoot "output"
           
-  #         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"
+  #         # Create directories with full permissions
+  #         foreach ($dir in @($buildRoot, $dotnetBuildDir, $buildOutputDir)) {
+  #           New-Item -ItemType Directory -Force -Path $dir
+  #           icacls $dir /grant Everyone:F /T
+  #         }
+          
+  #         # Set environment variables for build paths
+  #         echo "DOTNET_BUILD_OUTPUT_DIR=$dotnetBuildDir" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_CLI_HOME=$dotnetBuildDir" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" >> $Env:GITHUB_ENV
+  #         echo "DOTNET_USE_POLLING_FILE_WATCHER=true" >> $Env:GITHUB_ENV
+  #         echo "MSBUILDDISABLENODEREUSE=1" >> $Env:GITHUB_ENV
+  #         echo "MSBuildSDKsPath=$env:UE_ROOT\Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300\Sdks" >> $Env:GITHUB_ENV
+          
+  #         # Clean any existing build artifacts
+  #         Remove-Item -Path "$dotnetBuildDir\*" -Recurse -Force -ErrorAction SilentlyContinue
+  #         Remove-Item -Path "$buildOutputDir\*" -Recurse -Force -ErrorAction SilentlyContinue
+          
+  #         # Set up global.json to use the correct SDK version
+  #         $globalJson = @'
+  #         {
+  #           "sdk": {
+  #             "version": "8.0.300",
+  #             "rollForward": "latestFeature"
+  #           }
+  #         }
+  #         '@
+  #         Set-Content -Path "global.json" -Value $globalJson
+          
+  #         # Create Directory.Build.props to redirect all outputs
+  #         $buildPropsContent = @'
+  #         <?xml version="1.0" encoding="utf-8"?>
+  #         <Project>
+  #           <PropertyGroup>
+  #             <BaseIntermediateOutputPath>$(DOTNET_BUILD_OUTPUT_DIR)\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
+  #             <BaseOutputPath>$(DOTNET_BUILD_OUTPUT_DIR)\bin\$(MSBuildProjectName)\</BaseOutputPath>
+  #             <IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
+  #             <OutputPath>$(BaseOutputPath)</OutputPath>
+  #             <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+  #             <AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
+  #             <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
+  #             <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
+  #             <RestoreNoCache>true</RestoreNoCache>
+  #             <EnforceWritePermissions>false</EnforceWritePermissions>
+  #           </PropertyGroup>
+  #         </Project>
+  #         '@
+  #         Set-Content -Path "Directory.Build.props" -Value $buildPropsContent -Encoding UTF8
+
+  #         # Create a temporary nuget.config file to use a local package cache
+  #         $nugetConfig = @'
+  #         <?xml version="1.0" encoding="utf-8"?>
+  #         <configuration>
+  #           <config>
+  #             <add key="globalPackagesFolder" value="$(DOTNET_BUILD_OUTPUT_DIR)\packages" />
+  #           </config>
+  #         </configuration>
+  #         '@
+  #         Set-Content -Path "nuget.config" -Value $nugetConfig -Encoding UTF8
+          
+  #         # Set MSBuild configuration to use the temp directory
+  #         $MSBuildPath = Join-Path $env:UE_ROOT "Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300"
+  #         $env:MSBuildExtensionsPath = $MSBuildPath
+  #         $env:MSBuildSDKsPath = Join-Path $MSBuildPath "Sdks"
+  #         echo "MSBuildExtensionsPath=$env:MSBuildExtensionsPath" >> $Env:GITHUB_ENV
+  #         echo "MSBuildSDKsPath=$env:MSBuildSDKsPath" >> $Env:GITHUB_ENV
+  #         echo "MSBUILD_EXE_PATH=$MSBuildPath\MSBuild.dll" >> $Env:GITHUB_ENV
+        
+  #     - name: Locate .uproject file
+  #       run: |
+  #         $projectPath = Get-ChildItem -Path ".\" -Filter "*.uproject" -Recurse | Select-Object -First 1 -ExpandProperty FullName
+  #         if (-not $projectPath) {
+  #           Write-Error "No .uproject file found in repository"
   #           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"
-      
+  #         }
+  #         echo "UPROJECT_PATH=$projectPath" >> $Env:GITHUB_ENV
+  #         Write-Host "Found project file: $projectPath"
+
   #     - name: Build Unreal Project
   #       run: |
-  #         # Debug information
-  #         echo "=== Environment Information ==="
-  #         echo "macOS Version:"
-  #         sw_vers
-  #         echo "Current working directory: $(pwd)"
-  #         ls -la  # List all files in current directory
+  #         # Create and set permissions for build output directory
+  #         $buildOutputDir = Join-Path $env:TEMP "unreal-build\output"
+  #         New-Item -ItemType Directory -Force -Path $buildOutputDir
+  #         icacls $buildOutputDir /grant Everyone:F
           
-  #         echo "=== Unreal Engine Information ==="
-  #         ls -la "$UE_ROOT/Build/BatchFiles"
+  #         # Register dotnet locally
+  #         $dotnetPath = Join-Path $env:UE_ROOT "Binaries\ThirdParty\DotNet\8.0.300\win-x64\dotnet.exe"
+  #         $env:PATH = "$env:UE_ROOT\Binaries\ThirdParty\DotNet\8.0.300\win-x64;$env:PATH"
           
-  #         echo "=== Project Information ==="
-  #         # Detailed search for the project file
-  #         echo "Searching for .uproject files:"
-  #         find . -name "*.uproject" -type f
+  #         # Make a local copy of the MSBuild directory with write permissions
+  #         $customMSBuildDir = Join-Path $env:TEMP "msbuild-custom"
+  #         New-Item -ItemType Directory -Force -Path $customMSBuildDir
+  #         Copy-Item -Path "$env:UE_ROOT\Binaries\ThirdParty\DotNet\8.0.300\win-x64\sdk\8.0.300\*" -Destination $customMSBuildDir -Recurse -Force
+  #         icacls $customMSBuildDir /grant Everyone:F /T
           
-  #         # Get the absolute path of the project file
-  #         UPROJECT_PATH=$(find . -name "*.uproject" -type f | head -1)
-  #         if [ -z "$UPROJECT_PATH" ]; then
-  #           echo "Error: Could not find .uproject file"
+  #         # Set environment variables for the custom MSBuild
+  #         $env:MSBuildExtensionsPath = $customMSBuildDir
+  #         $env:MSBuildSDKsPath = Join-Path $customMSBuildDir "Sdks"
+          
+  #         # Run the build with environment variables 
+  #         $uatPath = Join-Path $env:UE_ROOT "Build\BatchFiles\RunUAT.bat"
+  #         $envVars = "set DOTNET_CLI_HOME=$env:DOTNET_CLI_HOME && " +
+  #                    "set DOTNET_BUILD_OUTPUT_DIR=$env:DOTNET_BUILD_OUTPUT_DIR && " +
+  #                    "set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 && " +
+  #                    "set DOTNET_CLI_TELEMETRY_OPTOUT=1 && " +
+  #                    "set DOTNET_USE_POLLING_FILE_WATCHER=true && " +
+  #                    "set MSBuildExtensionsPath=$env:MSBuildExtensionsPath && " +
+  #                    "set MSBuildSDKsPath=$env:MSBuildSDKsPath && " +
+  #                    "set MSBUILD_EXE_PATH=$env:MSBUILD_EXE_PATH && "
+                     
+  #         # Find project file
+  #         $projectPath = Get-ChildItem -Path ".\" -Filter "*.uproject" -Recurse | Select-Object -First 1 -ExpandProperty FullName
+  #         if (-not $projectPath) {
+  #           Write-Error "No .uproject file found in repository"
   #           exit 1
-  #         fi
+  #         }
+  #         Write-Host "Using project file: $projectPath"
           
-  #         # Convert to absolute path and verify file exists
-  #         UPROJECT_ABSOLUTE_PATH=$(realpath "$UPROJECT_PATH")
-  #         echo "Project absolute path: $UPROJECT_ABSOLUTE_PATH"
-          
-  #         if [ ! -f "$UPROJECT_ABSOLUTE_PATH" ]; then
-  #           echo "Error: Project file does not exist at: $UPROJECT_ABSOLUTE_PATH"
-  #           exit 1
-  #         fi
-          
-  #         echo "Using Unreal Engine at: $UE_ROOT"
-          
-  #         # Make the project file readable and executable
-  #         chmod 755 "$UPROJECT_ABSOLUTE_PATH"
-          
-  #         # Run the build using absolute paths
-  #         chmod +x "$UE_ROOT/Build/BatchFiles/RunUAT.sh"
-  #         "$UE_ROOT/Build/BatchFiles/RunUAT.sh" BuildCookRun \
-  #           -project="$UPROJECT_ABSOLUTE_PATH" \
-  #           -noP4 \
-  #           -platform=Mac \
-  #           -clientconfig=Development \
-  #           -cook -build -stage -pak -archive \
-  #           -archivedirectory="$(pwd)/Build"
-      
+  #         # Run UAT with full command
+  #         $cmdLine = "$envVars cmd.exe /c `"$uatPath`" BuildCookRun -project=`"$projectPath`" -noP4 -platform=Win64 -clientconfig=Development -cook -build -stage -pak -archive -archivedirectory=`"$buildOutputDir`""
+  #         Write-Host "Running command: $cmdLine"
+  #         Invoke-Expression $cmdLine
+
   #     - name: Upload build artifacts
   #       uses: actions/upload-artifact@v3
   #       with:
-  #         name: macos-build
-  #         path: Build/
-  #         retention-days: 7
\ No newline at end of file
+  #         name: windows-build
+  #         path: BuildOutput/
+  #         retention-days: 7
+
+  macos-build:
+    runs-on: macos
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+        with:
+          lfs: true
+          fetch-depth: 0
+      
+      - 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: |
+          # Debug information
+          echo "=== Environment Information ==="
+          echo "macOS Version:"
+          sw_vers
+          echo "Current working directory: $(pwd)"
+          ls -la  # List all files in current directory
+          
+          echo "=== Unreal Engine Information ==="
+          ls -la "$UE_ROOT/Build/BatchFiles"
+          
+          echo "=== Project Information ==="
+          # Detailed search for the project file
+          echo "Searching for .uproject files:"
+          find . -name "*.uproject" -type f
+          
+          # Get the absolute path of the project file
+          UPROJECT_PATH=$(find . -name "*.uproject" -type f | head -1)
+          if [ -z "$UPROJECT_PATH" ]; then
+            echo "Error: Could not find .uproject file"
+            exit 1
+          fi
+          
+          # Convert to absolute path and verify file exists
+          UPROJECT_ABSOLUTE_PATH=$(realpath "$UPROJECT_PATH")
+          echo "Project absolute path: $UPROJECT_ABSOLUTE_PATH"
+          
+          if [ ! -f "$UPROJECT_ABSOLUTE_PATH" ]; then
+            echo "Error: Project file does not exist at: $UPROJECT_ABSOLUTE_PATH"
+            exit 1
+          fi
+          
+          echo "Using Unreal Engine at: $UE_ROOT"
+          
+          # Make the project file readable and executable
+          chmod 755 "$UPROJECT_ABSOLUTE_PATH"
+          
+          # Run the build using absolute paths
+          chmod +x "$UE_ROOT/Build/BatchFiles/RunUAT.sh"
+          "$UE_ROOT/Build/BatchFiles/RunUAT.sh" BuildCookRun \
+            -project="$UPROJECT_ABSOLUTE_PATH" \
+            -noP4 \
+            -platform=Mac \
+            -clientconfig=Development \
+            -cook -build -stage -pak -archive \
+            -archivedirectory="$(pwd)/Builds"
+            
+          # Debug: Show exactly what was built
+          echo "=== Build Output Structure ==="
+          echo "Listing Builds directory contents:"
+          ls -la Builds/
+          echo "Showing detailed directory structure:"
+          find Builds -type d | sort
+          echo "Searching for app bundles:"
+          find Builds -name "*.app" -type d || echo "No .app bundles found"
+          echo "Searching for executable files:"
+          find Builds -type f -perm +111 || echo "No executable files found"
+          echo "Listing top-level files by type:"
+          find Builds -type f -not -path "*/\.*" | grep -v "DS_Store" | sort | xargs file || echo "No files to list"
+      
+      - name: Upload build artifacts
+        uses: actions/upload-artifact@v3
+        with:
+          name: macos-build
+          path: Builds/
+          retention-days: 7
+          
+      - name: Prepare release files
+        run: |
+          echo "Preparing packaged files for release..."
+          mkdir -p PackagedReleases
+          
+          # Debug info
+          echo "Build directory contents:"
+          ls -la Builds/
+          
+          # Check if Mac directory exists
+          if [ -d "Builds/Mac" ]; then
+            echo "Found Mac build directory"
+            
+            # Fix permissions
+            find Builds/Mac -type f -perm +111 -exec chmod 755 {} \;
+            echo "Fixed executable permissions"
+            
+            # Create readme file
+            echo "Creating README file"
+            cat > PackagedReleases/README.txt <<-'EOF'
+IMPORTANT INSTRUCTIONS FOR MACOS USERS
+--------------------------------------
+
+After downloading and extracting the zip file:
+
+1. If the app won't start, right-click on it and select "Open"
+2. If you still get security warnings, go to System Preferences > Security & Privacy
+   and click "Open Anyway" for the application
+3. Alternatively, run this command in Terminal:
+   xattr -cr /path/to/extracted/folder
+
+This removes quarantine attributes that may prevent running.
+EOF
+            
+            # Create the zip file
+            echo "Creating zip file of Mac build"
+            (cd Builds && zip -ry "../PackagedReleases/lyragame-macos.zip" "Mac" "../PackagedReleases/README.txt")
+            echo "Created package: PackagedReleases/lyragame-macos.zip"
+          else
+            echo "No Mac directory found, packaging everything"
+            (cd Builds && zip -ry "../PackagedReleases/game-macos.zip" .)
+            echo "Created fallback package: PackagedReleases/game-macos.zip"
+          fi
+          
+          # List the packaged files
+          echo "Packaged releases:"
+          ls -la PackagedReleases/
+
+      - name: Create Tag
+        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
+        run: |
+          TAG="v${{ github.run_number }}"
+          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/goran/lyra_game_ue.git"
+          
+          # Set git to not prompt for input
+          export 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 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 }}"
+          files: PackagedReleases/*.zip
\ No newline at end of file