|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: windows-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Setup MSBuild |
| 17 | + uses: microsoft/setup-msbuild@v2 |
| 18 | + |
| 19 | + - name: Setup NuGet |
| 20 | + uses: NuGet/setup-nuget@v2 |
| 21 | + |
| 22 | + - name: Restore NuGet packages |
| 23 | + run: nuget restore BundleManager.sln |
| 24 | + |
| 25 | + - name: Build solution |
| 26 | + run: msbuild BundleManager.sln /m /p:Configuration=Release |
| 27 | + |
| 28 | + - name: Remove debug symbols and non-Windows binaries |
| 29 | + shell: pwsh |
| 30 | + run: | |
| 31 | + $patterns = @('*.pdb', '*.dylib', '*.so') |
| 32 | + foreach ($pattern in $patterns) { |
| 33 | + Get-ChildItem -Path . -Recurse -File -Filter $pattern | |
| 34 | + Where-Object { $_.FullName -match '\\(bin|obj)\\Release\\' } | |
| 35 | + Remove-Item -Force -ErrorAction SilentlyContinue |
| 36 | + } |
| 37 | +
|
| 38 | + - name: Remove empty folders recursively |
| 39 | + shell: pwsh |
| 40 | + run: | |
| 41 | + $roots = Get-ChildItem -Path . -Directory -Recurse | |
| 42 | + Where-Object { $_.FullName -match '\\(bin|obj)\\Release(\\|$)' } |
| 43 | +
|
| 44 | + do { |
| 45 | + $removed = 0 |
| 46 | + $emptyDirs = $roots | |
| 47 | + Sort-Object { $_.FullName.Length } -Descending | |
| 48 | + Where-Object { $_.Exists } | |
| 49 | + Where-Object { (Get-ChildItem -Path $_.FullName -Force | Measure-Object).Count -eq 0 } |
| 50 | +
|
| 51 | + foreach ($dir in $emptyDirs) { |
| 52 | + Remove-Item -Path $dir.FullName -Force -ErrorAction SilentlyContinue |
| 53 | + $removed++ |
| 54 | + } |
| 55 | + } while ($removed -gt 0) |
| 56 | +
|
| 57 | + - name: Upload build artifacts |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: BundleManager-Release |
| 61 | + if-no-files-found: warn |
| 62 | + path: | |
| 63 | + **/bin/Release/** |
| 64 | + **/obj/Release/** |
0 commit comments