Merge pull request #86 from CompostInTraining/dependabot/github_actio… #227
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 | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
permissions: | |
checks: write | |
packages: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Restore dependencies | |
run: | | |
dotnet nuget add source --username prplecake --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/CompostInTraining/index.json" | |
dotnet restore | |
- name: Build | |
run: dotnet build --no-restore | |
- name: Test | |
run: dotnet test --no-build --verbosity normal --logger "trx" --results-directory "./TestResults" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[CiT.*.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@v3 | |
publish: | |
strategy: | |
matrix: | |
rid: [ osx-x64, linux-x64, win-x64 ] | |
runs-on: ubuntu-latest | |
name: publish-${{matrix.rid}} | |
needs: build | |
if: ${{ github.event_name != 'pull_request' }} # don't upload artifacts for PRs | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 7.0.x | |
- name: Add NuGet source | |
run: dotnet nuget add source --username prplecake --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/CompostInTraining/index.json" | |
- name: Publish CLI (${{matrix.rid}} | |
run: dotnet publish src/CiT.CLI/CiT.CLI.csproj -c Release -r ${{matrix.rid}} --self-contained | |
- name: Upload CLI artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: CiT.CLI-${{matrix.rid}} | |
path: src/CiT.CLI/bin/Release/net7.0/${{matrix.rid}}/publish/ |