build: Generate version info via git cli in build scripts
Instead of GitVersion.MsBuild nuget
This commit is contained in:
1 parent
2a284b1e9c
commit
69e4ed84c1
16 files changed
+106
-57
No files matched your search
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<Configuration Condition="'$(configuration)'==''">Debug</Configuration>
|
||||
<EnablePreviewFeatures>true</EnablePreviewFeatures>
|
||||
<LangVersion>11</LangVersion>
|
||||
<UseProjectRefs Condition="'$(UseProjectRefs)' == ''">true</UseProjectRefs>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
|
||||
@@ -9,15 +9,11 @@
|
||||
<Product>Spark</Product>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Version>1.0.0</Version>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -20,15 +20,12 @@
|
||||
<StartupObject>mbts.ui.shell.App</StartupObject>
|
||||
<RootNamespace>bts</RootNamespace>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
<WarningsAsErrors />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="IronPython" Version="3.4.2" />
|
||||
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
|
||||
|
||||
@@ -7,14 +7,11 @@
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -16,14 +16,11 @@
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
<WarningsAsErrors />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.0" />
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="6.0.0" />
|
||||
|
||||
@@ -4,15 +4,9 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\cs\Bts.Spark.Api\Bts.Spark.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -14,10 +15,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Net.WebSockets" Version="4.3.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
|
||||
|
||||
@@ -7,21 +7,27 @@
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<NoWarn>8981</NoWarn>
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Bts.Spark.Core\Bts.Spark.Core.csproj" />
|
||||
</ItemGroup>
|
||||
<Choose>
|
||||
<When Condition="'$(UseProjectRefs)' == 'true'">
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Bts.Spark.Core\Bts.Spark.Core.csproj" />
|
||||
</ItemGroup>
|
||||
</When>
|
||||
<Otherwise>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bts.Spark.Core" Version="$(SparkVersion)" />
|
||||
</ItemGroup>
|
||||
</Otherwise>
|
||||
</Choose>
|
||||
|
||||
<ItemGroup>
|
||||
<Proto Include="**/*.proto" />
|
||||
|
||||
@@ -8,13 +8,10 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors />
|
||||
<Version>$(SparkVersion)</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
|
||||
<PackageReference Include="protobuf-net" Version="3.2.26" />
|
||||
|
||||
@@ -26,6 +26,10 @@ def _get_arg_parser():
|
||||
action="store_true",
|
||||
help="Perform a clean build (remove artifacts from previous build)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--spark-version",
|
||||
help="The version identifier to use (by default, uses git to generate semantic version number)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--verbosity",
|
||||
metavar="{0-5}",
|
||||
@@ -94,16 +98,20 @@ def _main():
|
||||
cmake_verbosity = _cmake_verbosity(args.verbosity)
|
||||
dotnet_config = args.configuration.title()
|
||||
dotnet_verbosity = _dotnet_verbosity(args.verbosity)
|
||||
spark_version = args.spark_version
|
||||
if not spark_version:
|
||||
from core.git_utils import git_head_version
|
||||
spark_version = git_head_version()
|
||||
os.chdir(SparkPaths.root())
|
||||
if args.clean:
|
||||
run(f"cmake --build build/{cmake_preset} --target clean")
|
||||
run(f"dotnet clean {sln} -c {dotnet_config} -v {dotnet_verbosity}")
|
||||
run(f"dotnet clean {sln} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
run(f"cmake --preset {cmake_preset} -DCMAKE_MESSAGE_LOG_LEVEL={cmake_verbosity}")
|
||||
cmake_build_cmd = f"cmake --build build/{cmake_preset} --config {cmake_config}"
|
||||
if cmake_jobs:
|
||||
cmake_build_cmd += f" -j {cmake_jobs}"
|
||||
run(cmake_build_cmd)
|
||||
run(f"dotnet build {sln} -c {dotnet_config} -v {dotnet_verbosity}")
|
||||
run(f"dotnet build {sln} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -94,15 +94,19 @@ def build(args):
|
||||
dotnet_config = args.configuration.title()
|
||||
dotnet_verbosity = _dotnet_verbosity(args.verbosity)
|
||||
os.chdir(SparkPaths.root())
|
||||
spark_version = args.spark_version
|
||||
if not spark_version:
|
||||
from core.git_utils import git_head_version
|
||||
spark_version = git_head_version()
|
||||
if args.clean:
|
||||
run(f"cmake --build build/{cmake_preset} --target clean")
|
||||
run(f"dotnet clean {sln} -c {dotnet_config} -v {dotnet_verbosity}")
|
||||
run(f"dotnet clean {sln} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
run(f"cmake --preset {cmake_preset} -DCMAKE_MESSAGE_LOG_LEVEL={cmake_verbosity}")
|
||||
cmake_build_cmd = f"cmake --build build/{cmake_preset} --config {cmake_config}"
|
||||
if cmake_jobs:
|
||||
cmake_build_cmd += f" -j {cmake_jobs}"
|
||||
run(cmake_build_cmd)
|
||||
run(f"dotnet build {sln} -c {dotnet_config} -v {dotnet_verbosity}")
|
||||
run(f"dotnet build {sln} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
|
||||
|
||||
def _main():
|
||||
|
||||
+16
-10
@@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
|
||||
from core.file_utils import SparkPaths
|
||||
from core.iter_utils import at_bounded
|
||||
@@ -14,6 +15,7 @@ class BuildArgs:
|
||||
verbosity: int = 1,
|
||||
dry_run: bool = False,
|
||||
publish: bool = False,
|
||||
version: Optional[str] = None,
|
||||
):
|
||||
self.configuration = configuration
|
||||
self.clean = clean
|
||||
@@ -36,6 +38,7 @@ class BuildArgs:
|
||||
],
|
||||
verbosity)
|
||||
self.publish = publish
|
||||
self.version = version
|
||||
|
||||
|
||||
def _get_arg_parser():
|
||||
@@ -50,6 +53,10 @@ def _get_arg_parser():
|
||||
action='store_true',
|
||||
help='Perform a clean build (remove artifacts from previous build)',
|
||||
)
|
||||
parser.add_argument(
|
||||
"--spark-version",
|
||||
help="The version identifier to use (by default, uses git to generate semantic version number)"
|
||||
)
|
||||
parser.add_argument(
|
||||
'--verbosity',
|
||||
metavar='{0-5}',
|
||||
@@ -79,14 +86,7 @@ def build(args: BuildArgs):
|
||||
return
|
||||
subprocess.run(cmd).check_returncode()
|
||||
|
||||
def dotnet_cmd(action='build'):
|
||||
return ' '.join(
|
||||
[
|
||||
f'dotnet {action} spark_client.sln',
|
||||
f'--configuration {args.configuration.title()}',
|
||||
f'--verbosity {args.dotnet_verbosity}',
|
||||
])
|
||||
|
||||
dotnet_config = args.configuration.title()
|
||||
os.chdir(SparkPaths.root())
|
||||
cmake_configure_cmd = ' '.join(
|
||||
[
|
||||
@@ -100,12 +100,17 @@ def build(args: BuildArgs):
|
||||
f'--build',
|
||||
f'--preset spark-windows-{args.configuration.lower()}',
|
||||
])
|
||||
spark_version = args.version
|
||||
if not spark_version:
|
||||
from core.git_utils import git_head_version
|
||||
spark_version = git_head_version()
|
||||
if args.clean:
|
||||
run(f'{cmake_build_cmd} --target clean')
|
||||
run(dotnet_cmd('clean'))
|
||||
run(f"dotnet clean spark_client.sln -c {dotnet_config} -v {args.dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
run(cmake_configure_cmd)
|
||||
run(cmake_build_cmd)
|
||||
run(dotnet_cmd('publish' if args.publish else 'build'))
|
||||
build_action = "publish" if args.publish else "build"
|
||||
run(f"dotnet {build_action} spark_client.sln -c {dotnet_config} -v {args.dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
|
||||
|
||||
def _main():
|
||||
@@ -116,6 +121,7 @@ def _main():
|
||||
clean=cli_args.clean,
|
||||
verbosity=cli_args.verbosity,
|
||||
dry_run=cli_args.dry_run,
|
||||
version=cli_args.spark_version,
|
||||
)
|
||||
build(args)
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def git_head_version(revision: Optional[str] = None, check: bool = True):
|
||||
def run_captured(*args):
|
||||
res = subprocess.run(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
check=check,
|
||||
)
|
||||
return res.stdout
|
||||
|
||||
args = ["git", "describe", "--tags", "--always"]
|
||||
if revision:
|
||||
args += revision
|
||||
vers = run_captured(*args).rstrip()
|
||||
if vers.startswith("v") and "." in vers:
|
||||
vers = vers[1:]
|
||||
if check and not vers:
|
||||
raise ValueError(
|
||||
"Failed to generate spark version identifier. Please re-run pack_sdk.py with --spark-version <VERSION>"
|
||||
)
|
||||
return vers
|
||||
@@ -62,6 +62,7 @@ class PublishArgs:
|
||||
output: Optional[str] = None,
|
||||
framework="net8.0",
|
||||
runtime=_dotnet_runtime(),
|
||||
version: Optional[str] = None,
|
||||
):
|
||||
self.configuration = configuration
|
||||
self.cmake_jobs = cmake_jobs
|
||||
@@ -88,6 +89,7 @@ class PublishArgs:
|
||||
self.output = output
|
||||
self.framework = framework
|
||||
self.runtime = runtime
|
||||
self.version = version
|
||||
|
||||
|
||||
def _get_arg_parser():
|
||||
@@ -110,6 +112,10 @@ def _get_arg_parser():
|
||||
action="store_true",
|
||||
help="Perform a clean build (remove artifacts from previous build)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--spark-version",
|
||||
help="The version identifier to use (by default, uses git to generate semantic version number)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output", type=str, help="The output directory for published artifacts."
|
||||
)
|
||||
@@ -159,11 +165,15 @@ def publish(args: PublishArgs):
|
||||
"publish",
|
||||
)
|
||||
os.chdir(SparkPaths.root())
|
||||
spark_version = args.version
|
||||
if not spark_version:
|
||||
from core.git_utils import git_head_version
|
||||
spark_version = git_head_version()
|
||||
if args.clean:
|
||||
run(
|
||||
f"cmake --build build/{cmake_preset} --config {cmake_config} --target clean"
|
||||
)
|
||||
run(f"dotnet clean {sln} -c {dotnet_config} -v {dotnet_verbosity}")
|
||||
run(f"dotnet clean {sln} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
run(f"cmake --preset {cmake_preset} -DCMAKE_MESSAGE_LOG_LEVEL={cmake_verbosity}")
|
||||
cmake_build_cmd = (
|
||||
f"cmake --build build/{cmake_preset} --config {cmake_config} --target install"
|
||||
@@ -172,7 +182,7 @@ def publish(args: PublishArgs):
|
||||
cmake_build_cmd += f" -j {cmake_jobs}"
|
||||
run(cmake_build_cmd)
|
||||
run(
|
||||
f"dotnet publish {sln} -c {dotnet_config} -v {dotnet_verbosity} -f {args.framework} -r {args.runtime} --sc"
|
||||
f"dotnet publish {sln} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version} -f {args.framework} -r {args.runtime} --sc"
|
||||
)
|
||||
# Copy cpp bins
|
||||
print(f"[pseudo shell] cp -r install/{cmake_preset}/bin/* {publish_dir}")
|
||||
@@ -196,6 +206,7 @@ def _main():
|
||||
verbosity=args.verbosity,
|
||||
dry_run=args.dry_run,
|
||||
output=args.output,
|
||||
version=args.spark_version,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ class PublishArgs:
|
||||
output: Optional[str] = None,
|
||||
framework="net8.0-windows",
|
||||
runtime=_dotnet_runtime(),
|
||||
version: Optional[str] = None,
|
||||
):
|
||||
self.configuration = configuration
|
||||
self.cmake_jobs = cmake_jobs
|
||||
@@ -88,6 +89,7 @@ class PublishArgs:
|
||||
self.output = output
|
||||
self.framework = framework
|
||||
self.runtime = runtime
|
||||
self.version = version
|
||||
|
||||
|
||||
def _get_arg_parser():
|
||||
@@ -110,6 +112,10 @@ def _get_arg_parser():
|
||||
action="store_true",
|
||||
help="Perform a clean build (remove artifacts from previous build)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--spark-version",
|
||||
help="The version identifier to use (by default, uses git to generate semantic version number)"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output", type=str, help="The output directory for published artifacts."
|
||||
)
|
||||
@@ -159,11 +165,15 @@ def publish(args: PublishArgs):
|
||||
"publish",
|
||||
)
|
||||
os.chdir(SparkPaths.root())
|
||||
spark_version = args.version
|
||||
if not spark_version:
|
||||
from core.git_utils import git_head_version
|
||||
spark_version = git_head_version()
|
||||
if args.clean:
|
||||
run(
|
||||
f"cmake --build build/{cmake_preset} --config {cmake_config} --target clean"
|
||||
)
|
||||
run(f"dotnet clean {csproj} -c {dotnet_config} -v {dotnet_verbosity}")
|
||||
run(f"dotnet clean {csproj} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version}")
|
||||
run(f"cmake --preset {cmake_preset} -DCMAKE_MESSAGE_LOG_LEVEL={cmake_verbosity}")
|
||||
cmake_build_cmd = (
|
||||
f"cmake --build build/{cmake_preset} --config {cmake_config} --target install"
|
||||
@@ -172,7 +182,7 @@ def publish(args: PublishArgs):
|
||||
cmake_build_cmd += f" -j {cmake_jobs}"
|
||||
run(cmake_build_cmd)
|
||||
run(
|
||||
f"dotnet publish {csproj} -c {dotnet_config} -v {dotnet_verbosity} -f {args.framework} -r {args.runtime} --sc"
|
||||
f"dotnet publish {csproj} -c {dotnet_config} -v {dotnet_verbosity} -p:SparkVersion={spark_version} -f {args.framework} -r {args.runtime} --sc"
|
||||
)
|
||||
copytree(f"install/{cmake_preset}/bin", publish_dir, dirs_exist_ok=True)
|
||||
if args.output:
|
||||
@@ -189,6 +199,7 @@ def _main():
|
||||
verbosity=args.verbosity,
|
||||
dry_run=args.dry_run,
|
||||
output=args.output,
|
||||
version=args.spark_version,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user