|
| 1 | +name: Build and Release RyzenAI Server |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + paths: |
| 7 | + - '**.cpp' |
| 8 | + - '**.h' |
| 9 | + - 'CMakeLists.txt' |
| 10 | + - '.github/workflows/**' |
| 11 | + pull_request: |
| 12 | + paths: |
| 13 | + - '**.cpp' |
| 14 | + - '**.h' |
| 15 | + - 'CMakeLists.txt' |
| 16 | + - '.github/workflows/**' |
| 17 | + workflow_dispatch: |
| 18 | + inputs: |
| 19 | + create_release: |
| 20 | + description: 'Create a GitHub release with the built artifacts' |
| 21 | + required: false |
| 22 | + default: false |
| 23 | + type: boolean |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: write |
| 27 | + |
| 28 | +jobs: |
| 29 | + build-ryzenai-server: |
| 30 | + name: Build RyzenAI Server |
| 31 | + runs-on: [rai-160-sdk, Windows] |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + clean: true |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Install CMake if not available |
| 39 | + shell: PowerShell |
| 40 | + run: | |
| 41 | + # Check if CMake is already installed |
| 42 | + $cmakeInstalled = Get-Command cmake -ErrorAction SilentlyContinue |
| 43 | + |
| 44 | + if (-not $cmakeInstalled) { |
| 45 | + Write-Host "CMake not found, installing..." -ForegroundColor Yellow |
| 46 | + |
| 47 | + # Download CMake installer |
| 48 | + $cmakeVersion = "3.28.1" |
| 49 | + $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v$cmakeVersion/cmake-$cmakeVersion-windows-x86_64.msi" |
| 50 | + $cmakeInstaller = "cmake-installer.msi" |
| 51 | + |
| 52 | + Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeInstaller |
| 53 | + |
| 54 | + # Install CMake silently |
| 55 | + Start-Process msiexec.exe -ArgumentList "/i $cmakeInstaller /quiet /norestart" -Wait |
| 56 | + |
| 57 | + # Add CMake to PATH for this session AND future steps |
| 58 | + $cmakePath = "C:\Program Files\CMake\bin" |
| 59 | + $env:PATH = "$cmakePath;$env:PATH" |
| 60 | + |
| 61 | + # Persist to GITHUB_PATH for future steps |
| 62 | + echo $cmakePath >> $env:GITHUB_PATH |
| 63 | + |
| 64 | + # Verify installation |
| 65 | + cmake --version |
| 66 | + if ($LASTEXITCODE -ne 0) { |
| 67 | + Write-Host "ERROR: CMake installation failed!" -ForegroundColor Red |
| 68 | + exit 1 |
| 69 | + } |
| 70 | + |
| 71 | + Write-Host "CMake installed successfully and added to PATH!" -ForegroundColor Green |
| 72 | + } else { |
| 73 | + Write-Host "CMake is already installed:" -ForegroundColor Green |
| 74 | + cmake --version |
| 75 | + } |
| 76 | +
|
| 77 | + - name: Build RyzenAI Server with CMake |
| 78 | + shell: PowerShell |
| 79 | + run: | |
| 80 | + $ErrorActionPreference = "Stop" |
| 81 | + |
| 82 | + Write-Host "Building ryzenai-server..." -ForegroundColor Cyan |
| 83 | + |
| 84 | + # Create build directory |
| 85 | + if (Test-Path "build") { |
| 86 | + Remove-Item -Recurse -Force "build" |
| 87 | + } |
| 88 | + mkdir build |
| 89 | + cd build |
| 90 | + |
| 91 | + # Configure - Ryzen AI should be at C:\Program Files\RyzenAI\1.6.0 |
| 92 | + cmake .. -G "Visual Studio 17 2022" -A x64 |
| 93 | + if ($LASTEXITCODE -ne 0) { |
| 94 | + Write-Host "ERROR: CMake configuration failed!" -ForegroundColor Red |
| 95 | + exit $LASTEXITCODE |
| 96 | + } |
| 97 | + |
| 98 | + # Build |
| 99 | + cmake --build . --config Release |
| 100 | + if ($LASTEXITCODE -ne 0) { |
| 101 | + Write-Host "ERROR: Build failed!" -ForegroundColor Red |
| 102 | + exit $LASTEXITCODE |
| 103 | + } |
| 104 | + |
| 105 | + # Verify binary exists |
| 106 | + if (-not (Test-Path "bin\Release\ryzenai-server.exe")) { |
| 107 | + Write-Host "ERROR: ryzenai-server.exe not found!" -ForegroundColor Red |
| 108 | + exit 1 |
| 109 | + } |
| 110 | + |
| 111 | + Write-Host "ryzenai-server build successful!" -ForegroundColor Green |
| 112 | +
|
| 113 | + - name: Verify RyzenAI Server build |
| 114 | + shell: PowerShell |
| 115 | + run: | |
| 116 | + $ErrorActionPreference = "Stop" |
| 117 | + |
| 118 | + $releaseDir = "build\bin\Release" |
| 119 | + |
| 120 | + Write-Host "Verifying ryzenai-server build output..." -ForegroundColor Cyan |
| 121 | + |
| 122 | + if (-not (Test-Path "$releaseDir\ryzenai-server.exe")) { |
| 123 | + Write-Host "ERROR: ryzenai-server.exe not found in $releaseDir" -ForegroundColor Red |
| 124 | + exit 1 |
| 125 | + } |
| 126 | + |
| 127 | + Write-Host "`nListing all files that will be uploaded:" -ForegroundColor Cyan |
| 128 | + Get-ChildItem $releaseDir -File | ForEach-Object { |
| 129 | + $sizeMB = [math]::Round($_.Length / 1MB, 2) |
| 130 | + Write-Host " - $($_.Name) ($sizeMB MB)" -ForegroundColor Gray |
| 131 | + } |
| 132 | + |
| 133 | + $fileCount = (Get-ChildItem $releaseDir -File | Measure-Object).Count |
| 134 | + Write-Host "`nFound $fileCount files in release directory" -ForegroundColor Green |
| 135 | + Write-Host "Contents will be uploaded as artifact (GitHub will zip automatically)" -ForegroundColor Gray |
| 136 | +
|
| 137 | + - name: Upload RyzenAI Server Package |
| 138 | + uses: actions/upload-artifact@v4 |
| 139 | + with: |
| 140 | + name: ryzenai-server |
| 141 | + path: | |
| 142 | + build/bin/Release/*.exe |
| 143 | + build/bin/Release/*.dll |
| 144 | + build/bin/Release/*.pdb |
| 145 | + build/bin/Release/AMD_LICENSE |
| 146 | + retention-days: 7 |
| 147 | + |
| 148 | + create-release: |
| 149 | + name: Create GitHub Release |
| 150 | + needs: build-ryzenai-server |
| 151 | + runs-on: ubuntu-latest |
| 152 | + if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true')) |
| 153 | + steps: |
| 154 | + - uses: actions/checkout@v4 |
| 155 | + with: |
| 156 | + fetch-depth: 0 |
| 157 | + |
| 158 | + - name: Get version from CMakeLists.txt |
| 159 | + id: get_version |
| 160 | + run: | |
| 161 | + VERSION=$(grep -oP 'project\(ryzenai-server VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) |
| 162 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 163 | + echo "Detected version: $VERSION" |
| 164 | +
|
| 165 | + - name: Download artifacts |
| 166 | + uses: actions/download-artifact@v4 |
| 167 | + with: |
| 168 | + name: ryzenai-server |
| 169 | + path: ryzenai-server-files |
| 170 | + |
| 171 | + - name: Create ryzenai-server.zip for release |
| 172 | + run: | |
| 173 | + cd ryzenai-server-files |
| 174 | + zip -r ../ryzenai-server.zip * |
| 175 | + cd .. |
| 176 | + ls -lh ryzenai-server.zip |
| 177 | +
|
| 178 | + - name: Create GitHub Release |
| 179 | + uses: softprops/action-gh-release@v2 |
| 180 | + with: |
| 181 | + tag_name: v${{ steps.get_version.outputs.version }} |
| 182 | + name: RyzenAI Server v${{ steps.get_version.outputs.version }} |
| 183 | + body: | |
| 184 | + ## RyzenAI Server v${{ steps.get_version.outputs.version }} |
| 185 | + |
| 186 | + OpenAI API-compatible server for running LLMs on AMD Ryzen AI NPUs. |
| 187 | + |
| 188 | + ### Installation |
| 189 | + |
| 190 | + Download `ryzenai-server.zip` and extract to your preferred location. |
| 191 | + |
| 192 | + ### Requirements |
| 193 | + |
| 194 | + - Windows 11 (64-bit) |
| 195 | + - AMD Ryzen AI 300-series processor |
| 196 | + - Ryzen AI Software 1.6.0 with LLM patch |
| 197 | + |
| 198 | + ### Usage |
| 199 | + |
| 200 | + ```cmd |
| 201 | + ryzenai-server.exe -m C:\path\to\onnx\model --mode hybrid |
| 202 | + ``` |
| 203 | + |
| 204 | + See the [README](https://github.com/lemonade-sdk/ryzenai-server#readme) for full documentation. |
| 205 | + files: ryzenai-server.zip |
| 206 | + draft: false |
| 207 | + prerelease: false |
| 208 | + env: |
| 209 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments