Skip to content

Commit e4bc37d

Browse files
committed
Migrate to slnx, .net 10 and github actions
1 parent 528f304 commit e4bc37d

File tree

9 files changed

+265
-91
lines changed

9 files changed

+265
-91
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: Test and Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- development
8+
- 'cicd/**'
9+
pull_request:
10+
branches:
11+
- master
12+
- development
13+
- 'cicd/**'
14+
15+
concurrency:
16+
group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}}
17+
cancel-in-progress: true
18+
19+
env:
20+
# Disable the .NET logo in the console output.
21+
DOTNET_NOLOGO: true
22+
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
23+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
24+
# Disable sending .NET CLI telemetry to Microsoft.
25+
DOTNET_CLI_TELEMETRY_OPTOUT: true
26+
27+
jobs:
28+
upload-event-file:
29+
name: Upload Event File
30+
runs-on: ubuntu-24.04
31+
steps:
32+
- name: Upload event file
33+
uses: actions/upload-artifact@v5
34+
with:
35+
name: test-event-file
36+
path: ${{ github.event_path }}
37+
retention-days: 1
38+
39+
# Construct a version suffix including the branch name, build number and commit hash (e.g., "development.58+abcdef12").
40+
get-version:
41+
name: Calculating Version Suffix
42+
runs-on: ubuntu-24.04
43+
outputs:
44+
version_suffix: ${{ steps.set-vars.outputs.version_suffix }}
45+
46+
steps:
47+
- uses: actions/checkout@v6
48+
49+
- id: git-vars
50+
name: Get git branch information
51+
shell: bash
52+
run: |
53+
echo "##[set-output name=git_branch;]$(echo $GITHUB_REF)"
54+
echo "::set-output name=git_hash::$(git rev-parse --short HEAD)"
55+
56+
- id: set-vars
57+
uses: actions/github-script@v8
58+
with:
59+
script: |
60+
let runNumber = "${{ github.run_number }}";
61+
let gitHash = "${{ steps.git-vars.outputs.git_hash }}";
62+
let rawGitRef = "${{ steps.git-vars.outputs.git_branch }}";
63+
console.log("rawGitRef: " + rawGitRef);
64+
let gitRef = rawGitRef.replace(/^refs\/heads\//, "").replace(/^refs\/heads\//, "").replace(/[_//!@#$%&]/g, "-");
65+
if(gitRef.indexOf("refs/pull/") === 0) {
66+
gitRef = "pr-" + gitRef.substring(10, gitRef.lastIndexOf("/"));
67+
}
68+
var versSuffix = `${gitRef}.${runNumber}+${gitHash}`;
69+
console.log(versSuffix);
70+
core.setOutput("version_suffix", versSuffix);
71+
72+
# Main build job for compiling all csprojs.
73+
build:
74+
name: Build
75+
runs-on: ubuntu-24.04
76+
needs: [get-version]
77+
timeout-minutes: 10
78+
79+
steps:
80+
- uses: actions/checkout@v6
81+
82+
- name: Setup .NET
83+
uses: actions/setup-dotnet@v5
84+
with:
85+
dotnet-version: '10.0.x'
86+
87+
# Master branch is just a normal build.
88+
- name: Build on master branch
89+
if: ${{github.ref == 'refs/heads/master'}}
90+
run: |
91+
dotnet restore AvaloniaHex.slnx
92+
dotnet build AvaloniaHex.slnx `
93+
--configuration Release
94+
95+
# For non-master branches (e.g., development or feature branches) we apply a fixup on the version suffix.
96+
- name: Build on non-master branch
97+
if: ${{github.ref != 'refs/heads/master'}}
98+
run: |
99+
dotnet restore AvaloniaHex.slnx `
100+
--configuration Release `
101+
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}}
102+
103+
dotnet build AvaloniaHex.slnx `
104+
--configuration Release `
105+
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}}
106+
107+
- name: Upload Build Artifacts
108+
uses: actions/upload-artifact@v5
109+
with:
110+
name: build-artifacts
111+
path: artifacts/
112+
retention-days: 7
113+
114+
# Multiplexed test job running all tests on different architectures.
115+
test:
116+
name: Test
117+
needs: [get-version, build]
118+
runs-on: ubuntu-24.04
119+
timeout-minutes: 20
120+
121+
steps:
122+
- uses: actions/checkout@v6
123+
124+
- name: Setup .NET
125+
uses: actions/setup-dotnet@v5
126+
with:
127+
dotnet-version: '10.0.x'
128+
129+
- name: Download Build Artifacts
130+
uses: actions/download-artifact@v6
131+
with:
132+
name: build-artifacts
133+
path: artifacts/
134+
135+
- name: Run Tests
136+
shell: pwsh
137+
run: |
138+
& dotnet test AvaloniaHex.slnx `
139+
--configuration Release `
140+
--property:VersionSuffix=${{needs.get-version.outputs.version_suffix}} `
141+
--logger "trx" `
142+
--logger "console;verbosity=minimal"
143+
144+
# Collect all trx files and upload them.
145+
- name: Upload Test Results
146+
uses: actions/upload-artifact@v5
147+
if: always()
148+
with:
149+
name: test-results-${{matrix.runner.image}}-${{matrix.runner.arch}}
150+
path: '**/*.trx'
151+
if-no-files-found: 'warn'
152+
retention-days: 1
153+
154+
155+
# Job to publish to nuget feeds.
156+
publish:
157+
name: Publish NuGet Packages
158+
runs-on: ubuntu-24.04
159+
needs: [test]
160+
if: ${{github.ref == 'refs/heads/master'}}
161+
162+
steps:
163+
- uses: actions/checkout@v6
164+
165+
- name: Setup .NET
166+
uses: actions/setup-dotnet@v5
167+
with:
168+
dotnet-version: 10.0.x
169+
170+
- name: Download Build Artifacts
171+
uses: actions/download-artifact@v6
172+
with:
173+
name: build-artifacts
174+
path: artifacts/
175+
176+
- name: Push to NuGet
177+
if: ${{github.ref == 'refs/heads/master'}}
178+
shell: pwsh
179+
env:
180+
NUGET_API_KEY: ${{secrets.NUGET_API_KEY}}
181+
run: dotnet nuget push "./artifacts/**/*.nupkg" -k "$env:NUGET_API_KEY" -s https://api.nuget.org/v3/index.json --skip-duplicate
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish Test Results
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Test and Publish
7+
types: [completed]
8+
permissions: {}
9+
10+
jobs:
11+
publish-test-results:
12+
if: github.event.workflow_run.conclusion != 'skipped' && github.event.workflow_run.conclusion != 'cancelled'
13+
runs-on: ubuntu-24.04
14+
name: Publish Test Results
15+
16+
permissions:
17+
checks: write
18+
pull-requests: write
19+
contents: write
20+
issues: read
21+
actions: read
22+
statuses: read
23+
24+
steps:
25+
- uses: actions/checkout@v6
26+
27+
- name: Download Event File
28+
uses: actions/download-artifact@v4
29+
with:
30+
run-id: ${{ github.event.workflow_run.id }}
31+
github-token: ${{ github.token }}
32+
name: test-event-file
33+
merge-multiple: false
34+
35+
- name: Download Test Results
36+
uses: actions/download-artifact@v4
37+
with:
38+
run-id: ${{ github.event.workflow_run.id }}
39+
github-token: ${{ github.token }}
40+
pattern: test-results-*
41+
path: test-results
42+
merge-multiple: false
43+
44+
- name: Publish Test Results
45+
uses: nike4613/actions-test-results@v3
46+
with:
47+
check_name: Test Results
48+
files: test-results/**/*.trx
49+
fail_on: 'test failures'
50+
comment_mode: 'always'
51+
use_emojis: true
52+
53+
commit: ${{ github.event.workflow_run.head_sha }}
54+
event_file: event.json
55+
event_name: ${{ github.event.workflow_run.event }}
56+
57+
comment_on_commit: true

AvaloniaHex.sln

Lines changed: 0 additions & 47 deletions
This file was deleted.

AvaloniaHex.slnx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Solution>
2+
<Folder Name="/examples/">
3+
<Project Path="examples/AvaloniaHex.Demo/AvaloniaHex.Demo.csproj" />
4+
</Folder>
5+
<Folder Name="/Solution Items/">
6+
<File Path="Directory.Build.props" />
7+
<File Path="LICENSE.md" />
8+
<File Path="README.md" />
9+
</Folder>
10+
<Folder Name="/src/">
11+
<Project Path="src/AvaloniaHex/AvaloniaHex.csproj" />
12+
</Folder>
13+
<Folder Name="/test/">
14+
<Project Path="test/AvaloniaHex.Tests/AvaloniaHex.Tests.csproj" />
15+
</Folder>
16+
</Solution>

appveyor.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/AvaloniaHex.Demo/AvaloniaHex.Demo.csproj

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
4-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
54
<Nullable>enable</Nullable>
65
<!--Avalonia doesen't support TrimMode=link currently,but we are working on that https://github.com/AvaloniaUI/Avalonia/issues/6892 -->
76
<TrimMode>copyused</TrimMode>
87
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
9-
<LangVersion>12</LangVersion>
108
</PropertyGroup>
119
<ItemGroup>
1210
<None Remove=".gitignore"/>
@@ -19,12 +17,12 @@
1917
<TrimmableAssembly Include="Avalonia.Themes.Default"/>
2018
</ItemGroup>
2119
<ItemGroup>
22-
<PackageReference Include="Avalonia" Version="11.3.2" />
23-
<PackageReference Include="Avalonia.Desktop" Version="11.3.2" />
24-
<PackageReference Include="Avalonia.Themes.Simple" Version="11.3.2" />
25-
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2" />
20+
<PackageReference Include="Avalonia" Version="11.3.10" />
21+
<PackageReference Include="Avalonia.Desktop" Version="11.3.10" />
22+
<PackageReference Include="Avalonia.Themes.Simple" Version="11.3.10" />
23+
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.10" />
2624
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
27-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.2" />
25+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.10" />
2826
</ItemGroup>
2927
<ItemGroup>
3028
<ProjectReference Include="..\..\src\AvaloniaHex\AvaloniaHex.csproj" />

src/AvaloniaHex/AvaloniaHex.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<Title>AvaloniaHex</Title>
55
<Description>A hex editor control for the Avalonia UI framework.</Description>
66
<PackageTags>avalonia ui hex editor binary data visualizer</PackageTags>
7-
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
87
<ImplicitUsings>enable</ImplicitUsings>
98
<Nullable>enable</Nullable>
109
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -22,7 +21,7 @@
2221
</PropertyGroup>
2322

2423
<ItemGroup>
25-
<PackageReference Include="Avalonia" Version="11.3.2" />
24+
<PackageReference Include="Avalonia" Version="11.3.10" />
2625
</ItemGroup>
2726

2827
<ItemGroup>

src/AvaloniaHex/HexEditor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Avalonia.Controls;
33
using Avalonia.Controls.Primitives;
44
using Avalonia.Input;
5+
using Avalonia.Input.Platform;
56
using Avalonia.Interactivity;
67
using Avalonia.Media;
78
using AvaloniaHex.Document;
@@ -454,7 +455,7 @@ public async Task Paste()
454455
if (Caret.PrimaryColumn is not {} column || TopLevel.GetTopLevel(this)?.Clipboard is not { } clipboard)
455456
return;
456457

457-
string? text = await clipboard.GetTextAsync();
458+
string? text = await clipboard.TryGetTextAsync();
458459
if (string.IsNullOrEmpty(text))
459460
return;
460461

0 commit comments

Comments
 (0)