Fix some warnings #145
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |