|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master ] |
| 6 | + tags: [ 'v*' ] |
| 7 | + pull_request: |
| 8 | + branches: [ main, master ] |
| 9 | + |
| 10 | +env: |
| 11 | + # Adjust these paths if your repo root has a subfolder around the solution. |
| 12 | + SLN_PATH: PES5_WE9_LE_CameraTool.sln |
| 13 | + TEST_DLL: PES5_WE9_LE_CameraTool.Tests\bin\Release\PES5_WE9_LE_CameraTool.Tests.dll |
| 14 | + APP_RELEASE_DIR: PES5_WE9_LE_CameraTool\bin\Release |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-test: |
| 18 | + runs-on: windows-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Setup MSBuild |
| 25 | + uses: microsoft/setup-msbuild@v2 |
| 26 | + |
| 27 | + - name: Enable .NET Framework 3.5 (Windows Feature) |
| 28 | + run: dism /online /enable-feature /featurename:NetFx3 /All |
| 29 | + shell: powershell |
| 30 | + |
| 31 | + - name: Setup NuGet |
| 32 | + uses: NuGet/setup-nuget@v2 |
| 33 | + |
| 34 | + - name: Cache NuGet packages |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: | |
| 38 | + packages |
| 39 | + key: nuget-${{ hashFiles('**/packages.config') }} |
| 40 | + |
| 41 | + - name: NuGet restore (solution) |
| 42 | + run: nuget restore "${{ env.SLN_PATH }}" |
| 43 | + |
| 44 | + - name: Build Release |
| 45 | + run: msbuild "${{ env.SLN_PATH }}" /p:Configuration=Release /m |
| 46 | + |
| 47 | + - name: Install NUnit Console Runner (CLI) |
| 48 | + run: nuget install NUnit.ConsoleRunner -Version 3.17.0 -OutputDirectory .\testrunner |
| 49 | + |
| 50 | + - name: Run NUnit tests |
| 51 | + shell: powershell |
| 52 | + run: | |
| 53 | + $runner = Get-ChildItem -Recurse -Path . -Filter "nunit3-console.exe" | Select-Object -First 1 |
| 54 | + if (-not $runner) { throw "nunit3-console.exe not found. NuGet install failed?" } |
| 55 | +
|
| 56 | + $dll = "${{ env.TEST_DLL }}" |
| 57 | + if (!(Test-Path $dll)) { throw "Test assembly not found at $dll" } |
| 58 | +
|
| 59 | + & $runner.FullName $dll --noheader --framework:net-3.5 --result:"TestResult.xml;format=nunit2" |
| 60 | + if ($LASTEXITCODE -ne 0) { throw "Tests failed with exit code $LASTEXITCODE" } |
| 61 | +
|
| 62 | + - name: Upload test results |
| 63 | + if: always() |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: nunit-results |
| 67 | + path: TestResult.xml |
| 68 | + |
| 69 | + - name: Package Release binaries |
| 70 | + if: always() |
| 71 | + shell: powershell |
| 72 | + run: | |
| 73 | + $dir = "${{ env.APP_RELEASE_DIR }}" |
| 74 | + if (!(Test-Path $dir)) { throw "Release output not found: $dir" } |
| 75 | +
|
| 76 | + $zip = "CameraTool_Release.zip" |
| 77 | + if (Test-Path $zip) { Remove-Item $zip -Force } |
| 78 | + Compress-Archive -Path "$dir\*" -DestinationPath $zip -Force |
| 79 | + Write-Host "Created $zip" |
| 80 | +
|
| 81 | + - name: Upload Release artifact |
| 82 | + if: always() |
| 83 | + uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: CameraTool_Release |
| 86 | + path: CameraTool_Release.zip |
| 87 | + |
| 88 | + release: |
| 89 | + runs-on: windows-latest |
| 90 | + needs: build-test |
| 91 | + if: startsWith(github.ref, 'refs/tags/v') |
| 92 | + steps: |
| 93 | + - name: Checkout |
| 94 | + uses: actions/checkout@v4 |
| 95 | + |
| 96 | + - name: Download packaged binaries |
| 97 | + uses: actions/download-artifact@v4 |
| 98 | + with: |
| 99 | + name: CameraTool_Release |
| 100 | + path: . |
| 101 | + |
| 102 | + - name: Create GitHub Release |
| 103 | + uses: softprops/action-gh-release@v2 |
| 104 | + with: |
| 105 | + files: CameraTool_Release.zip |
| 106 | + env: |
| 107 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments