Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 101 additions & 28 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,121 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ published ]
workflow_dispatch:

permissions:
contents: read
contents: write
checks: write
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
NuGetDir: ${{ github.workspace }}/nuget

jobs:
build:
create-nuget:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7.0.x
8.0.x
- name: Pack
run: dotnet pack --configuration Release --output ${{ env.NuGetDir }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDir }}/*.nupkg

validate-nuget:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '7.0.x' ]
needs: [ create-nuget ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDir }}
- name: Install NuGet Validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
- name: Validate package
run: >-
meziantou.validate-nuget-package ${{ env.NuGetDir }}/*.nupkg
--excluded-rule-ids 32

run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7.0.x
8.0.x
- name: Test
run: dotnet test --verbosity normal --logger "trx" --results-directory "./TestResults" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[LinkAce.*.Tests?]*"
- uses: dorny/test-reporter@v1
if: always()
with:
name: .NET Test Results
path: TestResults/*.trx
reporter: dotnet-trx
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4

publish-to-github-packages:
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [ validate-nuget, run-tests ]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDir }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
source-url: https://nuget.pkg.github.com/prplecake/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
# - name: Test
# run: dotnet test --no-build --verbosity normal --logger "trx" --results-directory "./TestResults"
# - uses: dorny/test-reporter@v1
# if: always()
# with:
# name: .NET Test Results
# path: TestResults/*.trx
# reporter: dotnet-trx
- name: Pack NuGet
run: dotnet pack -c Release -o packages
- name: Upload NuGet Artifact
uses: actions/upload-artifact@v4
with:
path: src/LinkAce.NET/bin/Release/*.nupkg
- name: Push NuGet
if: ${{ github.event_name != 'pull_request' }}
run: |
dotnet nuget push packages/*.nupkg --skip-duplicate
- name: Publish to GitHub Packages
run: dotnet nuget push ${{ env.NuGetDir }}/*.nupkg --skip-duplicate

publish-to-nuget:
runs-on: ubuntu-latest
if: github.event_name == 'release'
needs: [ validate-nuget, run-tests ]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDir }}
- name: Setup .NET
uses: actions/setup-dotnet@v4
- name: Publish to NuGet
run: dotnet nuget push --api-key "${{ secrets.NUGET_API_KEY }}" ${{ env.NuGetDir }}/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate