From 9f074243cb184f9fac2bef4bfe39d437960b4ba3 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Fri, 15 May 2026 16:53:49 +0200 Subject: [PATCH 01/10] Migrate to System.Text.Json (replace Newtonsoft.Json) SAM-BIM core migrated from Newtonsoft.Json to System.Text.Json.Nodes. - Replace each csproj's Newtonsoft package reference with System.Text.Json 10.0.8 - Variable / VariableType: FromJObject/ToJObject -> FromJsonObject/ToJsonObject; JObject -> JsonObject; .Value(key) -> indexer + 'as JsonObject'; .Value(key) -> indexer + Deserialize(); .Add(key, value as dynamic) -> .Add(key, JsonValue.Create(value)) Co-Authored-By: Claude Opus 4.7 --- .../SAM.Core.Grasshopper.Python.csproj | 2 +- .../SAM.Core.Python/Classes/Variable.cs | 19 ++++++++++--------- .../SAM.Core.Python/Classes/VariableType.cs | 16 ++++++++-------- .../SAM.Core.Python/SAM.Core.Python.csproj | 2 +- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj b/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj index 0508f8f..d448d0b 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj +++ b/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj @@ -31,7 +31,7 @@ - + diff --git a/SAM_Python/SAM.Core.Python/Classes/Variable.cs b/SAM_Python/SAM.Core.Python/Classes/Variable.cs index fc7eda2..1e735e6 100644 --- a/SAM_Python/SAM.Core.Python/Classes/Variable.cs +++ b/SAM_Python/SAM.Core.Python/Classes/Variable.cs @@ -1,6 +1,7 @@ -using Newtonsoft.Json.Linq; -using System; +using System; using System.Drawing; +using System.Text.Json; +using System.Text.Json.Nodes; namespace SAM.Core.Python { @@ -67,7 +68,7 @@ public object Value } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -76,30 +77,30 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("VariableType")) { - variableType = new VariableType(jObject.Value("VariableType")); + variableType = new VariableType(jObject["VariableType"] as JsonObject); } if (jObject.ContainsKey("Value")) { - value = jObject.Value("Value"); + value = jObject["Value"]?.Deserialize(); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Query.FullTypeName(this)); if (variableType != null) { - jObject.Add("VariableType", variableType.ToJObject()); + jObject.Add("VariableType", variableType.ToJsonObject()); } if (value != null) { - jObject.Add("Value", value as dynamic); + jObject.Add("Value", JsonValue.Create(value)); } return jObject; diff --git a/SAM_Python/SAM.Core.Python/Classes/VariableType.cs b/SAM_Python/SAM.Core.Python/Classes/VariableType.cs index 3250893..112431f 100644 --- a/SAM_Python/SAM.Core.Python/Classes/VariableType.cs +++ b/SAM_Python/SAM.Core.Python/Classes/VariableType.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json.Linq; +using System.Text.Json.Nodes; using System; namespace SAM.Core.Python @@ -16,9 +16,9 @@ public VariableType(VariableType variableType) name = variableType.name; } } - public VariableType(JObject jObject) + public VariableType(JsonObject jObject) { - FromJObject(jObject); + FromJsonObject(jObject); } public VariableType(Type type, string name) @@ -35,7 +35,7 @@ public string Name } } - public bool FromJObject(JObject jObject) + public bool FromJsonObject(JsonObject jObject) { if (jObject == null) { @@ -44,20 +44,20 @@ public bool FromJObject(JObject jObject) if (jObject.ContainsKey("Name")) { - name = jObject.Value("Name"); + name = jObject["Name"]?.GetValue() ?? default(string); } if (jObject.ContainsKey("Type")) { - type = Query.Type(jObject.Value("Type"), true); + type = Query.Type(jObject["Type"]?.GetValue() ?? default(string), true); } return true; } - public JObject ToJObject() + public JsonObject ToJsonObject() { - JObject jObject = new JObject(); + JsonObject jObject = new JsonObject(); jObject.Add("_type", Query.FullTypeName(this)); if (name != null) diff --git a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj index ec35367..0367e6d 100644 --- a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj +++ b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj @@ -23,7 +23,7 @@ - + From 4e601c8c697e40ea6c8f856ec5b78133d628cff5 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Fri, 15 May 2026 22:01:02 +0200 Subject: [PATCH 02/10] CI: prefer sow/2026-Q2 for dep clones + trigger on it During the SAM-BIM Newtonsoft.Json -> System.Text.Json migration the quarterly sow/2026-Q2 branch carries the binary-breaking change. CI needs to consume the migrated SAM (and any sibling dep) from sow/2026-Q2, not from master, until the quarter-end merge. - Add "sow/2026-Q2" to push/pull_request branch triggers - For each dep clone, ls-remote sow/2026-Q2 and prefer it when present; fall back to default branch (e.g. master) otherwise. After the quarter merges back to master, this fallback naturally restores prior behaviour. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/build.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b01de0f..83c991c 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/2026-Q2" ] pull_request: - branches: [ "master", "main" ] + branches: [ "master", "main", "sow/2026-Q2" ] workflow_dispatch: jobs: @@ -55,8 +55,15 @@ jobs: $deps = $buildOrder[0..($buildOrder.Count-2)] 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 + $preferredBranch = 'sow/2026-Q2' + $hasPreferred = (git ls-remote --heads "https://github.com/$org/$r.git" $preferredBranch 2>$null | Out-String).Trim() + if ($hasPreferred) { + Write-Host "Cloning $org/$r @ $preferredBranch" + git clone --depth 1 --branch $preferredBranch "https://github.com/$org/$r.git" $r + } else { + 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 From 082ae39d1caf4d9a69a9ae2474197537a89fc02b Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Fri, 15 May 2026 22:05:43 +0200 Subject: [PATCH 03/10] CI: cascade dep clones to PR head_ref -> sow/2026-Q2 -> default Refines the previous workflow patch so CI on the migration PR can succeed before anything has been merged. Each dep repo is cloned from: 1. github.head_ref (feature/remove-newtonsoft on these PRs) - has the migration right now on every dep 2. sow/2026-Q2 - source of truth after these PRs merge 3. default branch - source of truth after quarter-end merge Co-Authored-By: Claude Opus 4.7 --- .github/workflows/build.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83c991c..f1431d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,17 +55,27 @@ jobs: $deps = $buildOrder[0..($buildOrder.Count-2)] foreach ($r in $deps) { if (Test-Path $r) { continue } - $preferredBranch = 'sow/2026-Q2' - $hasPreferred = (git ls-remote --heads "https://github.com/$org/$r.git" $preferredBranch 2>$null | Out-String).Trim() - if ($hasPreferred) { - Write-Host "Cloning $org/$r @ $preferredBranch" - git clone --depth 1 --branch $preferredBranch "https://github.com/$org/$r.git" $r - } else { + $headRef = '${{ github.head_ref }}' + $candidates = @() + if ($headRef) { $candidates += $headRef } + $candidates += 'sow/2026-Q2' + $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 New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null From 2dc8c66e9ca7bfed619bbde67bf0d7de19dd0b77 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Fri, 15 May 2026 22:39:19 +0200 Subject: [PATCH 04/10] Add SPDX + copyright header to migration-touched files The SPDX-check workflow requires the top 6 lines of every changed .cs file to contain both: // SPDX-License-Identifier: LGPL-3.0-or-later // Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors (with an en-dash between the years). Migration commits modified existing files without preserving the header. Prepend the two lines now. Co-Authored-By: Claude Opus 4.7 --- SAM_Python/SAM.Core.Python/Classes/Variable.cs | 4 +++- SAM_Python/SAM.Core.Python/Classes/VariableType.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SAM_Python/SAM.Core.Python/Classes/Variable.cs b/SAM_Python/SAM.Core.Python/Classes/Variable.cs index 1e735e6..fbc22c4 100644 --- a/SAM_Python/SAM.Core.Python/Classes/Variable.cs +++ b/SAM_Python/SAM.Core.Python/Classes/Variable.cs @@ -1,4 +1,6 @@ -using System; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System; using System.Drawing; using System.Text.Json; using System.Text.Json.Nodes; diff --git a/SAM_Python/SAM.Core.Python/Classes/VariableType.cs b/SAM_Python/SAM.Core.Python/Classes/VariableType.cs index 112431f..997be2e 100644 --- a/SAM_Python/SAM.Core.Python/Classes/VariableType.cs +++ b/SAM_Python/SAM.Core.Python/Classes/VariableType.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Nodes; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors +using System.Text.Json.Nodes; using System; namespace SAM.Core.Python From 75fd44e41a7d9c90bb24a126de62f55c74b57cd0 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Fri, 15 May 2026 22:51:41 +0200 Subject: [PATCH 05/10] CI: harmonize spdx-check.yml with org-canonical Version A template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the older spdx-check.yml (literal en-dash grep, top 6 lines, PR-only trigger) with the modern template shipped on SAM core: - grep -qE with [-–] char class — accepts both hyphen-minus and en-dash - 20-line lookback (was 6) - BOM and CR stripping - mapfile + diff-filter for cleaner change detection - Adds workflow_dispatch trigger Co-Authored-By: Claude Opus 4.7 --- .github/workflows/spdx-check.yml | 81 +++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/.github/workflows/spdx-check.yml b/.github/workflows/spdx-check.yml index 269d562..e386bd3 100644 --- a/.github/workflows/spdx-check.yml +++ b/.github/workflows/spdx-check.yml @@ -2,44 +2,89 @@ name: SPDX + Copyright header check on: pull_request: + workflow_dispatch: jobs: spdx: runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v5 with: fetch-depth: 0 - name: Check header in changed .cs files + shell: bash run: | - set -e - BASE="${{ github.event.pull_request.base.sha }}" - HEAD="${{ github.event.pull_request.head.sha }}" + set -euo pipefail + + if [ "${{ github.event_name }}" = "pull_request" ]; then + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.event.pull_request.head.sha }}" + else + HEAD="${{ github.sha }}" + BASE="$(git rev-parse "${HEAD}^" 2>/dev/null || true)" + fi - FILES=$(git diff --name-only "$BASE" "$HEAD" -- '*.cs' || true) + echo "Base SHA: ${BASE:-}" + echo "Head SHA: $HEAD" + echo - if [ -z "$FILES" ]; then + if [ -z "${BASE:-}" ]; then + mapfile -t files < <(git ls-files '*.cs') + else + mapfile -t files < <(git diff --diff-filter=ACMR --name-only "$BASE" "$HEAD" -- '*.cs' || true) + fi + + if [ "${#files[@]}" -eq 0 ]; then echo "No C# files changed." exit 0 fi - MISSING="" - for f in $FILES; do - HEADBLOCK=$(head -n 6 "$f") + echo "Changed C# files:" + printf ' - %s\n' "${files[@]}" + echo + + missing=() + + for f in "${files[@]}"; do + if [ ! -f "$f" ]; then + echo "Skipping missing file: $f" + continue + fi + + headblock="$(head -n 20 "$f" | sed '1s/^\xEF\xBB\xBF//' | tr -d '\r')" + + echo "Checking: $f" + + if ! grep -q "SPDX-License-Identifier: LGPL-3.0-or-later" <<< "$headblock"; then + echo " Missing SPDX line" + missing+=("$f") + continue + fi + + if ! grep -qE "Copyright \(c\) 2020[-–]2026 Michal Dengusiak & Jakub Ziolkowski and contributors" <<< "$headblock"; then + echo " Missing copyright line" + missing+=("$f") + continue + fi - echo "$HEADBLOCK" | grep -q "// SPDX-License-Identifier: LGPL-3.0-or-later" || MISSING="$MISSING $f" - echo "$HEADBLOCK" | grep -q "// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors" || MISSING="$MISSING $f" + echo " OK" done - if [ -n "$MISSING" ]; then - echo "❌ Missing required header in:" - for f in $MISSING; do echo " - $f"; done - echo "" - echo "Each changed .cs file must start with:" + echo + if [ "${#missing[@]}" -gt 0 ]; then + echo "Missing required header in:" + printf ' - %s\n' "${missing[@]}" + echo + echo "Each checked .cs file must contain within the first 20 lines:" echo "// SPDX-License-Identifier: LGPL-3.0-or-later" - echo "// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors" + echo "// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors" exit 1 fi - echo "✅ SPDX + copyright headers OK." + echo "SPDX + copyright headers OK." \ No newline at end of file From d677aa96eca5a126593c86430bb1f841a8f73695 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 09:57:52 +0200 Subject: [PATCH 06/10] Pin System.Text.Json to 8.0.5 Aligns the repo with the SAM-BIM workspace-wide pin to the LTS-aligned System.Text.Json 8.0.5, replacing the previously pinned 10.0.8 preview. --- .../SAM.Core.Grasshopper.Python.csproj | 2 +- SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj b/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj index d448d0b..56ab367 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj +++ b/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj @@ -31,7 +31,7 @@ - + diff --git a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj index 0367e6d..0a02f87 100644 --- a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj +++ b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj @@ -23,7 +23,7 @@ - + From 1220a65e4694d68c07db7480f7d28d9e5437a2c7 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 13:35:35 +0200 Subject: [PATCH 07/10] fix: pin AssemblyVersion/FileVersion to 1.0.0.0 (#3) * fix: pin AssemblyVersion/FileVersion to 1.0.0.0 (drop 1.0.* wildcard) Eliminates CS1607 warnings and restores deterministic builds. Aligns with the workspace's existing fixed-version files. Scope: AssemblyInfo.cs + .csproj version attributes only. The // commented-out template example is left intact for documentation. * fix: add SPDX + copyright header to modified AssemblyInfo.cs and refresh .csproj Satisfies the spdx-check workflow which requires every changed .cs file to declare the LGPL-3.0-or-later SPDX identifier and the 2020-2026 attribution in its first 20 lines. Also updates the stale 'Copyright (c) 2020' line in .csproj files to match the SPDX header style. --- .../Properties/AssemblyInfo.cs | 8 +++++--- SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs index 2544fa5..0c0032f 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs @@ -1,4 +1,6 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * @@ -54,5 +56,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyFileVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj index 0a02f87..52c52e8 100644 --- a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj +++ b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj @@ -6,9 +6,9 @@ false SAM SAM - Copyright © 2020 - 1.0.%2a - 1.0.%2a + Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors + 1.0.0.0 + 1.0.0.0 false false From f896c874f7886fc83a2a4c2636d662fd1bb32536 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Wed, 20 May 2026 21:15:36 +0200 Subject: [PATCH 08/10] build: Directory.Build.props for centralised SAMVersion stamping (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * build: Directory.Build.props for centralised SAMVersion stamping Mirrors SAM-BIM/SAM#7. Stage 2 of the AssemblyVersion versioning migration. * 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'. * 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). * ci: Codex P2 fixes — four-part SAMVersion, prefer head_ref for sow PRs - 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 | 40 ++++++++++++++++++- Directory.Build.props | 39 ++++++++++++++++++ .../Kernel/AssemblyInfo.cs | 5 ++- .../Properties/AssemblyInfo.cs | 3 -- .../SAM.Core.Grasshopper.Python.csproj | 1 - .../Properties/AssemblyInfo.cs | 5 ++- .../SAM.Core.Python/SAM.Core.Python.csproj | 3 -- 7 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 Directory.Build.props diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f1431d9..63aaffa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build (Windows) on: push: - branches: [ "master", "main", "sow/2026-Q2" ] + branches: [ "master", "main", "sow/**" ] pull_request: - branches: [ "master", "main", "sow/2026-Q2" ] + branches: [ "master", "main", "sow/**" ] workflow_dispatch: jobs: @@ -35,6 +35,36 @@ jobs: - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 + - name: Compute SAMVersion + id: ver + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + # 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.0" + $src = "branch '$ref'" + } else { + $now = (Get-Date).ToUniversalTime() + $quarter = [int][Math]::Ceiling($now.Month / 3.0) + $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)" + "samversion=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 - name: Clone dependency repos (siblings) shell: pwsh @@ -56,8 +86,13 @@ jobs: foreach ($r in $deps) { if (Test-Path $r) { continue } $headRef = '${{ github.head_ref }}' + $baseRef = '${{ github.base_ref }}' + $refName = '${{ github.ref_name }}' $candidates = @() if ($headRef) { $candidates += $headRef } + # Current sow branch: base_ref on PR events, ref_name on push events. + $sowRef = if ($baseRef -match '^sow/') { $baseRef } elseif ($refName -match '^sow/') { $refName } else { '' } + if ($sowRef -and $sowRef -ne $headRef) { $candidates += $sowRef } $candidates += 'sow/2026-Q2' $cloned = $false foreach ($cand in $candidates) { @@ -94,6 +129,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/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..9841655 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,39 @@ + + + + + 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)")]" /> + + + + + + + + + + diff --git a/Grasshopper/SAM.Core.Grasshopper.Python/Kernel/AssemblyInfo.cs b/Grasshopper/SAM.Core.Grasshopper.Python/Kernel/AssemblyInfo.cs index 78cfa0d..cd48b47 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Python/Kernel/AssemblyInfo.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Python/Kernel/AssemblyInfo.cs @@ -1,4 +1,7 @@ -using Grasshopper.Kernel; +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +using Grasshopper.Kernel; using SAM.Core.Grasshopper.Python.Properties; using System; using System.Drawing; diff --git a/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs b/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs index 0c0032f..874d4fa 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs +++ b/Grasshopper/SAM.Core.Grasshopper.Python/Properties/AssemblyInfo.cs @@ -55,6 +55,3 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj b/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj index 56ab367..1e891af 100644 --- a/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj +++ b/Grasshopper/SAM.Core.Grasshopper.Python/SAM.Core.Grasshopper.Python.csproj @@ -11,7 +11,6 @@ true true C:\Program Files\Rhino 8\System\Rhino.exe - false false false True diff --git a/SAM_Python/SAM.Core.Python/Properties/AssemblyInfo.cs b/SAM_Python/SAM.Core.Python/Properties/AssemblyInfo.cs index cf1e05d..2fa9aca 100644 --- a/SAM_Python/SAM.Core.Python/Properties/AssemblyInfo.cs +++ b/SAM_Python/SAM.Core.Python/Properties/AssemblyInfo.cs @@ -1,4 +1,7 @@ -/* +// SPDX-License-Identifier: LGPL-3.0-or-later +// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors + +/* * This file is part of the Sustaiable Analytical Model (SAM) * Copyright (c) 2020, the respective contributors. All rights reserved. * diff --git a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj index 52c52e8..837ae6b 100644 --- a/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj +++ b/SAM_Python/SAM.Core.Python/SAM.Core.Python.csproj @@ -2,13 +2,10 @@ netstandard2.0 Library - false false SAM SAM Copyright (c) 2020-2026 Michal Dengusiak & Jakub Ziolkowski and contributors - 1.0.0.0 - 1.0.0.0 false false From 8c470e45fbdc207621a13ba5dc7d304a88803595 Mon Sep 17 00:00:00 2001 From: Michal Dengusiak Date: Thu, 21 May 2026 10:19:42 +0200 Subject: [PATCH 09/10] build: emit AssemblyInformationalVersion for non-SDK projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors SAM sow/2026-Q2. Adds AssemblyInformationalVersion attribute generation to Path D's SAMVersion.g.cs Target — covers Grasshopper / Tas-bridge assemblies that have GenerateAssemblyInfo=false, so they also get the CI commit SHA stamp in their ProductVersion field. SDK projects pick up InformationalVersion via PropertyGroup auto-gen as before. Local dev builds unchanged. --- Directory.Build.props | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 9841655..b6b921f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,10 +1,17 @@ - + 1.0.0.0 $(SAMVersion) $(SAMVersion) + + $(SAMVersion)+$(SAMSourceRevision) true @@ -23,6 +30,9 @@ <_SAMVersionLine Include="// <auto-generated />" /> <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyVersionAttribute("$(SAMVersion)")]" /> <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyFileVersionAttribute("$(SAMVersion)")]" /> + + <_SAMVersionLine Include="[assembly: System.Reflection.AssemblyInformationalVersionAttribute("$(InformationalVersion)")]" Condition="'$(InformationalVersion)' != ''" /> Date: Thu, 21 May 2026 12:52:27 +0200 Subject: [PATCH 10/10] build: emit AssemblyInformationalVersion for non-SDK projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors SAM sow/2026-Q2. Adds AssemblyInformationalVersion attribute generation to Path D's SAMVersion.g.cs Target — covers Grasshopper / Tas-bridge assemblies that have GenerateAssemblyInfo=false, so they also get the CI commit SHA stamp in their ProductVersion field. SDK projects pick up InformationalVersion via PropertyGroup auto-gen as before. Local dev builds unchanged. --- Directory.Build.props | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index b6b921f..509f4c6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,6 +12,14 @@ that and don't overwrite. Local dev builds leave both empty -> no SHA attribute emitted. --> $(SAMVersion)+$(SAMSourceRevision) + + false true