|
| 1 | +name: Build (Windows) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master", "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "master", "main" ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + # Guard: if this workflow ever gets merged upstream (e.g. HoareLea), |
| 13 | + # it will show as "skipped" there and won't break their CI. |
| 14 | + if: github.repository_owner == 'SAM-BIM' |
| 15 | + runs-on: windows-2022 |
| 16 | + |
| 17 | + env: |
| 18 | + MSBUILDDISABLENODEREUSE: "1" |
| 19 | + ORG_NAME: "SAM-BIM" |
| 20 | + # >>> CHANGE THIS PER REPO <<< |
| 21 | + # Examples: SAM, SAM_gbXML, SAM_GEM, SAM_Tas, ... |
| 22 | + REPO_NAME: "SAM_MachineLearning" |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout this repo |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + fetch-depth: 0 |
| 29 | + path: ${{ env.REPO_NAME }} |
| 30 | + |
| 31 | + - name: Setup .NET 8 |
| 32 | + uses: actions/setup-dotnet@v4 |
| 33 | + with: |
| 34 | + dotnet-version: "8.x" |
| 35 | + |
| 36 | + - name: Setup MSBuild |
| 37 | + uses: microsoft/setup-msbuild@v2 |
| 38 | + |
| 39 | + - name: Clone dependency repos (siblings) |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + $ErrorActionPreference = 'Stop' |
| 43 | +
|
| 44 | + $org = '${{ env.ORG_NAME }}' |
| 45 | + $repo = '${{ env.REPO_NAME }}' |
| 46 | +
|
| 47 | + # >>> ADJUST BUILD ORDER HERE IF NEEDED <<< |
| 48 | + # Keep the current repo LAST. |
| 49 | + $buildOrder = @( |
| 50 | + $repo |
| 51 | + ) |
| 52 | +
|
| 53 | + # Clone everything except the last one (already checked out by Actions) |
| 54 | + $deps = $buildOrder[0..($buildOrder.Count-2)] |
| 55 | + foreach ($r in $deps) { |
| 56 | + if (Test-Path $r) { continue } |
| 57 | + Write-Host "Cloning https://github.com/$org/$r.git" |
| 58 | + git clone --depth 1 "https://github.com/$org/$r.git" $r |
| 59 | + } |
| 60 | +
|
| 61 | + # Ensure ReferencePath exists even before SAM_Windows builds |
| 62 | + New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null |
| 63 | +
|
| 64 | + - name: Restore + Rebuild in order (CI props like SAM_Deploy) |
| 65 | + shell: pwsh |
| 66 | + run: | |
| 67 | + $ErrorActionPreference = 'Stop' |
| 68 | +
|
| 69 | + $repo = '${{ env.REPO_NAME }}' |
| 70 | + $windowsRef = (Resolve-Path 'SAM_Windows\build').Path |
| 71 | +
|
| 72 | + # IMPORTANT: keep these as an ARRAY of args (do NOT join into one string) |
| 73 | + $common = @( |
| 74 | + '/m:1' |
| 75 | + '/nr:false' |
| 76 | + '/v:m' |
| 77 | + '/p:Configuration=Release' |
| 78 | + '/p:UseSharedCompilation=false' |
| 79 | + '/p:RunPostBuildEvent=OnOutputUpdated' |
| 80 | + "/p:ReferencePath=$windowsRef" |
| 81 | + ) |
| 82 | +
|
| 83 | + # If you really want Platform, use QUOTED Any CPU: |
| 84 | + # $common += '/p:Platform="Any CPU"' |
| 85 | +
|
| 86 | + # Same build order as above (keep repo LAST) |
| 87 | + $buildOrder = @( |
| 88 | + $repo |
| 89 | + ) |
| 90 | +
|
| 91 | + # Convert build order -> solution paths (robust: first .sln in each folder) |
| 92 | + $solutions = foreach ($r in $buildOrder) { |
| 93 | + $sln = Get-ChildItem -Path $r -Filter *.sln -File | Select-Object -First 1 |
| 94 | + if (-not $sln) { throw "No .sln found under: $r" } |
| 95 | + $sln.FullName |
| 96 | + } |
| 97 | +
|
| 98 | + foreach ($sln in $solutions) { |
| 99 | + Write-Host "==> Restore: $sln" |
| 100 | + & msbuild $sln /t:Restore @common |
| 101 | + } |
| 102 | +
|
| 103 | + foreach ($sln in $solutions) { |
| 104 | + Write-Host "==> Rebuild: $sln" |
| 105 | + & msbuild $sln /t:Rebuild @common |
| 106 | + } |
| 107 | +
|
| 108 | + - name: Upload build folders (optional) |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: ${{ env.REPO_NAME }}-build-folders |
| 112 | + path: | |
| 113 | + **\build\* |
| 114 | + if-no-files-found: warn |
0 commit comments