Compare commits
5 Commits
main
...
v3.0.1-adam.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 58e36b07c8 | |||
| f4522cbe33 | |||
| 9584d442a2 | |||
| 9a56a09d7a | |||
| d6aa70875e |
@@ -9,10 +9,10 @@
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"gitversion.tool": {
|
||||
"version": "6.0.2",
|
||||
"dotnet-affected": {
|
||||
"version": "5.0.0",
|
||||
"commands": [
|
||||
"dotnet-gitversion"
|
||||
"dotnet-affected"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ name: .NET Build and Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main", "dev", "release/*"] # Continuous delivery on every long-lived branch
|
||||
branches: ["main", "adam/*"]
|
||||
tags: ["v3.*"] # Manual delivery on every 3.x tag
|
||||
|
||||
jobs:
|
||||
@@ -11,6 +11,10 @@ jobs:
|
||||
outputs:
|
||||
version: ${{ steps.set-version.outputs.version }}
|
||||
steps:
|
||||
- name: Check if both branch and tag exist
|
||||
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v3.') && (github.event.base_ref == 'refs/heads/main' || startsWith(github.event.base_ref, 'refs/heads/adam/'))
|
||||
run: echo "Both branch and tag match, proceeding..."
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -27,9 +31,6 @@ jobs:
|
||||
path: ~/.nuget/packages
|
||||
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
|
||||
|
||||
- name: ⚒️ Run GitVersion on Windows
|
||||
run: ./build.ps1 build-server-version
|
||||
|
||||
- name: ⚒️ Run build on Windows
|
||||
run: ./build.ps1
|
||||
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
using Microsoft.Build.Construction;
|
||||
using Semver;
|
||||
using static SimpleExec.Command;
|
||||
|
||||
namespace Build;
|
||||
|
||||
public static class Affected
|
||||
{
|
||||
public static readonly string Root = Environment.CurrentDirectory;
|
||||
public const string AFFECTED_PROJECT = "affected.proj";
|
||||
|
||||
public static async Task<string[]> GetSolutions()
|
||||
{
|
||||
await ComputeAffected();
|
||||
var projFile = Path.Combine(Root, AFFECTED_PROJECT);
|
||||
if (File.Exists(projFile))
|
||||
{
|
||||
Console.WriteLine("Affected project file: " + projFile);
|
||||
return [projFile];
|
||||
}
|
||||
|
||||
Console.WriteLine("Using solutions: " + string.Join(',', Consts.Solutions));
|
||||
return Consts.Solutions;
|
||||
}
|
||||
|
||||
public static async Task<InstallerProject[]> GetInstallerProjects()
|
||||
{
|
||||
await ComputeAffected();
|
||||
var projFile = Path.Combine(Root, AFFECTED_PROJECT);
|
||||
if (File.Exists(projFile))
|
||||
{
|
||||
Console.WriteLine("Affected project file: " + projFile);
|
||||
var project = ProjectRootElement.Open(projFile) ?? throw new InvalidOperationException();
|
||||
var references = project
|
||||
.ItemGroups.SelectMany(x => x.Items)
|
||||
.Where(x => x.ItemType == "ProjectReference")
|
||||
.ToList();
|
||||
var projs = new List<InstallerProject>();
|
||||
|
||||
foreach (var refe in references)
|
||||
{
|
||||
Console.WriteLine($"Candidate project: {refe.Include}");
|
||||
}
|
||||
|
||||
foreach (var manifest in Consts.InstallerManifests)
|
||||
{
|
||||
var assets = new List<InstallerAsset>();
|
||||
foreach (var refe in references)
|
||||
{
|
||||
var referencePath = refe.Include[(Root.Length + 1)..];
|
||||
referencePath = Path.GetDirectoryName(referencePath) ?? throw new InvalidOperationException();
|
||||
if (Path.DirectorySeparatorChar != '/')
|
||||
{
|
||||
referencePath = referencePath.Replace(Path.DirectorySeparatorChar, '/');
|
||||
}
|
||||
|
||||
foreach (var proj in manifest.Projects)
|
||||
{
|
||||
if (proj.ProjectPath.Contains(referencePath))
|
||||
{
|
||||
assets.Add(proj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (assets.Count > 0)
|
||||
{
|
||||
projs.Add(manifest with { Projects = assets });
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var proj in projs.SelectMany(x => x.Projects))
|
||||
{
|
||||
Console.WriteLine("Affected project being built: " + proj);
|
||||
}
|
||||
|
||||
if (projs.Count > 0)
|
||||
{
|
||||
return projs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("Using all installer manifests: " + string.Join(',', Consts.InstallerManifests));
|
||||
return Consts.InstallerManifests;
|
||||
}
|
||||
|
||||
public static async Task ComputeAffected()
|
||||
{
|
||||
var projFile = Path.Combine(Root, AFFECTED_PROJECT);
|
||||
if (File.Exists(projFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var (currentTag, _) = await ReadAsync("git", "describe --tags");
|
||||
currentTag = currentTag.Trim();
|
||||
var version = await Affected.ComputeVersion();
|
||||
var currentVersion = SemVersion.Parse(version).WithoutPrereleaseOrMetadata();
|
||||
var (lastTag, _) = await ReadAsync("git", $"describe --abbrev=0 --tags {currentTag}^");
|
||||
lastTag = lastTag.Trim();
|
||||
|
||||
if (!SemVersion.TryParse(lastTag, SemVersionStyles.AllowLowerV, out var lastVersion))
|
||||
{
|
||||
Console.WriteLine($"Could not parse version: '{lastTag}'");
|
||||
return;
|
||||
}
|
||||
Console.WriteLine($"Last tag: {lastTag}, Current tag: {currentTag}");
|
||||
|
||||
lastVersion = lastVersion.WithoutPrereleaseOrMetadata();
|
||||
currentVersion = currentVersion.WithoutPrereleaseOrMetadata();
|
||||
Console.WriteLine($"Last parsed version: {lastVersion}, Current parsed version: {currentVersion}");
|
||||
var sort = currentVersion.CompareSortOrderTo(lastVersion);
|
||||
Console.WriteLine($"Sort: {sort}");
|
||||
if (sort == 0)
|
||||
{
|
||||
Console.WriteLine($"Current version {currentVersion} is equal to: {lastVersion}");
|
||||
return;
|
||||
}
|
||||
if (sort != 1)
|
||||
{
|
||||
Console.WriteLine($"Current version {currentVersion} is not greater than: {lastVersion}");
|
||||
return;
|
||||
}
|
||||
|
||||
var majorEquals = currentVersion.Major == lastVersion.Major;
|
||||
var minorEquals = currentVersion.Minor == lastVersion.Minor;
|
||||
if (!majorEquals)
|
||||
{
|
||||
Console.WriteLine($"Current version {currentVersion} is not matching major version: {lastVersion}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (minorEquals)
|
||||
{
|
||||
var (currentCommit, _) = await ReadAsync("git", $"rev-list -n 1 {currentTag.Trim()}");
|
||||
var (lastCommit, _) = await ReadAsync("git", $"rev-list -n 1 {lastTag.Trim()}");
|
||||
await RunAsync("dotnet", $"affected --from {currentCommit.Trim()} --to {lastCommit.Trim()}", Root);
|
||||
}
|
||||
}
|
||||
|
||||
private static string? s_currentVersion;
|
||||
|
||||
public static async Task<string> ComputeVersion()
|
||||
{
|
||||
if (s_currentVersion is not null)
|
||||
{
|
||||
return s_currentVersion;
|
||||
}
|
||||
var (currentTag, _) = await ReadAsync("git", "describe --tags");
|
||||
currentTag = currentTag.Trim();
|
||||
|
||||
if (!SemVersion.TryParse(currentTag, SemVersionStyles.AllowLowerV, out var currentVersion))
|
||||
{
|
||||
throw new InvalidOperationException($"Could not parse version: '{currentTag}'");
|
||||
}
|
||||
s_currentVersion = currentVersion.ToString();
|
||||
return s_currentVersion;
|
||||
}
|
||||
|
||||
private static string? s_currentFileVersion;
|
||||
|
||||
public static async Task<string> ComputeFileVersion()
|
||||
{
|
||||
if (s_currentFileVersion is not null)
|
||||
{
|
||||
return s_currentFileVersion;
|
||||
}
|
||||
var version = await Affected.ComputeVersion();
|
||||
var currentVersion = SemVersion.Parse(version).WithoutPrereleaseOrMetadata();
|
||||
s_currentFileVersion = currentVersion.ToString() + ".0";
|
||||
return s_currentFileVersion;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
<PackageReference Include="Bullseye" />
|
||||
<PackageReference Include="Glob" />
|
||||
<PackageReference Include="Microsoft.Build" />
|
||||
<PackageReference Include="Semver" />
|
||||
<PackageReference Include="SimpleExec" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
+25
-38
@@ -12,9 +12,7 @@ const string TEST = "test";
|
||||
const string TEST_ONLY = "test-only";
|
||||
const string FORMAT = "format";
|
||||
const string ZIP = "zip";
|
||||
const string VERSION = "version";
|
||||
const string RESTORE_TOOLS = "restore-tools";
|
||||
const string BUILD_SERVER_VERSION = "build-server-version";
|
||||
const string CLEAN_LOCKS = "clean-locks";
|
||||
const string CHECK_SOLUTIONS = "check-solutions";
|
||||
const string DEEP_CLEAN = "deep-clean";
|
||||
@@ -75,6 +73,9 @@ void CleanSolution(string solution, string configuration)
|
||||
Build(solution, configuration);
|
||||
}
|
||||
|
||||
var solutions = await Affected.GetSolutions();
|
||||
var projects = await Affected.GetInstallerProjects();
|
||||
|
||||
Target(
|
||||
CLEAN_LOCKS,
|
||||
() =>
|
||||
@@ -125,17 +126,6 @@ Target(
|
||||
}
|
||||
);
|
||||
|
||||
Target(
|
||||
VERSION,
|
||||
async () =>
|
||||
{
|
||||
var (output, _) = await ReadAsync("dotnet", "minver -v w");
|
||||
output = output.Trim();
|
||||
Console.WriteLine($"Version: {output}");
|
||||
Run("echo", $"\"version={output}\" >> $GITHUB_OUTPUT");
|
||||
}
|
||||
);
|
||||
|
||||
Target(
|
||||
RESTORE_TOOLS,
|
||||
() =>
|
||||
@@ -156,32 +146,26 @@ Target(
|
||||
Target(
|
||||
RESTORE,
|
||||
DependsOn(FORMAT),
|
||||
Consts.Solutions,
|
||||
s =>
|
||||
solutions,
|
||||
async s =>
|
||||
{
|
||||
var version = await Affected.ComputeVersion();
|
||||
var fileVersion = await Affected.ComputeFileVersion();
|
||||
Console.WriteLine($"Version: {version} & {fileVersion}");
|
||||
Run("dotnet", $"restore {s} --locked-mode");
|
||||
}
|
||||
);
|
||||
|
||||
Target(
|
||||
BUILD_SERVER_VERSION,
|
||||
DependsOn(RESTORE_TOOLS),
|
||||
() =>
|
||||
{
|
||||
Run("dotnet", "tool run dotnet-gitversion /output json /output buildserver");
|
||||
}
|
||||
);
|
||||
|
||||
Target(
|
||||
BUILD,
|
||||
DependsOn(RESTORE),
|
||||
Consts.Solutions,
|
||||
s =>
|
||||
solutions,
|
||||
async s =>
|
||||
{
|
||||
var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild";
|
||||
var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.0";
|
||||
var version = await Affected.ComputeVersion();
|
||||
var fileVersion = await Affected.ComputeFileVersion();
|
||||
Console.WriteLine($"Version: {version} & {fileVersion}");
|
||||
Run(
|
||||
await RunAsync(
|
||||
"dotnet",
|
||||
$"build {s} -c Release --no-restore -warnaserror -p:Version={version} -p:FileVersion={fileVersion} -v:m"
|
||||
);
|
||||
@@ -218,18 +202,18 @@ Target(
|
||||
BUILD_LINUX,
|
||||
DependsOn(FORMAT),
|
||||
Glob.Files(".", "**/Speckle.Importers.Ifc.csproj"),
|
||||
file =>
|
||||
async file =>
|
||||
{
|
||||
Run("dotnet", $"restore {file} --locked-mode");
|
||||
var version = Environment.GetEnvironmentVariable("GitVersion_FullSemVer") ?? "3.0.0-localBuild";
|
||||
var fileVersion = Environment.GetEnvironmentVariable("GitVersion_AssemblySemFileVer") ?? "3.0.0.0";
|
||||
await RunAsync("dotnet", $"restore {file} --locked-mode");
|
||||
var version = await Affected.ComputeVersion();
|
||||
var fileVersion = await Affected.ComputeFileVersion();
|
||||
Console.WriteLine($"Version: {version} & {fileVersion}");
|
||||
Run(
|
||||
await RunAsync(
|
||||
"dotnet",
|
||||
$"build {file} -c Release --no-restore -warnaserror -p:Version={version} -p:FileVersion={fileVersion} -v:m"
|
||||
);
|
||||
|
||||
RunAsync(
|
||||
await RunAsync(
|
||||
"dotnet",
|
||||
$"pack {file} -c Release -o output --no-build -p:Version={version} -p:FileVersion={fileVersion} -v:m"
|
||||
);
|
||||
@@ -239,9 +223,12 @@ Target(
|
||||
Target(
|
||||
ZIP,
|
||||
DependsOn(TEST),
|
||||
Consts.InstallerManifests,
|
||||
x =>
|
||||
projects,
|
||||
async x =>
|
||||
{
|
||||
await Affected.ComputeAffected();
|
||||
var version = await Affected.ComputeVersion();
|
||||
Console.WriteLine("Zipping..." + version);
|
||||
var outputDir = Path.Combine(".", "output");
|
||||
var slugDir = Path.Combine(outputDir, x.HostAppSlug);
|
||||
|
||||
@@ -280,6 +267,6 @@ Target(
|
||||
}
|
||||
);
|
||||
|
||||
Target("default", DependsOn(FORMAT, ZIP), () => Console.WriteLine("Done!"));
|
||||
Target("default", DependsOn(TEST), () => Console.WriteLine("Done!"));
|
||||
|
||||
await RunTargetsAndExitAsync(args).ConfigureAwait(true);
|
||||
|
||||
@@ -53,6 +53,15 @@
|
||||
"resolved": "1.14.1",
|
||||
"contentHash": "mOOmFYwad3MIOL14VCjj02LljyF1GNw1wP0YVlxtcPvqdxjGGMNdNJJxHptlry3MOd8b40Flm8RPOM8JOlN2sQ=="
|
||||
},
|
||||
"Semver": {
|
||||
"type": "Direct",
|
||||
"requested": "[3.0.0, )",
|
||||
"resolved": "3.0.0",
|
||||
"contentHash": "9jZCicsVgTebqkAujRWtC9J1A5EQVlu0TVKHcgoCuv345ve5DYf4D1MjhKEnQjdRZo6x/vdv6QQrYFs7ilGzLA==",
|
||||
"dependencies": {
|
||||
"Microsoft.Extensions.Primitives": "5.0.1"
|
||||
}
|
||||
},
|
||||
"SimpleExec": {
|
||||
"type": "Direct",
|
||||
"requested": "[12.0.0, )",
|
||||
@@ -75,6 +84,11 @@
|
||||
"resolved": "8.0.0",
|
||||
"contentHash": "bZKfSIKJRXLTuSzLudMFte/8CempWjVamNUR5eHJizsy+iuOuO/k2gnh7W0dHJmYY0tBf+gUErfluCv5mySAOQ=="
|
||||
},
|
||||
"Microsoft.Extensions.Primitives": {
|
||||
"type": "Transitive",
|
||||
"resolved": "5.0.1",
|
||||
"contentHash": "5WPSmL4YeP7eW+Vc8XZ4DwjYWBAiSwDV9Hm63JJWcz1Ie3Xjv4KuJXzgCstj48LkLfVCYa7mLcx7y+q6yqVvtw=="
|
||||
},
|
||||
"Microsoft.NET.StringTools": {
|
||||
"type": "Transitive",
|
||||
"resolved": "17.11.4",
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
<PackageVersion Include="Revit.Async" Version="2.1.1" />
|
||||
<PackageVersion Include="RhinoCommon" Version="8.9.24194.18121" />
|
||||
<PackageVersion Include="RhinoWindows" Version="8.9.24194.18121" />
|
||||
<PackageVersion Include="Speckle.CSI.API" Version="2.4.0" />
|
||||
<PackageVersion Include="Semver" Version="3.0.0" />
|
||||
<PackageVersion Include="Speckle.CSI.API" Version="2.4.0" />
|
||||
<PackageVersion Include="Speckle.DoubleNumerics" Version="4.1.0" />
|
||||
<PackageVersion Include="Speckle.Triangle" Version="1.0.0" />
|
||||
<PackageVersion Include="Tekla.Structures.Dialog" Version="2024.0.4" PrivateAssets="all" IncludeAssets="compile; build" />
|
||||
@@ -55,4 +56,4 @@
|
||||
<GlobalPackageReference Include="Speckle.InterfaceGenerator" Version="0.9.6" />
|
||||
<GlobalPackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{85A13E
|
||||
Directory.Packages.props = Directory.Packages.props
|
||||
global.json = global.json
|
||||
README.md = README.md
|
||||
.config\dotnet-tools.json = .config\dotnet-tools.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Revit", "Revit", "{D92751C8-1039-4005-90B2-913E55E0B8BD}"
|
||||
@@ -278,6 +279,7 @@ EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Importers.Ifc.Tester", "Importers\Ifc\Speckle.Importers.Ifc.Tester\Speckle.Importers.Ifc.Tester.csproj", "{FCD6CB79-6B41-4448-99E1-787408AD24B0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Importers.Ifc.Tester2", "Importers\Ifc\Speckle.Importers.Ifc.Tester2\Speckle.Importers.Ifc.Tester2.csproj", "{17FB6920-DF63-4D94-86A4-F1619D501C6D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Connectors.Common.Tests", "Sdk\Speckle.Connectors.Common.Tests\Speckle.Connectors.Common.Tests.csproj", "{F86DFA8A-E2E0-4EBE-9BAF-72AE2698EDC6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Speckle.Common.MeshTriangulation", "Sdk\Speckle.Common.MeshTriangulation\Speckle.Common.MeshTriangulation.csproj", "{B740A025-1035-4A75-865B-7825857D610C}"
|
||||
|
||||
Reference in New Issue
Block a user