-
Notifications
You must be signed in to change notification settings - Fork 25
182 lines (156 loc) · 6.59 KB
/
dotnet-core.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: .NET Core
on:
release:
types: [published]
push:
branches:
- '*'
tags-ignore:
- '*'
pull_request:
branches:
- main
env:
CORE_SLN: ./src/Imageflow.dncore.sln
FULL_SLN: ./src/Imageflow.dnfull.sln
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: macos-11.0
- os: ubuntu-latest
test_aot: true
- os: ubuntu-latest
SystemTextJsonVersion: 8.0.1
- os: windows-latest
pack: true
docs: true
coverage: true
test_legacy: true
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6
7
8
- uses: nowsprinting/[email protected]
id: version
with:
prefix: 'v'
- name: For releases only - set TAGGED_VERSION and ARTIFACT_VERSION
run: |
echo "TAGGED_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
echo "ARTIFACT_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
echo Set version to ${{ steps.version.outputs.full_without_prefix }}
shell: bash
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
- name: Set ARTIFACT_VERSION to commit-${{ github.sha }} for non-release builds
run: |
echo "ARTIFACT_VERSION=commit-${{ github.sha }}" >> $GITHUB_ENV
echo Set ARTIFACT_VERSION to commit-${{ github.sha }}
shell: bash
if: steps.version.outputs.is_valid == 'false' || github.event_name != 'release'
- run: |
dotnet clean ${{ env.CORE_SLN }} --configuration Release
dotnet nuget locals all --clear
if: github.event_name == 'release'
- name: Test with ${{ matrix.SystemTextJsonVersion }} and ${{ matrix.RecyclableMemoryStreamVersion }}
if: matrix.SystemTextJsonVersion != null && matrix.RecyclableMemoryStreamVersion != null
run: |
dotnet test ${{ env.CORE_SLN }} -p:SystemTextJsonVersion=${{ matrix.SystemTextJsonVersion }} -p:RecyclableMemoryStreamVersion=${{ matrix.RecyclableMemoryStreamVersion }} -c Release
- name: Install dependencies
run: dotnet restore ${{ env.CORE_SLN }} --force-evaluate
- name: Build all modern dotnet projects
run: dotnet build ${{ env.CORE_SLN }} --maxcpucount:1 -c Release
- name: Test, relying on projects to only conditionally enable net48 TFMs on windows
if: matrix.coverage == false
run: |
dotnet test ${{ env.CORE_SLN }} -c Release
- name: Test with coverage
if: matrix.coverage
run: |
dotnet test ${{ env.CORE_SLN }} -c Release --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- uses: actions/upload-artifact@v4
if: failure()
with:
name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
path: TestResults/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.coverage
with:
files:
token: ${{ secrets.CODECOV_TOKEN }} # replace with your Codecov token
fail_ci_if_error: false
# - uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
# path: TestResults/
- name: Pack
run: |
dotnet pack ./src/Imageflow/Imageflow.Net.csproj -c Release --include-source -o NuGetPackages/Release/
dotnet pack ./src/Imageflow.AllPlatforms/Imageflow.AllPlatforms.csproj -c Release --include-source -o NuGetPackages/Release/
if: matrix.pack
- name: Upload artifacts
uses: actions/upload-artifact@v4
id: nuget-artifact-upload-step
if: matrix.pack
with:
name: NuGetPackages
path: |
NuGetPackages/Release/*.nupkg
NuGetPackages/Release/*.snupkg
- name: Add msbuild to PATH
uses: microsoft/[email protected]
if: matrix.os == 'windows-latest' && matrix.test_legacy
- name: Build legacy projects on Windows
if: matrix.test_legacy
run: |
nuget restore tests/Imageflow.TestDotNetFull/Imageflow.TestDotNetFull.csproj -SolutionDirectory src
nuget restore tests/Imageflow.TestDotNetFullPackageReference/Imageflow.TestDotNetFullPackageReference.csproj -SolutionDirectory src
msbuild src/Imageflow.dnfull.sln /p:Configuration=Release /p:Platform="Any CPU"
- name: Legacy - Test Imageflow.TestDotNetFull and Imageflow.TestDotNetFullPackageReference
if: matrix.test_legacy
run: |
dotnet test tests/Imageflow.TestDotNetFull/bin/Release/Imageflow.TestDotNetFull.dll
dotnet test tests/Imageflow.TestDotNetFullPackageReference/bin/Release/Imageflow.TestDotNetFullPackageReference.dll
dotnet test tests/Imageflow.TestDotNetFull/bin/Release/Imageflow.TestDotNetFull.dll --platform:x86
dotnet test tests/Imageflow.TestDotNetFullPackageReference/bin/Release/Imageflow.TestDotNetFullPackageReference.dll --platform:x86
dotnet test tests/Imageflow.TestDotNetFull/bin/Release/Imageflow.TestDotNetFull.dll --platform:x64
dotnet test tests/Imageflow.TestDotNetFullPackageReference/bin/Release/Imageflow.TestDotNetFullPackageReference.dll --platform:x64
- name: Test use in an AOT web app
if: matrix.test_aot
shell: pwsh
run: ./tests/Imageflow.TestWebAOT/test.ps1
publish:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'
# Download nuget artifacts from the test job into a folder called NuGetPackages
- name: Download artifacts
uses: actions/download-artifact@v4
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
with:
name: NuGetPackages
path: NuGetPackages
- name: Publish NuGet packages to Nuget.org
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
run: |
dotnet nuget push NuGetPackages/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json