85 lines
2.1 KiB
YAML
85 lines
2.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build
|
|
run: dotnet build --no-restore --configuration Release
|
|
|
|
- name: Test
|
|
run: dotnet test --no-build --configuration Release --verbosity normal --logger "trx;LogFileName=test-results.trx"
|
|
|
|
- name: Upload test results
|
|
uses: actions/upload-artifact@v4
|
|
if: always()
|
|
with:
|
|
name: test-results-${{ matrix.os }}
|
|
path: '**/test-results.trx'
|
|
|
|
- name: Pack NuGet package
|
|
if: matrix.os == 'ubuntu-latest'
|
|
run: dotnet pack --no-build --configuration Release --output nupkgs
|
|
|
|
- name: Upload NuGet package
|
|
if: matrix.os == 'ubuntu-latest'
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nuget-package
|
|
path: nupkgs/*.nupkg
|
|
|
|
publish:
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
|
|
steps:
|
|
- name: Download NuGet package
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: nuget-package
|
|
path: nupkgs
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
|
|
- name: Publish to NuGet.org
|
|
run: |
|
|
if [ -z "$NUGET_API_KEY" ]; then
|
|
echo "Error: NUGET_API_KEY is not set"
|
|
exit 1
|
|
fi
|
|
for package in nupkgs/*.nupkg; do
|
|
echo "Publishing $package"
|
|
dotnet nuget push "$package" --api-key "$NUGET_API_KEY" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
|
|
done
|
|
env:
|
|
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} |