Skip to content

Fixes for dotnet workflow. #17

Fixes for dotnet workflow.

Fixes for dotnet workflow. #17

Workflow file for this run

name: .NET Build, Test, and Publish
on:
push:
branches: [ "main" ]
tags: [ 'v*' ]
pull_request:
branches: [ "main" ]
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
sdk: ['8.0.x', '9.0.x']
steps:
- uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.sdk }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.sdk }}
# ───────────────────────────────────────────────
# build only net8.0 on the 8-SDK, all TFM on 9-SDK
# ───────────────────────────────────────────────
- name: Restore
run: |
if [[ "${{ matrix.sdk }}" == "8.0.x" ]]; then
dotnet restore -p:TargetFramework=net8.0
else
dotnet restore
fi
- name: Build
run: |
if [[ "${{ matrix.sdk }}" == "8.0.x" ]]; then
dotnet build --no-restore -c Release -p:TargetFramework=net8.0 -p:EnablePreviewFeatures=true
else
dotnet build --no-restore -c Release
fi
- name: Test
run: |
if [[ "${{ matrix.sdk }}" == "8.0.x" ]]; then
dotnet test --no-build -c Release --framework net8.0 -p:EnablePreviewFeatures=true
else
dotnet test --no-build -c Release
fi
# --------------------------------------------------------------------
# Publish job unchanged (runs on .NET 9 SDK)
# --------------------------------------------------------------------
publish-to-nuget:
name: Publish to NuGet.org
runs-on: ubuntu-latest
needs: build-and-test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Create NuGet package
run: |
VERSION=${GITHUB_REF#refs/tags/v}
dotnet pack src/OatIM.DeltaCompression.csproj \
-c Release /p:Version=$VERSION --output ./nupkg
- name: Publish to NuGet.org
run: dotnet nuget push "./nupkg/*.nupkg" \
--api-key "${{ secrets.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json