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
159 changes: 77 additions & 82 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,96 @@ env:
on:
push:
paths-ignore:
- '*.md'
- '**.md'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Check formatting
run: dotnet format --verify-no-changes
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test on Ubuntu (no build)
run: dotnet test --no-build --verbosity normal --configuration Release
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: release-artifacts
path: SanitizeFilename/bin/Release/
retention-days: 1
- name: Upload test artifacts
uses: actions/upload-artifact@v7
with:
name: test-artifacts
path: SanitizeFilenameTests/bin/Release/
retention-days: 1

test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
- macos-latest
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Download build artifacts
uses: actions/download-artifact@v8
with:
name: test-artifacts
path: SanitizeFilenameTests/bin/Release/
- name: Test (no build)
run: dotnet test --no-build --verbosity normal --configuration Release
- uses: actions/checkout@v7
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Check formatting
run: dotnet format --verify-no-changes
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release

- name: Upload NuGet package
if: runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: nuget-package
path: ./SanitizeFilename/bin/Release/*.*nupkg
if-no-files-found: error
retention-days: 7

deployRelease:
if: startsWith(github.ref, 'refs/heads/release')
needs: build
runs-on: ubuntu-latest
needs: [build, test]
permissions:
contents: write # gh release create
id-token: write # NuGet Trusted Publishing (OIDC)
steps:
- uses: actions/download-artifact@v8
with:
name: release-artifacts
path: SanitizeFilename/bin/Release/
- name: NugetPush
env:
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }}
if: env.NUGET_TOKEN_EXISTS != ''
run: |
dotnet nuget push ./SanitizeFilename/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
- name: Github release
shell: bash
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
if: env.GITHUB_TOKEN != ''
run: |
gh release create ${{env.CURRENT_VERSION}} ./SanitizeFilename/bin/Release/*.*nupkg --generate-notes
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Download NuGet package
uses: actions/download-artifact@v8
with:
name: nuget-package
path: ./nuget
- name: NuGet login (Trusted Publishing)
uses: NuGet/login@v1
id: nugetLogin
with:
user: ${{ secrets.NUGET_USER }}
- name: NugetPush
run: |
dotnet nuget push ./nuget/*.nupkg --skip-duplicate --api-key ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
- name: Github release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ env.CURRENT_VERSION }} ./nuget/*.*nupkg --repo ${{ github.repository }} --target ${{ github.sha }} --generate-notes

deployTest:
if: github.ref == 'refs/heads/main'
if: ${{ github.ref == 'refs/heads/main' }}
needs: build
runs-on: ubuntu-latest
needs: [build, test]
permissions:
id-token: write # NuGet Trusted Publishing (OIDC)
steps:
- uses: actions/download-artifact@v8
with:
name: release-artifacts
path: SanitizeFilename/bin/Release/
- name: NugetPush
env:
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }}
if: env.NUGET_TOKEN_EXISTS != ''
run: |
ls ./SanitizeFilename/bin/Release
dotnet nuget push ./SanitizeFilename/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.0.x
- name: Download NuGet package
uses: actions/download-artifact@v8
with:
name: nuget-package
path: ./nuget
- name: NuGet login (Trusted Publishing)
uses: NuGet/login@v1
id: nugetLogin
with:
user: ${{ secrets.NUGET_TEST_USER }}
token-service-url: https://int.nugettest.org/api/v2/token
audience: https://int.nugettest.org
- name: NugetPush
run: |
dotnet nuget push ./nuget/*.nupkg --skip-duplicate --api-key ${{ steps.nugetLogin.outputs.NUGET_API_KEY }} --source https://apiint.nugettest.org/v3/index.json
Loading