Merge pull request #157 from tavis-software/dependabot/nuget/xunit.ru… #112
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: Build and Test | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
solutionName: UriTemplates.sln | |
outputFolder: ./buildArtifacts | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 6.0.x | |
- name: Restore dependencies | |
run: dotnet restore ${{ env.solutionName }} | |
- name: Check formatting | |
run: dotnet format --verify-no-changes --verbosity diagnostic | |
- name: Build | |
run: dotnet build ${{ env.solutionName }} --no-restore -c Release | |
- name: Test | |
run: dotnet test ${{ env.solutionName }} --no-build --verbosity normal -c Release /p:CollectCoverage=true /p:CoverletOutput=./TestResults/ /p:CoverletOutputFormat=opencover | |
- name: Pack | |
run: dotnet pack ${{ env.solutionName }} /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg --no-build --output ${{ env.outputFolder }} -c Release | |
- name: Upload Nuget Package and Symbols | |
uses: actions/upload-artifact@v4 | |
with: | |
name: drop | |
path: | | |
${{ env.outputFolder }}/*.nupkg | |
${{ env.outputFolder }}/*.snupkg | |
deploy: | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
environment: | |
name: production | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 6.0.x | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: drop | |
- name: Nuget push | |
run: dotnet nuget push "*.nupkg" --skip-duplicate -s https://api.nuget.org/v3/index.json -k ${{ secrets.PUBLISH_GH_TOKEN }} | |