1616 - ' main'
1717
1818jobs :
19- build :
20- if : (github.event_name != 'pull_request' && ! github.event.pull_request.head.repo.fork) || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || startsWith(github.head_ref, 'dependabot/')))
21- # Use an Ubuntu-based container to build the project
19+ build-and-test-linux :
20+ if : |
21+ (github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
22+ || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
23+ || startsWith(github.head_ref, 'dependabot/')))
2224 runs-on : ubuntu-latest
2325
24- container :
25- image : unityci/editor:ubuntu-2022.3.20f1-windows-mono-3.1.0
26-
2726 steps :
2827 - name : Checkout repository
2928 uses : actions/checkout@v4
3534 uses : actions/setup-dotnet@v4
3635 with :
3736 dotnet-version : 8.0.x
38-
37+
38+ - name : Install Mono (required for .NET Framework tests on Linux)
39+ run : |
40+ sudo apt update
41+ sudo apt install -y mono-complete
42+
3943 - name : Install GitVersion
4044 uses : gittools/actions/gitversion/setup@v3.1.1
4145 with :
@@ -50,42 +54,81 @@ jobs:
5054 ${{ runner.os }}-nuget-
5155
5256 - name : Determine Version
57+ id : version_step
5358 run : |
5459 chown -R $(whoami) $(pwd)
55- dotnet-gitversion /output json
60+ dotnet-gitversion /output json > version.json
61+ echo "FULL_SEM_VER=$(grep -oP '"FullSemVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
62+ echo "ASSEMBLY_VERSION=$(grep -oP '"AssemblySemFileVer":\s*"\K[^"]+' version.json)" >> $GITHUB_ENV
5663
5764 - name : Restore dependencies
5865 run : dotnet restore
5966
6067 - name : Build Solution
61- env :
62- UnityManagedPath : \opt\unity\Editor\Data\Managed
6368 run : |
64- echo "Version:${{ env.GitVersion_FullSemVer }}\nAssembley Version:${{ env.GitVersion_AssemblySemFileVer }}"
65- dotnet build --configuration Release --no-restore
69+ echo "Version: ${{ env.FULL_SEM_VER }}"
70+ echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
71+ dotnet build --configuration Debug --no-restore
6672
67- - name : Upload Test Artifacts
68- uses : actions/upload-artifact@v4
69- with :
70- name : BuildOutputTest
71- path : ./tests/FixedMathSharp.Tests/bin/Release
73+ - name : Test .NET48
74+ run : |
75+ mono ~/.nuget/packages/xunit.runner.console/2.9.3/tools/net48/xunit.console.exe ${{github.workspace}}/tests/FixedMathSharp.Tests/bin/Debug/net48/FixedMathSharp.Tests.dll
76+
77+ - name : Test .NET8
78+ run : |
79+ dotnet test -f net8 --verbosity normal
7280
73- test :
74- # Use a Windows runner to execute the .NET Framework tests
81+ build-and-test-windows :
82+ if : |
83+ (github.event_name != 'pull_request' && !github.event.pull_request.head.repo.fork)
84+ || (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork
85+ || startsWith(github.head_ref, 'dependabot/')))
7586 runs-on : windows-latest
76- needs : build
77-
7887 steps :
7988 - name : Checkout repository
8089 uses : actions/checkout@v4
81-
82- - name : Download Test Artifacts
83- uses : actions/download-artifact@v4
8490 with :
85- name : BuildOutputTest
86- path : ./tests/FixedMathSharp.Tests/bin/Release
87-
88- - name : Test
91+ fetch-depth : 0
92+ persist-credentials : false
93+
94+ - name : Setup .NET
95+ uses : actions/setup-dotnet@v4
96+ with :
97+ dotnet-version : 8.0.x
98+
99+ - name : Install GitVersion
100+ uses : gittools/actions/gitversion/setup@v3.1.1
101+ with :
102+ versionSpec : 6.0.x
103+
104+ - name : Cache NuGet packages
105+ uses : actions/cache@v3
106+ with :
107+ path : ~/.nuget/packages
108+ key : ' ${{ runner.os }}-nuget-${{ hashFiles('' **/*.csproj'' , '' **/*.sln'' ) }}'
109+ restore-keys : |
110+ ${{ runner.os }}-nuget-
111+
112+ - name : Determine Version
113+ id : version_step
114+ shell : pwsh
115+ run : |
116+ chown -R $env:USERNAME $(Get-Location)
117+ dotnet-gitversion /output json | Out-File -FilePath version.json
118+ $json = Get-Content version.json | ConvertFrom-Json
119+ echo "FULL_SEM_VER=$($json.FullSemVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
120+ echo "ASSEMBLY_VERSION=$($json.AssemblySemFileVer)" | Out-File -FilePath $env:GITHUB_ENV -Append
121+
122+ - name : Restore dependencies
123+ run : dotnet restore
124+
125+ - name : Build Solution
126+ run : |
127+ echo "Version: ${{ env.FULL_SEM_VER }}"
128+ echo "Assembly Version: ${{ env.ASSEMBLY_VERSION }}"
129+ dotnet build --configuration Debug --no-restore
130+
131+ - name : Test .NET48 & .NET8
89132 run : |
90133 dotnet --info
91- dotnet test ${{ github.workspace }}\tests\FixedMathSharp.Tests\bin\Release\net48\FixedMathSharp.Tests.dll --verbosity normal
134+ dotnet test --verbosity normal
0 commit comments