mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 15:34:34 +00:00
native build?
This commit is contained in:
67
.github/workflows/cli-native.yml
vendored
Normal file
67
.github/workflows/cli-native.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: CLI Native Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
- "release"
|
||||
paths:
|
||||
- "src/SharpCompress.Cli/**"
|
||||
- "src/SharpCompress/**"
|
||||
- "build/**"
|
||||
- "tests/SharpCompress.Test/Cli/**"
|
||||
- "tests/SharpCompress.Test/SharpCompress.Test.csproj"
|
||||
- "Directory.Build.props"
|
||||
- "Directory.Packages.props"
|
||||
- "global.json"
|
||||
- ".github/workflows/cli-native.yml"
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
- "release"
|
||||
paths:
|
||||
- "src/SharpCompress.Cli/**"
|
||||
- "src/SharpCompress/**"
|
||||
- "build/**"
|
||||
- "tests/SharpCompress.Test/Cli/**"
|
||||
- "tests/SharpCompress.Test/SharpCompress.Test.csproj"
|
||||
- "Directory.Build.props"
|
||||
- "Directory.Packages.props"
|
||||
- "global.json"
|
||||
- ".github/workflows/cli-native.yml"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
native-aot:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
rid: linux-x64
|
||||
- os: macos-14
|
||||
rid: osx-arm64
|
||||
- os: windows-latest
|
||||
rid: win-x64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: 10.0.x
|
||||
|
||||
- name: Build Native AOT CLI
|
||||
run: dotnet run --project build/build.csproj -- cli-native
|
||||
env:
|
||||
CLI_RID: ${{ matrix.rid }}
|
||||
|
||||
- name: Upload CLI Native Artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: sharpcompress-cli-${{ matrix.rid }}
|
||||
path: src/SharpCompress.Cli/bin/Release/net10.0/${{ matrix.rid }}/publish/
|
||||
@@ -23,6 +23,7 @@ const string PushToNuGet = "push-to-nuget";
|
||||
const string DisplayBenchmarkResults = "display-benchmark-results";
|
||||
const string CompareBenchmarkResults = "compare-benchmark-results";
|
||||
const string GenerateBaseline = "generate-baseline";
|
||||
const string CliNative = "cli-native";
|
||||
|
||||
Target(
|
||||
Clean,
|
||||
@@ -466,6 +467,40 @@ Target(
|
||||
}
|
||||
);
|
||||
|
||||
Target(
|
||||
CliNative,
|
||||
() =>
|
||||
{
|
||||
var rid = GetRequiredEnvironmentVariable("CLI_RID");
|
||||
var configuration = Environment.GetEnvironmentVariable("CLI_CONFIGURATION") ?? "Release";
|
||||
var framework = Environment.GetEnvironmentVariable("CLI_FRAMEWORK") ?? "net10.0";
|
||||
const string project = "src/SharpCompress.Cli/SharpCompress.Cli.csproj";
|
||||
|
||||
Run("dotnet", $"restore {project} -r {rid}");
|
||||
Run(
|
||||
"dotnet",
|
||||
$"publish {project} -c {configuration} -f {framework} -r {rid} -p:PublishAot=true --no-restore"
|
||||
);
|
||||
|
||||
var binaryName = rid.StartsWith("win-", StringComparison.OrdinalIgnoreCase)
|
||||
? "SharpCompress.Cli.exe"
|
||||
: "SharpCompress.Cli";
|
||||
var binaryPath = Path.Combine(
|
||||
"src",
|
||||
"SharpCompress.Cli",
|
||||
"bin",
|
||||
configuration,
|
||||
framework,
|
||||
rid,
|
||||
"publish",
|
||||
binaryName
|
||||
);
|
||||
|
||||
Console.WriteLine($"Smoke testing native binary: {binaryPath}");
|
||||
Run(binaryPath, "formats --format json");
|
||||
}
|
||||
);
|
||||
|
||||
Target("default", [Publish], () => Console.WriteLine("Done!"));
|
||||
|
||||
await RunTargetsAndExitAsync(args);
|
||||
@@ -702,6 +737,19 @@ static double CalculateChange(double baseline, double current)
|
||||
return ((current - baseline) / baseline) * 100;
|
||||
}
|
||||
|
||||
static string GetRequiredEnvironmentVariable(string variableName)
|
||||
{
|
||||
var value = Environment.GetEnvironmentVariable(variableName);
|
||||
if (string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Environment variable '{variableName}' must be set for this target."
|
||||
);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
record BenchmarkMetric
|
||||
{
|
||||
public string Method { get; init; } = "";
|
||||
|
||||
Reference in New Issue
Block a user