-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin native tools CLI as example program for native volatile process
This project builds an executable file for each supported OS that we can use with the planned new (native) volatile process model.
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: build-native-tools | ||
|
||
on: [push,workflow_dispatch] | ||
|
||
jobs: | ||
build: | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
environment: [ubuntu-22.04, windows-2022, macos-13] | ||
include: | ||
- environment: ubuntu-22.04 | ||
publish-runtime-id: linux-x64 | ||
- environment: windows-2022 | ||
publish-runtime-id: win10-x64 | ||
- environment: macos-13 | ||
publish-runtime-id: osx-x64 | ||
|
||
runs-on: ${{ matrix.environment }} | ||
|
||
steps: | ||
|
||
- name: Avoid git mutating files on checkout | ||
run: | | ||
git config --global core.autocrlf false | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: '7.0.304' | ||
|
||
- name: Try use dotnet | ||
run: dotnet --info | ||
|
||
- name: Clean package cache as a temporary workaround for https://github.com/actions/setup-dotnet/issues/155 | ||
run: dotnet clean ./implement/native-tools/native-tools.csproj && dotnet nuget locals all --clear | ||
|
||
- name: dotnet publish | ||
run: dotnet publish -c Debug -r ${{ matrix.publish-runtime-id }} --output ./dotnet-build ./implement/native-tools | ||
|
||
- name: Copy artifacts to publish | ||
shell: pwsh | ||
run: | | ||
New-Item -ItemType Directory -Force -Path "./publish"; | ||
Get-ChildItem -Path "./dotnet-build/" -Filter "native-tools*" | ForEach-Object { Copy-Item -Path $_.FullName -Destination "./publish/" } | ||
- name: Publish artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: native-tools-bin-${{ github.sha }}-${{ matrix.publish-runtime-id }} | ||
path: ./publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Text.Json; | ||
|
||
namespace native_tools; | ||
|
||
public class EchoJson | ||
{ | ||
public static int EchoJsonLoop() | ||
{ | ||
while (true) | ||
{ | ||
var lineText = Console.ReadLine()?.Trim(); | ||
|
||
if (string.IsNullOrEmpty(lineText)) | ||
{ | ||
continue; | ||
} | ||
|
||
try | ||
{ | ||
var json = JsonSerializer.Deserialize<JsonElement>(lineText); | ||
Console.WriteLine(JsonSerializer.Serialize(json) + "\n"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.Error.WriteLine("Failed with runtime exception:\n" + ex); | ||
return 1; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.CommandLine; | ||
using System.Threading.Tasks; | ||
|
||
namespace native_tools; | ||
|
||
public class Program | ||
{ | ||
static async Task<int> Main(string[] args) | ||
{ | ||
var rootCommand = new RootCommand("Collection of native tools"); | ||
|
||
var echoJsonCommand = new Command("echo-json", "Echoes the JSON string to the console."); | ||
|
||
echoJsonCommand.SetHandler(() => | ||
{ | ||
EchoJson.EchoJsonLoop(); | ||
}); | ||
|
||
rootCommand.Add(echoJsonCommand); | ||
|
||
return await rootCommand.InvokeAsync(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RootNamespace>native_tools</RootNamespace> | ||
<Nullable>enable</Nullable> | ||
<PublishSingleFile>true</PublishSingleFile> | ||
<SelfContained>true</SelfContained> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |