Skip to content

Commit 0122ba1

Browse files
committed
Create basic CI/CD for interface package
1 parent b39b4c0 commit 0122ba1

File tree

6 files changed

+241
-120
lines changed

6 files changed

+241
-120
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto
2+
*.cs text
3+
*.csproj text
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Harp.Olfactometer
2+
on:
3+
push:
4+
# This prevents tag pushes from triggering this workflow
5+
branches: ['*']
6+
pull_request:
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
env:
11+
DOTNET_NOLOGO: true
12+
DOTNET_CLI_TELEMETRY_OPTOUT: true
13+
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
14+
ContinuousIntegrationBuild: true
15+
CiBuildVersion: ${{github.event.release.tag_name || 'api42.42.42'}}
16+
jobs:
17+
build:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
configuration: ['Release']
22+
include:
23+
- configuration: Release
24+
collect-packages: true
25+
name: Build
26+
runs-on: windows-latest
27+
if: github.event_name != 'release' || startsWith(github.event.release.tag_name, 'api')
28+
steps:
29+
# ----------------------------------------------------------------------- Checkout
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
# ----------------------------------------------------------------------- Set up tools
34+
- name: Set up .NET
35+
uses: actions/setup-dotnet@v4
36+
with:
37+
dotnet-version: 8.x
38+
39+
- name: Set up T4
40+
run: dotnet tool install -g dotnet-t4 --version 3.0.0
41+
42+
# ----------------------------------------------------------------------- Regenerate
43+
- name: Restore generators
44+
run: dotnet restore Generators
45+
46+
- name: Run generators
47+
run: dotnet build Generators --no-restore --configuration ${{matrix.configuration}}
48+
49+
- name: Verify pre-generated code was up-to-date
50+
id: verify-dist
51+
run: |
52+
git add . --intent-to-add --ignore-removal
53+
git diff --name-status --exit-code
54+
55+
# ----------------------------------------------------------------------- Build interface package
56+
- name: Restore interface
57+
run: dotnet restore Interface
58+
59+
- name: Build interface
60+
run: dotnet build Interface --no-restore --configuration ${{matrix.configuration}}
61+
62+
- name: Pack interface
63+
id: pack
64+
run: dotnet pack Interface --no-restore --no-build --configuration ${{matrix.configuration}}
65+
66+
# ----------------------------------------------------------------------- Collect artifacts
67+
- name: Collect NuGet packages
68+
uses: actions/upload-artifact@v4
69+
if: matrix.collect-packages && steps.pack.outcome == 'success' && always()
70+
with:
71+
name: Packages
72+
if-no-files-found: error
73+
path: Interface/bin/${{matrix.configuration}}/**
74+
75+
publish-packages-nuget-org:
76+
name: Publish packages to NuGet.org
77+
runs-on: ubuntu-latest
78+
permissions:
79+
# Needed to attach files to releases
80+
contents: write
81+
environment: public-release
82+
needs: build
83+
if: github.event_name == 'release'
84+
steps:
85+
# ----------------------------------------------------------------------- Set up .NET
86+
- name: Setup .NET
87+
uses: actions/setup-dotnet@v4
88+
with:
89+
dotnet-version: 8.x
90+
91+
# ----------------------------------------------------------------------- Download built packages
92+
- name: Download built packages
93+
uses: actions/download-artifact@v4
94+
with:
95+
name: Packages
96+
path: artifacts/packages/
97+
98+
# ----------------------------------------------------------------------- Push to NuGet.org
99+
- name: Push to NuGet.org
100+
run: dotnet nuget push "artifacts/packages/*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source ${{vars.NUGET_API_URL}}
101+
env:
102+
# This is a workaround for https://github.com/NuGet/Home/issues/9775
103+
DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
using Avalonia;
2-
using Avalonia.Controls.ApplicationLifetimes;
3-
using Avalonia.Markup.Xaml;
4-
using Olfactometer.Design.ViewModels;
5-
using Olfactometer.Design.Views;
6-
7-
namespace Olfactometer.Design;
8-
9-
public partial class App : Application
10-
{
11-
public override void Initialize()
12-
{
13-
AvaloniaXamlLoader.Load(this);
14-
}
15-
16-
public override void OnFrameworkInitializationCompleted()
17-
{
18-
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
19-
{
20-
desktop.MainWindow = new MainWindow
21-
{
22-
DataContext = new MainWindowViewModel(),
23-
};
24-
}
25-
26-
base.OnFrameworkInitializationCompleted();
27-
}
28-
}
1+
using Avalonia;
2+
using Avalonia.Controls.ApplicationLifetimes;
3+
using Avalonia.Markup.Xaml;
4+
using Olfactometer.Design.ViewModels;
5+
using Olfactometer.Design.Views;
6+
7+
namespace Olfactometer.Design;
8+
9+
public partial class App : Application
10+
{
11+
public override void Initialize()
12+
{
13+
AvaloniaXamlLoader.Load(this);
14+
}
15+
16+
public override void OnFrameworkInitializationCompleted()
17+
{
18+
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
19+
{
20+
desktop.MainWindow = new MainWindow
21+
{
22+
DataContext = new MainWindowViewModel(),
23+
};
24+
}
25+
26+
base.OnFrameworkInitializationCompleted();
27+
}
28+
}
Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<OutputType>Library</OutputType>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
6-
<RootNamespace>Olfactometer.Design</RootNamespace>
7-
<Version>1.1.0</Version>
8-
<Nullable>enable</Nullable>
9-
</PropertyGroup>
10-
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
11-
<OutputPath>../bin/Debug/</OutputPath>
12-
</PropertyGroup>
13-
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
14-
<OutputPath>../bin/Release/</OutputPath>
15-
</PropertyGroup>
16-
17-
<ItemGroup>
18-
<Compile Update="**\*.xaml.cs">
19-
<DependentUpon>%(Filename)</DependentUpon>
20-
</Compile>
21-
<AvaloniaResource Include="**\*.xaml">
22-
<SubType>Designer</SubType>
23-
</AvaloniaResource>
24-
<AvaloniaResource Include="Assets\**"/>
25-
<Compile Update="App.axaml.cs">
26-
<DependentUpon>App.axaml</DependentUpon>
27-
<SubType>Code</SubType>
28-
</Compile>
29-
</ItemGroup>
30-
31-
<ItemGroup>
32-
<ProjectCapability Include="Avalonia"/>
33-
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent"/>
34-
</ItemGroup>
35-
36-
<ItemGroup>
37-
<EmbeddedResource Include="Assets\Fonts\OpenSans-Bold.ttf"/>
38-
<EmbeddedResource Include="Assets\Fonts\OpenSans-BoldItalic.ttf"/>
39-
<EmbeddedResource Include="Assets\Fonts\OpenSans-ExtraBold.ttf"/>
40-
<EmbeddedResource Include="Assets\Fonts\OpenSans-ExtraBoldItalic.ttf"/>
41-
<EmbeddedResource Include="Assets\Fonts\OpenSans-Italic.ttf"/>
42-
<EmbeddedResource Include="Assets\Fonts\OpenSans-Light.ttf"/>
43-
<EmbeddedResource Include="Assets\Fonts\OpenSans-LightItalic.ttf"/>
44-
<EmbeddedResource Include="Assets\Fonts\OpenSans-Regular.ttf"/>
45-
<EmbeddedResource Include="Assets\Fonts\OpenSans-SemiBold.ttf"/>
46-
<EmbeddedResource Include="Assets\Fonts\OpenSans-SemiBoldItalic.ttf"/>
47-
</ItemGroup>
48-
49-
<ItemGroup>
50-
<PackageReference Include="Avalonia" Version="0.10.21"/>
51-
<PackageReference Include="Avalonia.Desktop" Version="0.10.21"/>
52-
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
53-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.21"/>
54-
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.21"/>
55-
<PackageReference Include="Avalonia.ReactiveUI.Events" Version="0.10.21"/>
56-
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.18"/>
57-
<PackageReference Include="HexIO" Version="3.0.5"/>
58-
<PackageReference Include="MessageBox.Avalonia" Version="2.1.0"/>
59-
<PackageReference Include="ReactiveUI.Fody" Version="19.2.1"/>
60-
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7"/>
61-
<PackageReference Include="System.IO.Ports" Version="6.0.0"/>
62-
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1"/>
63-
</ItemGroup>
64-
65-
<ItemGroup>
66-
<ProjectReference Include="..\..\Interface\Harp.Olfactometer\Harp.Olfactometer.csproj"/>
67-
</ItemGroup>
68-
69-
<ItemGroup>
70-
<Folder Include="Models\"/>
71-
</ItemGroup>
72-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Library</OutputType>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
6+
<RootNamespace>Olfactometer.Design</RootNamespace>
7+
<Version>1.1.0</Version>
8+
<Nullable>enable</Nullable>
9+
</PropertyGroup>
10+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
11+
<OutputPath>../bin/Debug/</OutputPath>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
14+
<OutputPath>../bin/Release/</OutputPath>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<Compile Update="**\*.xaml.cs">
19+
<DependentUpon>%(Filename)</DependentUpon>
20+
</Compile>
21+
<AvaloniaResource Include="**\*.xaml">
22+
<SubType>Designer</SubType>
23+
</AvaloniaResource>
24+
<AvaloniaResource Include="Assets\**"/>
25+
<Compile Update="App.axaml.cs">
26+
<DependentUpon>App.axaml</DependentUpon>
27+
<SubType>Code</SubType>
28+
</Compile>
29+
</ItemGroup>
30+
31+
<ItemGroup>
32+
<ProjectCapability Include="Avalonia"/>
33+
<TrimmerRootAssembly Include="Avalonia.Themes.Fluent"/>
34+
</ItemGroup>
35+
36+
<ItemGroup>
37+
<EmbeddedResource Include="Assets\Fonts\OpenSans-Bold.ttf"/>
38+
<EmbeddedResource Include="Assets\Fonts\OpenSans-BoldItalic.ttf"/>
39+
<EmbeddedResource Include="Assets\Fonts\OpenSans-ExtraBold.ttf"/>
40+
<EmbeddedResource Include="Assets\Fonts\OpenSans-ExtraBoldItalic.ttf"/>
41+
<EmbeddedResource Include="Assets\Fonts\OpenSans-Italic.ttf"/>
42+
<EmbeddedResource Include="Assets\Fonts\OpenSans-Light.ttf"/>
43+
<EmbeddedResource Include="Assets\Fonts\OpenSans-LightItalic.ttf"/>
44+
<EmbeddedResource Include="Assets\Fonts\OpenSans-Regular.ttf"/>
45+
<EmbeddedResource Include="Assets\Fonts\OpenSans-SemiBold.ttf"/>
46+
<EmbeddedResource Include="Assets\Fonts\OpenSans-SemiBoldItalic.ttf"/>
47+
</ItemGroup>
48+
49+
<ItemGroup>
50+
<PackageReference Include="Avalonia" Version="0.10.21"/>
51+
<PackageReference Include="Avalonia.Desktop" Version="0.10.21"/>
52+
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
53+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.21"/>
54+
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.21"/>
55+
<PackageReference Include="Avalonia.ReactiveUI.Events" Version="0.10.21"/>
56+
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.18"/>
57+
<PackageReference Include="HexIO" Version="3.0.5"/>
58+
<PackageReference Include="MessageBox.Avalonia" Version="2.1.0"/>
59+
<PackageReference Include="ReactiveUI.Fody" Version="19.2.1"/>
60+
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7"/>
61+
<PackageReference Include="System.IO.Ports" Version="6.0.0"/>
62+
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1"/>
63+
</ItemGroup>
64+
65+
<ItemGroup>
66+
<ProjectReference Include="..\..\Interface\Harp.Olfactometer\Harp.Olfactometer.csproj"/>
67+
</ItemGroup>
68+
69+
<ItemGroup>
70+
<Folder Include="Models\"/>
71+
</ItemGroup>
72+
</Project>
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
using Avalonia;
2-
using Avalonia.ReactiveUI;
3-
using ReactiveUI;
4-
5-
namespace Olfactometer.Design
6-
{
7-
public class StartApp
8-
{
9-
// Avalonia configuration, don't remove; also used by visual designer.
10-
public static AppBuilder BuildAvaloniaApp()
11-
{
12-
RxApp.DefaultExceptionHandler = new MyCustomObservableExceptionHandler();
13-
14-
return AppBuilder.Configure<App>()
15-
.UsePlatformDetect()
16-
.LogToTrace()
17-
.UseReactiveUI();
18-
}
19-
}
20-
}
1+
using Avalonia;
2+
using Avalonia.ReactiveUI;
3+
using ReactiveUI;
4+
5+
namespace Olfactometer.Design
6+
{
7+
public class StartApp
8+
{
9+
// Avalonia configuration, don't remove; also used by visual designer.
10+
public static AppBuilder BuildAvaloniaApp()
11+
{
12+
RxApp.DefaultExceptionHandler = new MyCustomObservableExceptionHandler();
13+
14+
return AppBuilder.Configure<App>()
15+
.UsePlatformDetect()
16+
.LogToTrace()
17+
.UseReactiveUI();
18+
}
19+
}
20+
}

Interface/Directory.Build.props

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Force malformed versions to be an error -->
4+
<WarningsAsErrors>$(WarningsAsErrors);CS7035</WarningsAsErrors>
5+
<NoWarn>$(NoWarn);CS1591</NoWarn>
6+
</PropertyGroup>
7+
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
8+
<Version Condition="$(CiBuildVersion.StartsWith('api'))">$(CiBuildVersion.Substring(3))</Version>
9+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
10+
</PropertyGroup>
11+
<Target Name="VersionSanityChecks" BeforeTargets="build;restore">
12+
<Error Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(CiBuildVersion)' == ''" Text="CI version info not configured." />
13+
<Error Condition="'api$(Version)' != '$(CiBuildVersion)'" Text="CI version info was not applied correctly." />
14+
</Target>
15+
</Project>

0 commit comments

Comments
 (0)