(#3) security: remove extensions #5
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 CI Build, Test, and Publish | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '9.x' | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build all projects | |
run: dotnet build --configuration Release --no-restore | |
- name: Test all projects with coverage | |
run: | | |
for testProject in $(find ./src -type f -name '*.Tests.csproj'); do | |
echo "Running tests for $testProject" | |
dotnet test $testProject --configuration Release --no-build \ | |
--collect:"XPlat Code Coverage" \ | |
--results-directory TestResults/ \ | |
/p:CollectCoverage=true \ | |
/p:CoverletOutputFormat=cobertura \ | |
--logger "trx;LogFileName=TestResults.trx" | |
done | |
- name: Upload test results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: TestResults | |
path: TestResults/ | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: CoverageReport | |
path: TestResults/**/coverage.cobertura.xml | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: TestResults/**/coverage.cobertura.xml | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: unittests | |
name: code-coverage-report | |
fail_ci_if_error: true | |
publish: | |
if: github.ref == 'refs/heads/dev' | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '9.x' | |
- name: Run publish script for all packages | |
run: | | |
chmod +x ./scripts/pack-all.sh | |
./scripts/pack-all.sh | |
- name: Upload NuGet package to NuGet.org | |
env: | |
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
run: ./scripts/publish_nuget.sh |