Publish to NuGet + Documentation #2
Workflow file for this run
This file contains hidden or 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, Test, and Deploy Docs | |
# Trigger | |
on: | |
pull_request: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
permissions: | |
contents: read # Allow read access to the repository content | |
actions: read | |
pages: write | |
id-token: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the code from the repository | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Setup .NET environment | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.x' | |
# Install dependencies | |
- name: Install dependencies | |
run: dotnet restore | |
# Build the project | |
- name: Build project | |
run: dotnet build --configuration Release --no-restore -warnaserror | |
# Run unit tests | |
- name: Run Unit tests | |
run: dotnet test --no-build --verbosity normal --configuration Release | |
publish-docs: | |
needs: build-and-test | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Dotnet Setup | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.x | |
- run: dotnet tool update -g docfx | |
- run: docfx docs/docfx.json | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: 'docs/_site' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
deploy-to-nuget: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Create NuGet Package | |
run: dotnet pack --configuration Release | |
- name: Publish to NuGet | |
run: dotnet nuget push bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |