Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 66 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build (Windows) - SAM_Revit (2025/2026)

on:
push:
branches: [ "master", "main" ]
branches: [ "master", "main", "sow/**" ]
pull_request:
branches: [ "master", "main" ]
branches: [ "master", "main", "sow/**" ]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -39,6 +39,36 @@ jobs:
uses: nuget/setup-nuget@v2
with:
nuget-version: "6.x"
- 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) + build order
shell: powershell
Expand Down Expand Up @@ -85,7 +115,37 @@ jobs:
'SAM_Revit_UI'
)

foreach ($r in $deps) { Clone-Repo $r }
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'
# Use the auth-token form so private deps (e.g. SAM_Solver) don't prompt
Comment on lines +120 to +129
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Select dependencies from the active branch context

When this workflow runs on push or workflow_dispatch, github.head_ref is empty, so the candidate list becomes only sow/2026-Q2 (then default). Because line 93 unconditionally prioritizes sow/2026-Q2, builds on master/main will clone and compile dependency repos from that quarter branch whenever it exists, instead of the branch being validated. This can mask real integration breakages (or create false failures) by testing SAM_Revit against mismatched dependency revisions.

Useful? React with 👍 / 👎.

$url = if ($token) { "https://$token@github.com/$org/$r.git" } else { "https://github.com/$org/$r.git" }
$cloned = $false
foreach ($cand in $candidates) {
$has = (git ls-remote --heads $url $cand 2>$null | Out-String).Trim()
if ($has) {
Write-Host "Cloning $org/$r @ $cand"
git clone --depth 1 --branch $cand $url $r
if ($LASTEXITCODE -ne 0) { throw "Failed to clone $r @ $cand" }
$cloned = $true
break
}
}
if (-not $cloned) {
Write-Host "Cloning $org/$r @ default branch"
git clone --depth 1 $url $r
if ($LASTEXITCODE -ne 0) { throw "Failed to clone $r" }
}
}


# Ensure build folders exist (some projects expect these paths)
New-Item -ItemType Directory -Force -Path "SAM_Windows\build" | Out-Null
Expand Down Expand Up @@ -147,6 +207,7 @@ jobs:
'/nr:false'
'/v:m'
'/p:UseSharedCompilation=false'
'/p:SAMVersion=${{ steps.ver.outputs.samversion }}'
'/p:RunPostBuildEvent=OnOutputUpdated'
)

Expand Down Expand Up @@ -220,6 +281,7 @@ jobs:
'/nr:false'
'/v:m'
'/p:UseSharedCompilation=false'
'/p:SAMVersion=${{ steps.ver.outputs.samversion }}'
'/p:RunPostBuildEvent=OnOutputUpdated'
"/p:Configuration=$cfg"
'/p:Platform=Any CPU'
Expand Down Expand Up @@ -307,6 +369,7 @@ jobs:
'/nr:false'
'/v:m'
'/p:UseSharedCompilation=false'
'/p:SAMVersion=${{ steps.ver.outputs.samversion }}'
'/p:RunPostBuildEvent=OnOutputUpdated'
"/p:Configuration=$cfg"
'/p:Platform=Any CPU'
Expand Down
57 changes: 57 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<Project>

<PropertyGroup>
<!-- Local dev builds default to 1.0.0.0. CI passes /p:SAMVersion=YYYY.Q.<run_number>.0. -->
<SAMVersion Condition="'$(SAMVersion)' == ''">1.0.0.0</SAMVersion>
<AssemblyVersion>$(SAMVersion)</AssemblyVersion>
<FileVersion>$(SAMVersion)</FileVersion>
<!--
InformationalVersion: the content-identity stamp (SemVer +build metadata).
Composed from SAMVersion + SAMSourceRevision when CI sets the latter. If CI already
set InformationalVersion directly (e.g. SAM_Deploy installer.yml does this), respect
that and don't overwrite. Local dev builds leave both empty -> no SHA attribute emitted.
-->
<InformationalVersion Condition="'$(InformationalVersion)' == '' AND '$(SAMSourceRevision)' != ''">$(SAMVersion)+$(SAMSourceRevision)</InformationalVersion>
<!--
Suppress the SDK's SourceLink auto-append behaviour. By default, when SourceLink is
configured on a project (via NuGet or repo settings), the SDK appends the project's
OWN commit SHA to InformationalVersion (e.g. '2026.2.164.0+998af06.dd02a4c2...').
We set InformationalVersion explicitly to SAM_Deploy's SHA (which encodes all 22
submodule pointers), so the SDK's extra append is noise. False = keep our value clean.
-->
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Deterministic>true</Deterministic>
</PropertyGroup>

