Skip to content

Commit

Permalink
ci: Publish AOT compiled for releases (#2)
Browse files Browse the repository at this point in the history
- Test publish on build
- Publish pre-compiled self-contained executables on release
  • Loading branch information
skarllot authored Dec 20, 2024
1 parent 59be30b commit 5e2c42d
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 14 deletions.
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"nbgv": {
"version": "3.7.112",
"commands": [
"nbgv"
],
"rollForward": false
}
}
}
22 changes: 20 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ permissions:

jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
runtime: linux-x64
- os: macos-latest
runtime: osx-x64
- os: windows-latest
runtime: win-x64

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash

steps:
- name: 🛡️ Harden Runner
Expand Down Expand Up @@ -67,4 +80,9 @@ jobs:
run: dotnet build --no-restore

- name: ✅ Test
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
run: dotnet test --no-build --verbosity normal -p:CollectCoverage=true -p:CoverletOutputFormat=opencover

- name: ✅ Test Publish
run: |
dotnet publish -r ${{ matrix.runtime }} -c Release
7z a -tzip -mx9 flowpair-${{ matrix.runtime }}.zip $PWD/publish/*.*
26 changes: 22 additions & 4 deletions .github/workflows/package.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@ permissions:
contents: read

jobs:
nuget:
pack:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
runtime: linux-x64
- os: macos-latest
runtime: osx-x64
- os: windows-latest
runtime: win-x64

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash

steps:
- name: 🛡️ Harden Runner
Expand Down Expand Up @@ -56,7 +69,12 @@ jobs:
run: dotnet build --no-restore -c Release

- name: 📦 Pack
run: dotnet pack /p:CI=true /p:PublicRelease=true --no-build -c Release
run: |
dotnet publish -r ${{ matrix.runtime }} -c Release
7z a -tzip -mx9 flowpair-${{ matrix.runtime }}-${{ github.ref_name }}.zip $PWD/publish/*.*
- name: 🚀 Publish
run: dotnet nuget push "artifacts/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_APIKEY }} --skip-duplicate
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: "flowpair*.zip"
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<AssemblyName>$(RootNamespace)</AssemblyName>
<SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)</SolutionDir>
<PackageOutputPath>$(SolutionDir)artifacts</PackageOutputPath>
<PublishDir>$(SolutionDir)publish</PublishDir>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<LangVersion>13</LangVersion>
<Nullable>enable</Nullable>
Expand Down
7 changes: 7 additions & 0 deletions flow-pair.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F62983E1
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowPair", "src\FlowPair\FlowPair.csproj", "{C5518AFB-A554-41EF-A8B4-CD6A08A60E1C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FlowPair.Tests", "tests\FlowPair.Tests\FlowPair.Tests.csproj", "{7A174BD3-2DCE-4854-B35D-84A4AC733417}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -24,11 +26,16 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C5518AFB-A554-41EF-A8B4-CD6A08A60E1C} = {B48F9C8B-2277-4F7C-A5B7-9517F509E434}
{7A174BD3-2DCE-4854-B35D-84A4AC733417} = {F62983E1-C491-4C83-BC2B-8FB2E7B251ED}
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C5518AFB-A554-41EF-A8B4-CD6A08A60E1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5518AFB-A554-41EF-A8B4-CD6A08A60E1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C5518AFB-A554-41EF-A8B4-CD6A08A60E1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C5518AFB-A554-41EF-A8B4-CD6A08A60E1C}.Release|Any CPU.Build.0 = Release|Any CPU
{7A174BD3-2DCE-4854-B35D-84A4AC733417}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7A174BD3-2DCE-4854-B35D-84A4AC733417}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A174BD3-2DCE-4854-B35D-84A4AC733417}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A174BD3-2DCE-4854-B35D-84A4AC733417}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
6 changes: 4 additions & 2 deletions src/FlowPair/FlowPair.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<TrimMode>full</TrimMode>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

Expand Down
81 changes: 75 additions & 6 deletions src/FlowPair/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@
"LibGit2Sharp.NativeBinaries": "[2.0.323]"
}
},
"Microsoft.DotNet.ILCompiler": {
"type": "Direct",
"requested": "[9.0.0, )",
"resolved": "9.0.0",
"contentHash": "bbnlV2PbUmCQ8Ndpx0kJaicLyV28IU+4IzyctQLL57+DxrHurYr2qsJrC8+yD44Q0DyPfv2oM168c1Tk6Bxbmg=="
},
"Microsoft.Extensions.DependencyInjection.Abstractions": {
"type": "Direct",
"requested": "[9.0.0, )",
Expand Down Expand Up @@ -182,6 +176,81 @@
"resolved": "21.1.7",
"contentHash": "qsaIAF06PJiFUp1jH2y5NP3IcJILUYtcdGgx25p3D9G4QrFz4Cs3frGp8njX+zQWeb/tHBS+CTMHZtU7Nqa1lg=="
}
},
"net9.0/linux-arm64": {
"LibGit2Sharp.NativeBinaries": {
"type": "Transitive",
"resolved": "2.0.323",
"contentHash": "Kg+fJGWhGj5qRXG0Ilj4ddhuodGXZg57yhfX6OVUDR0M2DKg/UR42/d74+qv5l1qotc1qJilo/ho7xQnULP6yA=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
}
},
"net9.0/linux-x64": {
"LibGit2Sharp.NativeBinaries": {
"type": "Transitive",
"resolved": "2.0.323",
"contentHash": "Kg+fJGWhGj5qRXG0Ilj4ddhuodGXZg57yhfX6OVUDR0M2DKg/UR42/d74+qv5l1qotc1qJilo/ho7xQnULP6yA=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
}
},
"net9.0/osx-arm64": {
"LibGit2Sharp.NativeBinaries": {
"type": "Transitive",
"resolved": "2.0.323",
"contentHash": "Kg+fJGWhGj5qRXG0Ilj4ddhuodGXZg57yhfX6OVUDR0M2DKg/UR42/d74+qv5l1qotc1qJilo/ho7xQnULP6yA=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
}
},
"net9.0/osx-x64": {
"LibGit2Sharp.NativeBinaries": {
"type": "Transitive",
"resolved": "2.0.323",
"contentHash": "Kg+fJGWhGj5qRXG0Ilj4ddhuodGXZg57yhfX6OVUDR0M2DKg/UR42/d74+qv5l1qotc1qJilo/ho7xQnULP6yA=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
}
},
"net9.0/win-x64": {
"LibGit2Sharp.NativeBinaries": {
"type": "Transitive",
"resolved": "2.0.323",
"contentHash": "Kg+fJGWhGj5qRXG0Ilj4ddhuodGXZg57yhfX6OVUDR0M2DKg/UR42/d74+qv5l1qotc1qJilo/ho7xQnULP6yA=="
},
"System.Text.Encoding.CodePages": {
"type": "Transitive",
"resolved": "6.0.0",
"contentHash": "ZFCILZuOvtKPauZ/j/swhvw68ZRi9ATCfvGbk1QfydmcXBkIWecWKn/250UH7rahZ5OoDBaiAudJtPvLwzw85A==",
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
}
}
}
}
19 changes: 19 additions & 0 deletions tests/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
</ItemGroup>
</Project>
27 changes: 27 additions & 0 deletions tests/FlowPair.Tests/FlowPair.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" />
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>

</Project>
Loading

0 comments on commit 5e2c42d

Please sign in to comment.