From 35ef3c34feec4a7baeb5c6474aab9123b8006adf Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 19:59:40 +0200 Subject: [PATCH 1/5] build: Directory.Build.props for centralised SAMVersion stamping Mirrors SAM-BIM/SAM#7. Stage 2 of the AssemblyVersion versioning migration. --- .github/workflows/build.yml | 24 +++++++++++++-- Application/SAM Analytical/AssemblyInfo.cs | 3 ++ Directory.Build.props | 36 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 Directory.Build.props diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 884d8b0..d2e8160 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build (Windows) on: push: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/**" ] pull_request: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/**" ] workflow_dispatch: jobs: @@ -35,6 +35,25 @@ jobs: - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 + - name: Compute SAMVersion + id: ver + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + $ref = if ('${{ github.event_name }}' -eq 'pull_request') { '${{ github.base_ref }}' } else { '${{ github.ref_name }}' } + # .NET AssemblyVersion components are UInt16 (max 65535). Cap to 60000 for headroom. + $run = ${{ github.run_number }} % 60000 + if ($ref -match 'sow/(\d{4})-Q(\d)') { + $v = "$($Matches[1]).$($Matches[2]).$run" + $src = "branch '$ref'" + } else { + $now = (Get-Date).ToUniversalTime() + $quarter = [int][Math]::Ceiling($now.Month / 3.0) + $v = "$($now.Year).$quarter.$run" + $src = "date $($now.ToString('yyyy-MM-dd')) (ref '$ref' not sow/yyyy-Qx)" + } + Write-Host "SAMVersion = $v (from $src)" + "samversion=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 - name: Clone dependency repos (siblings) shell: pwsh @@ -76,6 +95,7 @@ jobs: '/v:m' '/p:Configuration=Release' '/p:UseSharedCompilation=false' + '/p:SAMVersion=${{ steps.ver.outputs.samversion }}' '/p:RunPostBuildEvent=OnOutputUpdated' "/p:ReferencePath=$windowsRef" ) diff --git a/Application/SAM Analytical/AssemblyInfo.cs b/Application/SAM Analytical/AssemblyInfo.cs index b0ec827..72bb068 100644 --- a/Application/SAM Analytical/AssemblyInfo.cs +++ b/Application/SAM Analytical/AssemblyInfo.cs @@ -1,3 +1,6 @@ +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020u{2013}2026 Michal Dengusiak & Jakub Ziolkowski and contributors + using System.Windows; [assembly: ThemeInfo( diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..bd157b1 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,36 @@ + + + + + 1.0.0.0 + $(SAMVersion) + $(SAMVersion) + true + + + + + + <_SAMVersionLine Include="// <auto-generated />" /> + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyVersionAttribute("$(SAMVersion)")]" /> + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyFileVersionAttribute("$(SAMVersion)")]" /> + + + + + + + + + + From a98ef1e5bb394b95e1891230dd0ba48f319855c6 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 20:12:21 +0200 Subject: [PATCH 2/5] fix: replace literal u{2013} escape with actual en-dash in SPDX header PowerShell 5.1 doesn't support backtick-u escape sequences; the apply-stage2.ps1 script leaked them as literal text in 'Copyright (c) 2020u{2013}2026'. --- Application/SAM Analytical/AssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/SAM Analytical/AssemblyInfo.cs b/Application/SAM Analytical/AssemblyInfo.cs index 72bb068..ce27608 100644 --- a/Application/SAM Analytical/AssemblyInfo.cs +++ b/Application/SAM Analytical/AssemblyInfo.cs @@ -1,5 +1,5 @@ // SPDX-License-Identifier: LGPL-3.0-or-later -// Copyright (c) 2020u{2013}2026 Michal Dengusiak & Jakub Ziolkowski and contributors +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors using System.Windows; From 2011814d35ddd7ef4068446dce8c26964a74ad6b Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 20:36:20 +0200 Subject: [PATCH 3/5] fix: relax SAMVersion.g.cs Target condition to != 'true' Codex P1 on SAM_LadybugTools#4: classic (non-SDK) csprojs don't set GenerateAssemblyInfo at all, so the previous '== false' condition skipped them. Switching to '!= true' catches both GenerateAssemblyInfo=false (SDK projects with legacy AssemblyInfo.cs) AND empty (classic projects). --- Directory.Build.props | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index bd157b1..9841655 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,13 +9,16 @@ + Condition="'$(GenerateAssemblyInfo)' != 'true'"> <_SAMVersionLine Include="// <auto-generated />" /> <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyVersionAttribute("$(SAMVersion)")]" /> From e59cd26bfd1306a0cc63d4593f1a773dc01ccdbe Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 20:40:00 +0200 Subject: [PATCH 4/5] =?UTF-8?q?ci:=20Codex=20P2=20fixes=20=E2=80=94=20four?= =?UTF-8?q?-part=20SAMVersion,=20prefer=20head=5Fref=20for=20sow=20PRs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Append .0 so SAMVersion is 4-part (AssemblyFileVersion expects 4 parts). - Prefer github.head_ref when it matches sow/yyyy-Qx (release-promotion PRs). - Mirrors SAM sow/2026-Q2 6d87d98e. --- .github/workflows/build.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2e8160..4d5a1c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,16 +40,27 @@ jobs: shell: pwsh run: | $ErrorActionPreference = 'Stop' - $ref = if ('${{ github.event_name }}' -eq 'pull_request') { '${{ github.base_ref }}' } else { '${{ github.ref_name }}' } + # Prefer head_ref when its a sow branch (release-promotion PRs from sow/* to main), + # else use base_ref on PR events / ref_name on push events. + $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' + if ($headRef -match '^sow/\d{4}-Q\d$') { + $ref = $headRef + } elseif ('${{ github.event_name }}' -eq 'pull_request') { + $ref = $baseRef + } else { + $ref = $refName + } # .NET AssemblyVersion components are UInt16 (max 65535). Cap to 60000 for headroom. $run = ${{ github.run_number }} % 60000 if ($ref -match 'sow/(\d{4})-Q(\d)') { - $v = "$($Matches[1]).$($Matches[2]).$run" + $v = "$($Matches[1]).$($Matches[2]).$run.0" $src = "branch '$ref'" } else { $now = (Get-Date).ToUniversalTime() $quarter = [int][Math]::Ceiling($now.Month / 3.0) - $v = "$($now.Year).$quarter.$run" + $v = "$($now.Year).$quarter.$run.0" $src = "date $($now.ToString('yyyy-MM-dd')) (ref '$ref' not sow/yyyy-Qx)" } Write-Host "SAMVersion = $v (from $src)" From 5c58fc2eee3279a1df0f64b2ca065d61c6c75c4f Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 20:47:06 +0200 Subject: [PATCH 5/5] ci: upgrade dep-clone to candidate-based with sow branch resolution Codex P1 from SAM_Excel#3: simple clone defaults to remote HEAD, mismatches sow branches. Mirrors fix in SAM_Excel. --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4d5a1c9..c69eb13 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -82,10 +82,32 @@ jobs: # Clone everything except the last one (already checked out by Actions) $deps = $buildOrder[0..($buildOrder.Count-2)] + # Branch resolution: prefer PR head_ref, then current sow branch, then sow/2026-Q2 fallback. + $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' + $candidates = @() + if ($headRef) { $candidates += $headRef } + $sowRef = if ($baseRef -match '^sow/') { $baseRef } elseif ($refName -match '^sow/') { $refName } else { '' } + if ($sowRef -and $sowRef -ne $headRef) { $candidates += $sowRef } + $candidates += 'sow/2026-Q2' + foreach ($r in $deps) { if (Test-Path $r) { continue } - Write-Host "Cloning https://github.com/$org/$r.git" - git clone --depth 1 "https://github.com/$org/$r.git" $r + $cloned = $false + foreach ($cand in $candidates) { + $has = (git ls-remote --heads "https://github.com/$org/$r.git" $cand 2>$null | Out-String).Trim() + if ($has) { + Write-Host "Cloning $org/$r @ $cand" + git clone --depth 1 --branch $cand "https://github.com/$org/$r.git" $r + $cloned = $true + break + } + } + if (-not $cloned) { + Write-Host "Cloning $org/$r @ default branch" + git clone --depth 1 "https://github.com/$org/$r.git" $r + } } # Ensure ReferencePath exists even before SAM_Windows builds