<!--
Projects where SDK assembly-attribute generation is disabled (legacy AssemblyInfo.cs
with GenerateAssemblyInfo=false) OR projects where the SDK doesn't auto-generate
attributes at all (classic-style csprojs that don't set the property — '' evaluates
as not 'true') ignore the AssemblyVersion/FileVersion MSBuild properties above.
Inject the attributes via a generated source file so those assemblies also get
stamped by CI.
-->
<Target Name="_GenerateSAMVersionFile"
BeforeTargets="CoreCompile"
Condition="'$(GenerateAssemblyInfo)' != 'true'">
<ItemGroup>
<_SAMVersionLine Include="// &lt;auto-generated /&gt;" />
<_SAMVersionLine Include="[assembly: System.Reflection.AssemblyVersionAttribute(&quot;$(SAMVersion)&quot;)]" />
<_SAMVersionLine Include="[assembly: System.Reflection.AssemblyFileVersionAttribute(&quot;$(SAMVersion)&quot;)]" />
<!-- Only emit InformationalVersion attribute when CI provided a value (SDK projects
would otherwise get it via PropertyGroup -> SDK auto-gen). -->
<_SAMVersionLine Include="[assembly: System.Reflection.AssemblyInformationalVersionAttribute(&quot;$(InformationalVersion)&quot;)]" Condition="'$(InformationalVersion)' != ''" />
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<WriteLinesToFile
File="$(IntermediateOutputPath)SAMVersion.g.cs"
Lines="@(_SAMVersionLine)"
Overwrite="true"
WriteOnlyWhenDifferent="true" />
<ItemGroup>
<Compile Include="$(IntermediateOutputPath)SAMVersion.g.cs" KeepDuplicates="false" />
<FileWrites Include="$(IntermediateOutputPath)SAMVersion.g.cs" />
</ItemGroup>
</Target>

</Project>
Original file line number Diff line number Diff line change
@@ -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 System;
using System.Drawing;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -52,6 +54,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.*")]
[assembly: AssemblyFileVersion("1.0.*")]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Deterministic>false</Deterministic>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
Expand Down Expand Up @@ -640,9 +639,8 @@
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
</ItemGroup>
<PropertyGroup />
Expand Down Expand Up @@ -707,4 +705,4 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if &quot;$(Configuration)&quot; == &quot;Debug2020&quot; set Version=Revit 2020&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2021&quot; set Version=Revit 2021&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2022&quot; set Version=Revit 2022&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2023&quot; set Version=Revit 2023&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2024&quot; set Version=Revit 2024&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2025&quot; set Version=Revit 2025&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2026&quot; set Version=Revit 2026&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2020&quot; set Version=Revit 2020&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2021&quot; set Version=Revit 2021&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2022&quot; set Version=Revit 2022&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2023&quot; set Version=Revit 2023&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2024&quot; set Version=Revit 2024&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2025&quot; set Version=Revit 2025&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2026&quot; set Version=Revit 2026&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetPath)&quot; &quot;$(TargetDir)\$(ProjectName).gha&quot;&#xD;&#xA;&#xD;&#xA;set SAM_DIR=$(APPDATA)\SAM\%25Version%25&#xD;&#xA;if not exist &quot;%25SAM_DIR%25&quot; mkdir &quot;%25SAM_DIR%25&quot;&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)*.dll&quot; &quot;%25SAM_DIR%25&quot;&#xD;&#xA;copy &quot;%25SAM_DIR%25\$(ProjectName).dll&quot; &quot;%25SAM_DIR%25\$(ProjectName).gha&quot;&#xD;&#xA;&#xD;&#xA;xcopy &quot;$(SolutionDir)\files\resources&quot; &quot;%25APPDATA%25\SAM\resources&quot; /Y/I/E/S&#xD;&#xA;xcopy &quot;$(SolutionDir)\files\resources&quot; &quot;%25USERPROFILE%25\Documents\SAM\resources&quot; /Y/D/I/E/S&#xD;&#xA;&#xD;&#xA;if exist &quot;$(SolutionDir)\files\Grasshopper\UserObjects&quot; (&#xD;&#xA; xcopy &quot;$(SolutionDir)\files\Grasshopper\UserObjects&quot; &quot;%25APPDATA%25\Grasshopper\UserObjects\SAM&quot; /Y/I/E/S&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;::erase &quot;%25SAM_DIR%25$(ProjectName).dll&quot;&#xD;&#xA;::erase &quot;$(TargetPath)&quot;" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -52,6 +54,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.*")]
[assembly: AssemblyFileVersion("1.0.*")]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Deterministic>false</Deterministic>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -637,9 +636,8 @@
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json">
<Version>13.0.3</Version>
</PackageReference>
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
</ItemGroup>
<PropertyGroup />
Expand Down Expand Up @@ -729,4 +727,4 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="if &quot;$(Configuration)&quot; == &quot;Debug2020&quot; set Version=Revit 2020&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2021&quot; set Version=Revit 2021&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2022&quot; set Version=Revit 2022&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2023&quot; set Version=Revit 2023&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2024&quot; set Version=Revit 2024&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2025&quot; set Version=Revit 2025&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Debug2026&quot; set Version=Revit 2026&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2020&quot; set Version=Revit 2020&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2021&quot; set Version=Revit 2021&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2022&quot; set Version=Revit 2022&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2023&quot; set Version=Revit 2023&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2024&quot; set Version=Revit 2024&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2025&quot; set Version=Revit 2025&#xD;&#xA;if &quot;$(Configuration)&quot; == &quot;Release2026&quot; set Version=Revit 2026&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetPath)&quot; &quot;$(TargetDir)\$(ProjectName).gha&quot;&#xD;&#xA;&#xD;&#xA;set SAM_DIR=$(APPDATA)\SAM\%25Version%25&#xD;&#xA;if not exist &quot;%25SAM_DIR%25&quot; mkdir &quot;%25SAM_DIR%25&quot;&#xD;&#xA;&#xD;&#xA;copy &quot;$(TargetDir)*.dll&quot; &quot;%25SAM_DIR%25&quot;&#xD;&#xA;copy &quot;%25SAM_DIR%25\$(ProjectName).dll&quot; &quot;%25SAM_DIR%25\$(ProjectName).gha&quot;&#xD;&#xA;&#xD;&#xA;xcopy &quot;$(SolutionDir)\files\resources&quot; &quot;%25APPDATA%25\SAM\resources&quot; /Y/I/E/S&#xD;&#xA;xcopy &quot;$(SolutionDir)\files\resources&quot; &quot;%25USERPROFILE%25\Documents\SAM\resources&quot; /Y/D/I/E/S&#xD;&#xA;&#xD;&#xA;if exist &quot;$(SolutionDir)\files\Grasshopper\UserObjects&quot; (&#xD;&#xA; xcopy &quot;$(SolutionDir)\files\Grasshopper\UserObjects&quot; &quot;%25APPDATA%25\Grasshopper\UserObjects\SAM&quot; /Y/I/E/S&#xD;&#xA;)&#xD;&#xA;&#xD;&#xA;::erase &quot;%25SAM_DIR%25$(ProjectName).dll&quot;&#xD;&#xA;::erase &quot;$(TargetPath)&quot;" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using GH_IO.Serialization;
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (c) 2020–2026 Michal Dengusiak & Jakub Ziolkowski and contributors
using GH_IO.Serialization;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using SAM.Core.Grasshopper.Revit.Properties;
Expand Down Expand Up @@ -38,7 +40,7 @@ public override bool Write(GH_IWriter writer)
if (Value == null)
return false;

writer.SetString(typeof(ConvertSettings).FullName, Value.ToJObject().ToString());
writer.SetString(typeof(ConvertSettings).FullName, Value.ToJsonObject().ToString());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -52,6 +54,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.*")]
[assembly: AssemblyFileVersion("1.0.*")]
Loading